@mcp-i/core 0.1.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/LICENSE +21 -0
- package/README.md +390 -0
- package/dist/auth/handshake.d.ts +104 -0
- package/dist/auth/handshake.d.ts.map +1 -0
- package/dist/auth/handshake.js +230 -0
- package/dist/auth/handshake.js.map +1 -0
- package/dist/auth/index.d.ts +3 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +2 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/types.d.ts +31 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +7 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/delegation/audience-validator.d.ts +9 -0
- package/dist/delegation/audience-validator.d.ts.map +1 -0
- package/dist/delegation/audience-validator.js +17 -0
- package/dist/delegation/audience-validator.js.map +1 -0
- package/dist/delegation/bitstring.d.ts +37 -0
- package/dist/delegation/bitstring.d.ts.map +1 -0
- package/dist/delegation/bitstring.js +117 -0
- package/dist/delegation/bitstring.js.map +1 -0
- package/dist/delegation/cascading-revocation.d.ts +45 -0
- package/dist/delegation/cascading-revocation.d.ts.map +1 -0
- package/dist/delegation/cascading-revocation.js +148 -0
- package/dist/delegation/cascading-revocation.js.map +1 -0
- package/dist/delegation/delegation-graph.d.ts +49 -0
- package/dist/delegation/delegation-graph.d.ts.map +1 -0
- package/dist/delegation/delegation-graph.js +99 -0
- package/dist/delegation/delegation-graph.js.map +1 -0
- package/dist/delegation/did-key-resolver.d.ts +64 -0
- package/dist/delegation/did-key-resolver.d.ts.map +1 -0
- package/dist/delegation/did-key-resolver.js +154 -0
- package/dist/delegation/did-key-resolver.js.map +1 -0
- package/dist/delegation/did-web-resolver.d.ts +83 -0
- package/dist/delegation/did-web-resolver.d.ts.map +1 -0
- package/dist/delegation/did-web-resolver.js +218 -0
- package/dist/delegation/did-web-resolver.js.map +1 -0
- package/dist/delegation/index.d.ts +21 -0
- package/dist/delegation/index.d.ts.map +1 -0
- package/dist/delegation/index.js +21 -0
- package/dist/delegation/index.js.map +1 -0
- package/dist/delegation/outbound-headers.d.ts +81 -0
- package/dist/delegation/outbound-headers.d.ts.map +1 -0
- package/dist/delegation/outbound-headers.js +139 -0
- package/dist/delegation/outbound-headers.js.map +1 -0
- package/dist/delegation/outbound-proof.d.ts +43 -0
- package/dist/delegation/outbound-proof.d.ts.map +1 -0
- package/dist/delegation/outbound-proof.js +52 -0
- package/dist/delegation/outbound-proof.js.map +1 -0
- package/dist/delegation/statuslist-manager.d.ts +44 -0
- package/dist/delegation/statuslist-manager.d.ts.map +1 -0
- package/dist/delegation/statuslist-manager.js +126 -0
- package/dist/delegation/statuslist-manager.js.map +1 -0
- package/dist/delegation/storage/memory-graph-storage.d.ts +70 -0
- package/dist/delegation/storage/memory-graph-storage.d.ts.map +1 -0
- package/dist/delegation/storage/memory-graph-storage.js +145 -0
- package/dist/delegation/storage/memory-graph-storage.js.map +1 -0
- package/dist/delegation/storage/memory-statuslist-storage.d.ts +19 -0
- package/dist/delegation/storage/memory-statuslist-storage.d.ts.map +1 -0
- package/dist/delegation/storage/memory-statuslist-storage.js +33 -0
- package/dist/delegation/storage/memory-statuslist-storage.js.map +1 -0
- package/dist/delegation/utils.d.ts +49 -0
- package/dist/delegation/utils.d.ts.map +1 -0
- package/dist/delegation/utils.js +131 -0
- package/dist/delegation/utils.js.map +1 -0
- package/dist/delegation/vc-issuer.d.ts +56 -0
- package/dist/delegation/vc-issuer.d.ts.map +1 -0
- package/dist/delegation/vc-issuer.js +80 -0
- package/dist/delegation/vc-issuer.js.map +1 -0
- package/dist/delegation/vc-verifier.d.ts +112 -0
- package/dist/delegation/vc-verifier.d.ts.map +1 -0
- package/dist/delegation/vc-verifier.js +280 -0
- package/dist/delegation/vc-verifier.js.map +1 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/index.d.ts +2 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +2 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/logging/logger.d.ts +23 -0
- package/dist/logging/logger.d.ts.map +1 -0
- package/dist/logging/logger.js +82 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/middleware/index.d.ts +7 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +7 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/middleware/with-mcpi.d.ts +152 -0
- package/dist/middleware/with-mcpi.d.ts.map +1 -0
- package/dist/middleware/with-mcpi.js +472 -0
- package/dist/middleware/with-mcpi.js.map +1 -0
- package/dist/proof/errors.d.ts +49 -0
- package/dist/proof/errors.d.ts.map +1 -0
- package/dist/proof/errors.js +61 -0
- package/dist/proof/errors.js.map +1 -0
- package/dist/proof/generator.d.ts +65 -0
- package/dist/proof/generator.d.ts.map +1 -0
- package/dist/proof/generator.js +163 -0
- package/dist/proof/generator.js.map +1 -0
- package/dist/proof/index.d.ts +4 -0
- package/dist/proof/index.d.ts.map +1 -0
- package/dist/proof/index.js +4 -0
- package/dist/proof/index.js.map +1 -0
- package/dist/proof/verifier.d.ts +108 -0
- package/dist/proof/verifier.d.ts.map +1 -0
- package/dist/proof/verifier.js +299 -0
- package/dist/proof/verifier.js.map +1 -0
- package/dist/providers/base.d.ts +64 -0
- package/dist/providers/base.d.ts.map +1 -0
- package/dist/providers/base.js +19 -0
- package/dist/providers/base.js.map +1 -0
- package/dist/providers/index.d.ts +3 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +3 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/memory.d.ts +33 -0
- package/dist/providers/memory.d.ts.map +1 -0
- package/dist/providers/memory.js +102 -0
- package/dist/providers/memory.js.map +1 -0
- package/dist/session/index.d.ts +2 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +2 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/manager.d.ts +77 -0
- package/dist/session/manager.d.ts.map +1 -0
- package/dist/session/manager.js +251 -0
- package/dist/session/manager.js.map +1 -0
- package/dist/types/protocol.d.ts +320 -0
- package/dist/types/protocol.d.ts.map +1 -0
- package/dist/types/protocol.js +229 -0
- package/dist/types/protocol.js.map +1 -0
- package/dist/utils/base58.d.ts +31 -0
- package/dist/utils/base58.d.ts.map +1 -0
- package/dist/utils/base58.js +104 -0
- package/dist/utils/base58.js.map +1 -0
- package/dist/utils/base64.d.ts +13 -0
- package/dist/utils/base64.d.ts.map +1 -0
- package/dist/utils/base64.js +99 -0
- package/dist/utils/base64.js.map +1 -0
- package/dist/utils/crypto-service.d.ts +37 -0
- package/dist/utils/crypto-service.d.ts.map +1 -0
- package/dist/utils/crypto-service.js +153 -0
- package/dist/utils/crypto-service.js.map +1 -0
- package/dist/utils/did-helpers.d.ts +156 -0
- package/dist/utils/did-helpers.d.ts.map +1 -0
- package/dist/utils/did-helpers.js +193 -0
- package/dist/utils/did-helpers.js.map +1 -0
- package/dist/utils/ed25519-constants.d.ts +18 -0
- package/dist/utils/ed25519-constants.d.ts.map +1 -0
- package/dist/utils/ed25519-constants.js +21 -0
- package/dist/utils/ed25519-constants.js.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +105 -0
- package/src/__tests__/integration/full-flow.test.ts +362 -0
- package/src/__tests__/providers/base.test.ts +173 -0
- package/src/__tests__/providers/memory.test.ts +332 -0
- package/src/__tests__/utils/mock-providers.ts +319 -0
- package/src/__tests__/utils/node-crypto-provider.ts +93 -0
- package/src/auth/handshake.ts +411 -0
- package/src/auth/index.ts +11 -0
- package/src/auth/types.ts +40 -0
- package/src/delegation/__tests__/audience-validator.test.ts +110 -0
- package/src/delegation/__tests__/bitstring.test.ts +346 -0
- package/src/delegation/__tests__/cascading-revocation.test.ts +624 -0
- package/src/delegation/__tests__/delegation-graph.test.ts +623 -0
- package/src/delegation/__tests__/did-key-resolver.test.ts +265 -0
- package/src/delegation/__tests__/did-web-resolver.test.ts +467 -0
- package/src/delegation/__tests__/outbound-headers.test.ts +230 -0
- package/src/delegation/__tests__/outbound-proof.test.ts +179 -0
- package/src/delegation/__tests__/statuslist-manager.test.ts +515 -0
- package/src/delegation/__tests__/utils.test.ts +185 -0
- package/src/delegation/__tests__/vc-issuer.test.ts +487 -0
- package/src/delegation/__tests__/vc-verifier.test.ts +1029 -0
- package/src/delegation/audience-validator.ts +24 -0
- package/src/delegation/bitstring.ts +160 -0
- package/src/delegation/cascading-revocation.ts +224 -0
- package/src/delegation/delegation-graph.ts +143 -0
- package/src/delegation/did-key-resolver.ts +181 -0
- package/src/delegation/did-web-resolver.ts +270 -0
- package/src/delegation/index.ts +33 -0
- package/src/delegation/outbound-headers.ts +193 -0
- package/src/delegation/outbound-proof.ts +90 -0
- package/src/delegation/statuslist-manager.ts +219 -0
- package/src/delegation/storage/__tests__/memory-graph-storage.test.ts +366 -0
- package/src/delegation/storage/__tests__/memory-statuslist-storage.test.ts +228 -0
- package/src/delegation/storage/memory-graph-storage.ts +178 -0
- package/src/delegation/storage/memory-statuslist-storage.ts +42 -0
- package/src/delegation/utils.ts +189 -0
- package/src/delegation/vc-issuer.ts +137 -0
- package/src/delegation/vc-verifier.ts +440 -0
- package/src/index.ts +264 -0
- package/src/logging/__tests__/logger.test.ts +366 -0
- package/src/logging/index.ts +6 -0
- package/src/logging/logger.ts +91 -0
- package/src/middleware/__tests__/with-mcpi.test.ts +504 -0
- package/src/middleware/index.ts +16 -0
- package/src/middleware/with-mcpi.ts +766 -0
- package/src/proof/__tests__/proof-generator.test.ts +483 -0
- package/src/proof/__tests__/verifier.test.ts +488 -0
- package/src/proof/errors.ts +75 -0
- package/src/proof/generator.ts +255 -0
- package/src/proof/index.ts +22 -0
- package/src/proof/verifier.ts +449 -0
- package/src/providers/base.ts +68 -0
- package/src/providers/index.ts +15 -0
- package/src/providers/memory.ts +130 -0
- package/src/session/__tests__/session-manager.test.ts +342 -0
- package/src/session/index.ts +7 -0
- package/src/session/manager.ts +332 -0
- package/src/types/protocol.ts +596 -0
- package/src/utils/__tests__/base58.test.ts +281 -0
- package/src/utils/__tests__/base64.test.ts +239 -0
- package/src/utils/__tests__/crypto-service.test.ts +530 -0
- package/src/utils/__tests__/did-helpers.test.ts +156 -0
- package/src/utils/base58.ts +115 -0
- package/src/utils/base64.ts +116 -0
- package/src/utils/crypto-service.ts +209 -0
- package/src/utils/did-helpers.ts +210 -0
- package/src/utils/ed25519-constants.ts +23 -0
- package/src/utils/index.ts +9 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DID:web Resolver
|
|
3
|
+
*
|
|
4
|
+
* Resolves did:web DIDs by fetching /.well-known/did.json from the domain.
|
|
5
|
+
* Supports both root domain DIDs and path-based DIDs.
|
|
6
|
+
*
|
|
7
|
+
* Examples:
|
|
8
|
+
* did:web:example.com → https://example.com/.well-known/did.json
|
|
9
|
+
* did:web:example.com:agents:bot1 → https://example.com/agents/bot1/did.json
|
|
10
|
+
*
|
|
11
|
+
* @see https://w3c-ccg.github.io/did-method-web/
|
|
12
|
+
*/
|
|
13
|
+
import { logger } from '../logging/index.js';
|
|
14
|
+
/**
|
|
15
|
+
* Type guard for checking if value is a valid DID Document structure
|
|
16
|
+
*/
|
|
17
|
+
function isValidDIDDocument(value) {
|
|
18
|
+
if (typeof value !== 'object' || value === null) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const doc = value;
|
|
22
|
+
// id is required and must be a string
|
|
23
|
+
if (typeof doc['id'] !== 'string' || doc['id'].length === 0) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
// verificationMethod is optional but if present must be an array
|
|
27
|
+
if (doc['verificationMethod'] !== undefined) {
|
|
28
|
+
if (!Array.isArray(doc['verificationMethod'])) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
// Each verification method must have required fields
|
|
32
|
+
for (const vm of doc['verificationMethod']) {
|
|
33
|
+
if (!isValidVerificationMethod(vm)) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Type guard for checking if value is a valid VerificationMethod
|
|
42
|
+
*/
|
|
43
|
+
function isValidVerificationMethod(value) {
|
|
44
|
+
if (typeof value !== 'object' || value === null) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
const vm = value;
|
|
48
|
+
// id, type, and controller are required strings
|
|
49
|
+
if (typeof vm['id'] !== 'string' || vm['id'].length === 0) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
if (typeof vm['type'] !== 'string' || vm['type'].length === 0) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
if (typeof vm['controller'] !== 'string' || vm['controller'].length === 0) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Check if a DID is a did:web DID
|
|
62
|
+
*
|
|
63
|
+
* @param did - The DID to check
|
|
64
|
+
* @returns true if it's a did:web DID
|
|
65
|
+
*/
|
|
66
|
+
export function isDidWeb(did) {
|
|
67
|
+
return did.startsWith('did:web:');
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Parse a did:web DID into its components
|
|
71
|
+
*
|
|
72
|
+
* @param did - The did:web DID to parse
|
|
73
|
+
* @returns Parsed components or null if invalid
|
|
74
|
+
*/
|
|
75
|
+
export function parseDidWeb(did) {
|
|
76
|
+
if (!isDidWeb(did)) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
// Remove the 'did:web:' prefix
|
|
80
|
+
const remainder = did.slice(8);
|
|
81
|
+
if (remainder.length === 0) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
// Split by ':' to get domain and path components
|
|
85
|
+
const parts = remainder.split(':');
|
|
86
|
+
// First part is the domain (URL-decoded)
|
|
87
|
+
const domain = decodeURIComponent(parts[0]);
|
|
88
|
+
if (domain.length === 0) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
// Remaining parts form the path
|
|
92
|
+
const path = parts.slice(1).map((p) => decodeURIComponent(p));
|
|
93
|
+
return { domain, path };
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Convert a did:web DID to its resolution URL
|
|
97
|
+
*
|
|
98
|
+
* did:web:example.com → https://example.com/.well-known/did.json
|
|
99
|
+
* did:web:example.com:path:to:doc → https://example.com/path/to/doc/did.json
|
|
100
|
+
*
|
|
101
|
+
* @param did - The did:web DID
|
|
102
|
+
* @returns The resolution URL or null if invalid
|
|
103
|
+
*/
|
|
104
|
+
export function didWebToUrl(did) {
|
|
105
|
+
const parsed = parseDidWeb(did);
|
|
106
|
+
if (!parsed) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
const { domain, path } = parsed;
|
|
110
|
+
// Build the URL
|
|
111
|
+
// Note: did:web specification requires HTTPS
|
|
112
|
+
let url = `https://${domain}`;
|
|
113
|
+
if (path.length === 0) {
|
|
114
|
+
// Root domain: use /.well-known/did.json
|
|
115
|
+
url += '/.well-known/did.json';
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
// Path-based: use /path/to/resource/did.json
|
|
119
|
+
url += '/' + path.join('/') + '/did.json';
|
|
120
|
+
}
|
|
121
|
+
return url;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* DID:web resolver implementation
|
|
125
|
+
*/
|
|
126
|
+
export class DidWebResolver {
|
|
127
|
+
fetchProvider;
|
|
128
|
+
cache;
|
|
129
|
+
cacheTtl;
|
|
130
|
+
constructor(fetchProvider, options) {
|
|
131
|
+
this.fetchProvider = fetchProvider;
|
|
132
|
+
this.cache = new Map();
|
|
133
|
+
this.cacheTtl = options?.cacheTtl ?? 300_000; // 5 minutes default
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Resolve a did:web DID to its DID Document
|
|
137
|
+
*
|
|
138
|
+
* @param did - The did:web DID to resolve
|
|
139
|
+
* @returns The DID Document or null if resolution fails
|
|
140
|
+
*/
|
|
141
|
+
async resolve(did) {
|
|
142
|
+
// Check if it's a did:web
|
|
143
|
+
if (!isDidWeb(did)) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
// Check cache
|
|
147
|
+
const cached = this.cache.get(did);
|
|
148
|
+
if (cached && Date.now() < cached.expiresAt) {
|
|
149
|
+
return cached.document;
|
|
150
|
+
}
|
|
151
|
+
// Convert to URL
|
|
152
|
+
const url = didWebToUrl(did);
|
|
153
|
+
if (!url) {
|
|
154
|
+
logger.warn(`[DidWebResolver] Invalid did:web format: ${did}`);
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
// Fetch the DID document
|
|
159
|
+
const response = await this.fetchProvider.fetch(url);
|
|
160
|
+
if (!response.ok) {
|
|
161
|
+
logger.warn(`[DidWebResolver] HTTP ${response.status} fetching ${url}`);
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
// Parse JSON
|
|
165
|
+
let json;
|
|
166
|
+
try {
|
|
167
|
+
json = await response.json();
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
logger.warn(`[DidWebResolver] Invalid JSON from ${url}`);
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
// Validate structure
|
|
174
|
+
if (!isValidDIDDocument(json)) {
|
|
175
|
+
logger.warn(`[DidWebResolver] Invalid DID Document structure from ${url}`);
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
// Verify the id matches the DID
|
|
179
|
+
if (json.id !== did) {
|
|
180
|
+
logger.warn(`[DidWebResolver] DID Document id mismatch: expected ${did}, got ${json.id}`);
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
// Cache the result
|
|
184
|
+
this.cache.set(did, {
|
|
185
|
+
document: json,
|
|
186
|
+
expiresAt: Date.now() + this.cacheTtl,
|
|
187
|
+
});
|
|
188
|
+
return json;
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
logger.warn(`[DidWebResolver] Error resolving ${did}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Clear the resolution cache
|
|
197
|
+
*/
|
|
198
|
+
clearCache() {
|
|
199
|
+
this.cache.clear();
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Clear a specific entry from the cache
|
|
203
|
+
*/
|
|
204
|
+
clearCacheEntry(did) {
|
|
205
|
+
this.cache.delete(did);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Create a did:web resolver with the given fetch provider
|
|
210
|
+
*
|
|
211
|
+
* @param fetchProvider - Provider for making HTTP requests
|
|
212
|
+
* @param options - Optional configuration
|
|
213
|
+
* @returns DIDResolver implementation for did:web
|
|
214
|
+
*/
|
|
215
|
+
export function createDidWebResolver(fetchProvider, options) {
|
|
216
|
+
return new DidWebResolver(fetchProvider, options);
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=did-web-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"did-web-resolver.js","sourceRoot":"","sources":["../../src/delegation/did-web-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAU7C;;GAEG;AACH,SAAS,kBAAkB,CAAC,KAAc;IACxC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,GAAG,GAA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KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CACvG,CAAC;YACF,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED;;OAEG;IACH,UAAU;QACR,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,eAAe,CAAC,GAAW;QACzB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,aAA4B,EAC5B,OAA+B;IAE/B,OAAO,IAAI,cAAc,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delegation Module Exports (Platform-Agnostic)
|
|
3
|
+
*
|
|
4
|
+
* W3C VC-based delegation issuance and verification.
|
|
5
|
+
* Platform-specific adapters (Node.js, Cloudflare) provide signing/verification functions.
|
|
6
|
+
*/
|
|
7
|
+
export * from './vc-issuer.js';
|
|
8
|
+
export * from './vc-verifier.js';
|
|
9
|
+
export * from './bitstring.js';
|
|
10
|
+
export * from './statuslist-manager.js';
|
|
11
|
+
export * from './delegation-graph.js';
|
|
12
|
+
export * from './cascading-revocation.js';
|
|
13
|
+
export * from './utils.js';
|
|
14
|
+
export * from './outbound-proof.js';
|
|
15
|
+
export * from './outbound-headers.js';
|
|
16
|
+
export * from './audience-validator.js';
|
|
17
|
+
export { createDidKeyResolver, resolveDidKeySync, isEd25519DidKey, extractPublicKeyFromDidKey, publicKeyToJwk, } from './did-key-resolver.js';
|
|
18
|
+
export { DidWebResolver, createDidWebResolver, isDidWeb, parseDidWeb, didWebToUrl, } from './did-web-resolver.js';
|
|
19
|
+
export { MemoryStatusListStorage } from './storage/memory-statuslist-storage.js';
|
|
20
|
+
export { MemoryDelegationGraphStorage } from './storage/memory-graph-storage.js';
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/delegation/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,0BAA0B,EAC1B,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,QAAQ,EACR,WAAW,EACX,WAAW,GACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delegation Module Exports (Platform-Agnostic)
|
|
3
|
+
*
|
|
4
|
+
* W3C VC-based delegation issuance and verification.
|
|
5
|
+
* Platform-specific adapters (Node.js, Cloudflare) provide signing/verification functions.
|
|
6
|
+
*/
|
|
7
|
+
export * from './vc-issuer.js';
|
|
8
|
+
export * from './vc-verifier.js';
|
|
9
|
+
export * from './bitstring.js';
|
|
10
|
+
export * from './statuslist-manager.js';
|
|
11
|
+
export * from './delegation-graph.js';
|
|
12
|
+
export * from './cascading-revocation.js';
|
|
13
|
+
export * from './utils.js';
|
|
14
|
+
export * from './outbound-proof.js';
|
|
15
|
+
export * from './outbound-headers.js';
|
|
16
|
+
export * from './audience-validator.js';
|
|
17
|
+
export { createDidKeyResolver, resolveDidKeySync, isEd25519DidKey, extractPublicKeyFromDidKey, publicKeyToJwk, } from './did-key-resolver.js';
|
|
18
|
+
export { DidWebResolver, createDidWebResolver, isDidWeb, parseDidWeb, didWebToUrl, } from './did-web-resolver.js';
|
|
19
|
+
export { MemoryStatusListStorage } from './storage/memory-statuslist-storage.js';
|
|
20
|
+
export { MemoryDelegationGraphStorage } from './storage/memory-graph-storage.js';
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/delegation/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,0BAA0B,EAC1B,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,QAAQ,EACR,WAAW,EACX,WAAW,GACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outbound Delegation Headers
|
|
3
|
+
*
|
|
4
|
+
* Builds the full set of outbound delegation headers for forwarding
|
|
5
|
+
* delegation context to downstream services.
|
|
6
|
+
*
|
|
7
|
+
* Headers (MCP-I §7):
|
|
8
|
+
* - X-Agent-DID: the original agent's DID
|
|
9
|
+
* - X-Delegation-Chain: the delegation chain ID (vcId of the root delegation)
|
|
10
|
+
* - X-Session-ID: the current session ID
|
|
11
|
+
* - X-Delegation-Proof: a signed JWT proving the delegation is being forwarded
|
|
12
|
+
*
|
|
13
|
+
* Related Spec: MCP-I §7 — Outbound Delegation Propagation
|
|
14
|
+
*/
|
|
15
|
+
import type { SessionContext, DelegationRecord } from '../types/protocol.js';
|
|
16
|
+
import type { CryptoProvider } from '../providers/base.js';
|
|
17
|
+
/**
|
|
18
|
+
* Header names for outbound delegation propagation
|
|
19
|
+
*/
|
|
20
|
+
export declare const OUTBOUND_HEADER_NAMES: {
|
|
21
|
+
readonly AGENT_DID: "X-Agent-DID";
|
|
22
|
+
readonly DELEGATION_CHAIN: "X-Delegation-Chain";
|
|
23
|
+
readonly SESSION_ID: "X-Session-ID";
|
|
24
|
+
readonly DELEGATION_PROOF: "X-Delegation-Proof";
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Context required to build outbound delegation headers
|
|
28
|
+
*/
|
|
29
|
+
export interface OutboundDelegationContext {
|
|
30
|
+
/** The current session context */
|
|
31
|
+
session: SessionContext;
|
|
32
|
+
/** The delegation record being forwarded */
|
|
33
|
+
delegation: DelegationRecord;
|
|
34
|
+
/** The MCP server's identity for signing the proof */
|
|
35
|
+
serverIdentity: {
|
|
36
|
+
did: string;
|
|
37
|
+
kid: string;
|
|
38
|
+
privateKey: string;
|
|
39
|
+
};
|
|
40
|
+
/** The downstream URL being called */
|
|
41
|
+
targetUrl: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Outbound delegation headers to attach to downstream requests
|
|
45
|
+
*/
|
|
46
|
+
export interface OutboundDelegationHeaders {
|
|
47
|
+
'X-Agent-DID': string;
|
|
48
|
+
'X-Delegation-Chain': string;
|
|
49
|
+
'X-Session-ID': string;
|
|
50
|
+
'X-Delegation-Proof': string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Build outbound delegation headers for forwarding to downstream services.
|
|
54
|
+
*
|
|
55
|
+
* When an MCP server calls a downstream service on behalf of an agent,
|
|
56
|
+
* it MUST forward the delegation context using these headers so the
|
|
57
|
+
* downstream service can independently verify the delegation chain.
|
|
58
|
+
*
|
|
59
|
+
* @param context - The delegation context including session, delegation, and server identity
|
|
60
|
+
* @param _cryptoProvider - CryptoProvider (reserved for future use)
|
|
61
|
+
* @returns Headers object to attach to the outbound request
|
|
62
|
+
*
|
|
63
|
+
* @throws {Error} If session is missing agentDid or sessionId
|
|
64
|
+
* @throws {Error} If delegation is missing vcId
|
|
65
|
+
* @throws {Error} If serverIdentity.did is not a valid Ed25519 did:key
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const headers = await buildOutboundDelegationHeaders({
|
|
70
|
+
* session,
|
|
71
|
+
* delegation,
|
|
72
|
+
* serverIdentity: { did: serverDid, kid: serverKid, privateKey },
|
|
73
|
+
* targetUrl: 'https://downstream-api.example.com/resource',
|
|
74
|
+
* }, cryptoProvider);
|
|
75
|
+
*
|
|
76
|
+
* // Attach headers to your HTTP request
|
|
77
|
+
* fetch(targetUrl, { headers });
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare function buildOutboundDelegationHeaders(context: OutboundDelegationContext, _cryptoProvider: CryptoProvider): Promise<OutboundDelegationHeaders>;
|
|
81
|
+
//# sourceMappingURL=outbound-headers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbound-headers.d.ts","sourceRoot":"","sources":["../../src/delegation/outbound-headers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAM3D;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;CAKxB,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,kCAAkC;IAClC,OAAO,EAAE,cAAc,CAAC;IACxB,4CAA4C;IAC5C,UAAU,EAAE,gBAAgB,CAAC;IAC7B,sDAAsD;IACtD,cAAc,EAAE;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;QACZ,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,sCAAsC;IACtC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAgDD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,8BAA8B,CAClD,OAAO,EAAE,yBAAyB,EAClC,eAAe,EAAE,cAAc,GAC9B,OAAO,CAAC,yBAAyB,CAAC,CAuDpC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outbound Delegation Headers
|
|
3
|
+
*
|
|
4
|
+
* Builds the full set of outbound delegation headers for forwarding
|
|
5
|
+
* delegation context to downstream services.
|
|
6
|
+
*
|
|
7
|
+
* Headers (MCP-I §7):
|
|
8
|
+
* - X-Agent-DID: the original agent's DID
|
|
9
|
+
* - X-Delegation-Chain: the delegation chain ID (vcId of the root delegation)
|
|
10
|
+
* - X-Session-ID: the current session ID
|
|
11
|
+
* - X-Delegation-Proof: a signed JWT proving the delegation is being forwarded
|
|
12
|
+
*
|
|
13
|
+
* Related Spec: MCP-I §7 — Outbound Delegation Propagation
|
|
14
|
+
*/
|
|
15
|
+
import { buildDelegationProofJWT } from './outbound-proof.js';
|
|
16
|
+
import { extractPublicKeyFromDidKey, isEd25519DidKey } from './did-key-resolver.js';
|
|
17
|
+
import { base64ToBytes, base64urlEncodeFromBytes } from '../utils/base64.js';
|
|
18
|
+
import { logger } from '../logging/index.js';
|
|
19
|
+
/**
|
|
20
|
+
* Header names for outbound delegation propagation
|
|
21
|
+
*/
|
|
22
|
+
export const OUTBOUND_HEADER_NAMES = {
|
|
23
|
+
AGENT_DID: 'X-Agent-DID',
|
|
24
|
+
DELEGATION_CHAIN: 'X-Delegation-Chain',
|
|
25
|
+
SESSION_ID: 'X-Session-ID',
|
|
26
|
+
DELEGATION_PROOF: 'X-Delegation-Proof',
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Extract hostname from a URL
|
|
30
|
+
*/
|
|
31
|
+
function extractHostname(url) {
|
|
32
|
+
try {
|
|
33
|
+
const parsed = new URL(url);
|
|
34
|
+
return parsed.hostname;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
logger.warn('Failed to parse target URL, using as-is', { url });
|
|
38
|
+
return url;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Convert base64 private key and DID to Ed25519 JWK format
|
|
43
|
+
*/
|
|
44
|
+
function buildPrivateKeyJwk(privateKeyBase64, serverDid) {
|
|
45
|
+
// Decode the private key from base64
|
|
46
|
+
const privateKeyBytes = base64ToBytes(privateKeyBase64);
|
|
47
|
+
// Extract the 32-byte seed (handle both 32-byte and 64-byte formats)
|
|
48
|
+
const seed = privateKeyBytes.length === 64
|
|
49
|
+
? privateKeyBytes.subarray(0, 32)
|
|
50
|
+
: privateKeyBytes;
|
|
51
|
+
// Extract public key from did:key
|
|
52
|
+
if (!isEd25519DidKey(serverDid)) {
|
|
53
|
+
throw new Error(`Server DID must be did:key with Ed25519: ${serverDid}`);
|
|
54
|
+
}
|
|
55
|
+
const publicKeyBytes = extractPublicKeyFromDidKey(serverDid);
|
|
56
|
+
if (!publicKeyBytes) {
|
|
57
|
+
throw new Error(`Failed to extract public key from DID: ${serverDid}`);
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
kty: 'OKP',
|
|
61
|
+
crv: 'Ed25519',
|
|
62
|
+
x: base64urlEncodeFromBytes(publicKeyBytes),
|
|
63
|
+
d: base64urlEncodeFromBytes(seed),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Build outbound delegation headers for forwarding to downstream services.
|
|
68
|
+
*
|
|
69
|
+
* When an MCP server calls a downstream service on behalf of an agent,
|
|
70
|
+
* it MUST forward the delegation context using these headers so the
|
|
71
|
+
* downstream service can independently verify the delegation chain.
|
|
72
|
+
*
|
|
73
|
+
* @param context - The delegation context including session, delegation, and server identity
|
|
74
|
+
* @param _cryptoProvider - CryptoProvider (reserved for future use)
|
|
75
|
+
* @returns Headers object to attach to the outbound request
|
|
76
|
+
*
|
|
77
|
+
* @throws {Error} If session is missing agentDid or sessionId
|
|
78
|
+
* @throws {Error} If delegation is missing vcId
|
|
79
|
+
* @throws {Error} If serverIdentity.did is not a valid Ed25519 did:key
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* const headers = await buildOutboundDelegationHeaders({
|
|
84
|
+
* session,
|
|
85
|
+
* delegation,
|
|
86
|
+
* serverIdentity: { did: serverDid, kid: serverKid, privateKey },
|
|
87
|
+
* targetUrl: 'https://downstream-api.example.com/resource',
|
|
88
|
+
* }, cryptoProvider);
|
|
89
|
+
*
|
|
90
|
+
* // Attach headers to your HTTP request
|
|
91
|
+
* fetch(targetUrl, { headers });
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export async function buildOutboundDelegationHeaders(context, _cryptoProvider) {
|
|
95
|
+
const { session, delegation, serverIdentity, targetUrl } = context;
|
|
96
|
+
// Validate required fields
|
|
97
|
+
if (!session.agentDid) {
|
|
98
|
+
throw new Error('Session must have agentDid for outbound delegation');
|
|
99
|
+
}
|
|
100
|
+
if (!session.sessionId) {
|
|
101
|
+
throw new Error('Session must have sessionId for outbound delegation');
|
|
102
|
+
}
|
|
103
|
+
if (!delegation.vcId) {
|
|
104
|
+
throw new Error('Delegation must have vcId for outbound delegation');
|
|
105
|
+
}
|
|
106
|
+
// Extract hostname for JWT audience
|
|
107
|
+
const targetHostname = extractHostname(targetUrl);
|
|
108
|
+
// Build the private key JWK from the server identity
|
|
109
|
+
const privateKeyJwk = buildPrivateKeyJwk(serverIdentity.privateKey, serverIdentity.did);
|
|
110
|
+
// Build the delegation proof JWT
|
|
111
|
+
// Per MCP-I §7, the JWT has:
|
|
112
|
+
// - iss: serverDid (the MCP server forwarding the request)
|
|
113
|
+
// - sub: agentDid (the original agent)
|
|
114
|
+
// - aud: targetHostname (the downstream service)
|
|
115
|
+
// - scope: "delegation:propagate"
|
|
116
|
+
const jwt = await buildDelegationProofJWT({
|
|
117
|
+
agentDid: serverIdentity.did, // becomes iss (server forwarding)
|
|
118
|
+
userDid: session.agentDid, // becomes sub (original agent)
|
|
119
|
+
delegationId: delegation.id,
|
|
120
|
+
delegationChain: delegation.vcId,
|
|
121
|
+
scopes: ['delegation:propagate'],
|
|
122
|
+
privateKeyJwk,
|
|
123
|
+
kid: serverIdentity.kid,
|
|
124
|
+
targetHostname,
|
|
125
|
+
});
|
|
126
|
+
logger.debug('Built outbound delegation headers', {
|
|
127
|
+
agentDid: session.agentDid,
|
|
128
|
+
delegationChain: delegation.vcId,
|
|
129
|
+
sessionId: session.sessionId,
|
|
130
|
+
targetHostname,
|
|
131
|
+
});
|
|
132
|
+
return {
|
|
133
|
+
'X-Agent-DID': session.agentDid,
|
|
134
|
+
'X-Delegation-Chain': delegation.vcId,
|
|
135
|
+
'X-Session-ID': session.sessionId,
|
|
136
|
+
'X-Delegation-Proof': jwt,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=outbound-headers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbound-headers.js","sourceRoot":"","sources":["../../src/delegation/outbound-headers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAAE,uBAAu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B,eAAe,EAAE,UAAU,CAAC,IAAI;QAChC,MAAM,EAAE,CAAC,sBAAsB,CAAC;QAChC,aAAa;QACb,GAAG,EAAE,cAAc,CAAC,GAAG;QACvB,cAAc;KACf,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,mCAAmC,EAAE;QAChD,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,eAAe,EAAE,UAAU,CAAC,IAAI;QAChC,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,cAAc;KACf,CAAC,CAAC;IAEH,OAAO;QACL,aAAa,EAAE,OAAO,CAAC,QAAQ;QAC/B,oBAAoB,EAAE,UAAU,CAAC,IAAI;QACrC,cAAc,EAAE,OAAO,CAAC,SAAS;QACjC,oBAAoB,EAAE,GAAG;KAC1B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outbound Delegation Proof
|
|
3
|
+
*
|
|
4
|
+
* Builds signed delegation proof JWTs for injection on outbound HTTP requests.
|
|
5
|
+
* Enables downstream services to independently verify the delegation chain.
|
|
6
|
+
*
|
|
7
|
+
* Wire format: signed compact EdDSA JWT (60s TTL, per-call jti)
|
|
8
|
+
* Header injection: X-Delegation-Id, X-Delegation-Chain, X-Delegation-Proof, X-Scopes
|
|
9
|
+
*
|
|
10
|
+
* Related Spec: MCP-I §2 — Outbound Delegation Propagation
|
|
11
|
+
*/
|
|
12
|
+
import type { DelegationRecord } from '../types/protocol.js';
|
|
13
|
+
export interface Ed25519PrivateJWK {
|
|
14
|
+
kty: 'OKP';
|
|
15
|
+
crv: 'Ed25519';
|
|
16
|
+
x: string;
|
|
17
|
+
d: string;
|
|
18
|
+
kid?: string;
|
|
19
|
+
use?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface DelegationProofOptions {
|
|
22
|
+
agentDid: string;
|
|
23
|
+
userDid: string;
|
|
24
|
+
delegationId: string;
|
|
25
|
+
delegationChain: string;
|
|
26
|
+
scopes: string[];
|
|
27
|
+
privateKeyJwk: Ed25519PrivateJWK;
|
|
28
|
+
kid: string;
|
|
29
|
+
targetHostname: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Build a signed delegation proof JWT for outbound HTTP requests.
|
|
33
|
+
*
|
|
34
|
+
* Creates a short-lived (60s) EdDSA-signed JWT containing delegation context
|
|
35
|
+
* that can be verified by downstream services without access to the MCP server.
|
|
36
|
+
*
|
|
37
|
+
* @param options - Proof options including DIDs, delegation info, scopes, and signing key
|
|
38
|
+
* @returns Compact JWS string (header.payload.signature)
|
|
39
|
+
* @throws {Error} If key import or signing fails
|
|
40
|
+
*/
|
|
41
|
+
export declare function buildDelegationProofJWT(options: DelegationProofOptions): Promise<string>;
|
|
42
|
+
export declare function buildChainString(delegation: DelegationRecord): string;
|
|
43
|
+
//# sourceMappingURL=outbound-proof.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbound-proof.d.ts","sourceRoot":"","sources":["../../src/delegation/outbound-proof.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,KAAK,CAAC;IACX,GAAG,EAAE,SAAS,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,aAAa,EAAE,iBAAiB,CAAC;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;GASG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAgCjB;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,gBAAgB,GAAG,MAAM,CAQrE"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outbound Delegation Proof
|
|
3
|
+
*
|
|
4
|
+
* Builds signed delegation proof JWTs for injection on outbound HTTP requests.
|
|
5
|
+
* Enables downstream services to independently verify the delegation chain.
|
|
6
|
+
*
|
|
7
|
+
* Wire format: signed compact EdDSA JWT (60s TTL, per-call jti)
|
|
8
|
+
* Header injection: X-Delegation-Id, X-Delegation-Chain, X-Delegation-Proof, X-Scopes
|
|
9
|
+
*
|
|
10
|
+
* Related Spec: MCP-I §2 — Outbound Delegation Propagation
|
|
11
|
+
*/
|
|
12
|
+
import { SignJWT, importJWK } from 'jose';
|
|
13
|
+
/**
|
|
14
|
+
* Build a signed delegation proof JWT for outbound HTTP requests.
|
|
15
|
+
*
|
|
16
|
+
* Creates a short-lived (60s) EdDSA-signed JWT containing delegation context
|
|
17
|
+
* that can be verified by downstream services without access to the MCP server.
|
|
18
|
+
*
|
|
19
|
+
* @param options - Proof options including DIDs, delegation info, scopes, and signing key
|
|
20
|
+
* @returns Compact JWS string (header.payload.signature)
|
|
21
|
+
* @throws {Error} If key import or signing fails
|
|
22
|
+
*/
|
|
23
|
+
export async function buildDelegationProofJWT(options) {
|
|
24
|
+
const { agentDid, userDid, delegationId, delegationChain, scopes, privateKeyJwk, kid, targetHostname, } = options;
|
|
25
|
+
const privateKey = await importJWK(privateKeyJwk, 'EdDSA');
|
|
26
|
+
const iat = Math.floor(Date.now() / 1000);
|
|
27
|
+
const exp = iat + 60;
|
|
28
|
+
const jwt = await new SignJWT({
|
|
29
|
+
delegation_id: delegationId,
|
|
30
|
+
delegation_chain: delegationChain,
|
|
31
|
+
scope: scopes.join(','),
|
|
32
|
+
})
|
|
33
|
+
.setProtectedHeader({ alg: 'EdDSA', kid })
|
|
34
|
+
.setIssuer(agentDid)
|
|
35
|
+
.setSubject(userDid)
|
|
36
|
+
.setJti(crypto.randomUUID())
|
|
37
|
+
.setAudience(targetHostname)
|
|
38
|
+
.setIssuedAt(iat)
|
|
39
|
+
.setExpirationTime(exp)
|
|
40
|
+
.sign(privateKey);
|
|
41
|
+
return jwt;
|
|
42
|
+
}
|
|
43
|
+
export function buildChainString(delegation) {
|
|
44
|
+
if (!delegation.id && !delegation.vcId) {
|
|
45
|
+
return '';
|
|
46
|
+
}
|
|
47
|
+
if (!delegation.vcId) {
|
|
48
|
+
return delegation.id;
|
|
49
|
+
}
|
|
50
|
+
return `${delegation.vcId}>${delegation.id}`;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=outbound-proof.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbound-proof.js","sourceRoot":"","sources":["../../src/delegation/outbound-proof.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAuB1C;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,OAA+B;IAE/B,MAAM,EACJ,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,eAAe,EACf,MAAM,EACN,aAAa,EACb,GAAG,EACH,cAAc,GACf,GAAG,OAAO,CAAC;IAEZ,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAE3D,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAC1C,MAAM,GAAG,GAAG,GAAG,GAAG,EAAE,CAAC;IAErB,MAAM,GAAG,GAAG,MAAM,IAAI,OAAO,CAAC;QAC5B,aAAa,EAAE,YAAY;QAC3B,gBAAgB,EAAE,eAAe;QACjC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;KACxB,CAAC;SACC,kBAAkB,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;SACzC,SAAS,CAAC,QAAQ,CAAC;SACnB,UAAU,CAAC,OAAO,CAAC;SACnB,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;SAC3B,WAAW,CAAC,cAAc,CAAC;SAC3B,WAAW,CAAC,GAAG,CAAC;SAChB,iBAAiB,CAAC,GAAG,CAAC;SACtB,IAAI,CAAC,UAAU,CAAC,CAAC;IAEpB,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,UAA4B;IAC3D,IAAI,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;QACvC,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;QACrB,OAAO,UAAU,CAAC,EAAE,CAAC;IACvB,CAAC;IACD,OAAO,GAAG,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,EAAE,EAAE,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StatusList2021 Manager
|
|
3
|
+
*
|
|
4
|
+
* Manages StatusList2021 credentials for efficient delegation revocation.
|
|
5
|
+
*
|
|
6
|
+
* Related Spec: W3C StatusList2021
|
|
7
|
+
*/
|
|
8
|
+
import type { StatusList2021Credential, CredentialStatus } from '../types/protocol.js';
|
|
9
|
+
import { type CompressionFunction, type DecompressionFunction } from './bitstring.js';
|
|
10
|
+
import type { VCSigningFunction } from './vc-issuer.js';
|
|
11
|
+
export interface StatusListStorageProvider {
|
|
12
|
+
getStatusList(statusListId: string): Promise<StatusList2021Credential | null>;
|
|
13
|
+
setStatusList(statusListId: string, credential: StatusList2021Credential): Promise<void>;
|
|
14
|
+
allocateIndex(statusListId: string): Promise<number>;
|
|
15
|
+
}
|
|
16
|
+
export interface StatusListIdentityProvider {
|
|
17
|
+
getDid(): string;
|
|
18
|
+
getKeyId(): string;
|
|
19
|
+
}
|
|
20
|
+
export declare class StatusList2021Manager {
|
|
21
|
+
private storage;
|
|
22
|
+
private identity;
|
|
23
|
+
private signingFunction;
|
|
24
|
+
private compressor;
|
|
25
|
+
private decompressor;
|
|
26
|
+
private statusListBaseUrl;
|
|
27
|
+
private defaultListSize;
|
|
28
|
+
constructor(storage: StatusListStorageProvider, identity: StatusListIdentityProvider, signingFunction: VCSigningFunction, compressor: CompressionFunction, decompressor: DecompressionFunction, options?: {
|
|
29
|
+
statusListBaseUrl?: string;
|
|
30
|
+
defaultListSize?: number;
|
|
31
|
+
});
|
|
32
|
+
allocateStatusEntry(purpose: 'revocation' | 'suspension'): Promise<CredentialStatus>;
|
|
33
|
+
updateStatus(credentialStatus: CredentialStatus, revoked: boolean): Promise<void>;
|
|
34
|
+
checkStatus(credentialStatus: CredentialStatus): Promise<boolean>;
|
|
35
|
+
getRevokedIndices(statusListId: string): Promise<number[]>;
|
|
36
|
+
private ensureStatusListExists;
|
|
37
|
+
getStatusListBaseUrl(): string;
|
|
38
|
+
getDefaultListSize(): number;
|
|
39
|
+
}
|
|
40
|
+
export declare function createStatusListManager(storage: StatusListStorageProvider, identity: StatusListIdentityProvider, signingFunction: VCSigningFunction, compressor: CompressionFunction, decompressor: DecompressionFunction, options?: {
|
|
41
|
+
statusListBaseUrl?: string;
|
|
42
|
+
defaultListSize?: number;
|
|
43
|
+
}): StatusList2021Manager;
|
|
44
|
+
//# sourceMappingURL=statuslist-manager.d.ts.map
|