agent-passport-system-mcp 6.0.1 → 6.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/README.md +1 -1
- package/build/__tests__/nullifier-store.test.d.ts +1 -0
- package/build/__tests__/nullifier-store.test.js +331 -0
- package/build/capabilityToken/index.d.ts +2 -2
- package/build/capabilityToken/index.js +1 -1
- package/build/capabilityToken/nullifierSet.d.ts +59 -0
- package/build/capabilityToken/nullifierSet.js +238 -3
- package/build/index.js +55 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -217,7 +217,7 @@ Layer 1: Agent Passport Protocol (Ed25519 identity)
|
|
|
217
217
|
|
|
218
218
|
## Links
|
|
219
219
|
|
|
220
|
-
- npm SDK: [agent-passport-system](https://www.npmjs.com/package/agent-passport-system) (
|
|
220
|
+
- npm SDK: [agent-passport-system](https://www.npmjs.com/package/agent-passport-system) (v7.0.0, 5,491 tests)
|
|
221
221
|
- Python SDK: [agent-passport-system](https://pypi.org/project/agent-passport-system/) (v3.0.0)
|
|
222
222
|
- Rust SDK: [agent-passport-system](https://crates.io/crates/agent-passport-system) (v0.3.0; library crate `agent_passport`)
|
|
223
223
|
- Go SDK: [agent-passport-go](https://pkg.go.dev/github.com/aeoess/agent-passport-go) (v0.7.0; `go get github.com/aeoess/agent-passport-go@v0.7.0`)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
// Copyright 2026 Tymofii Pidlisnyi. Apache-2.0 license. See LICENSE.
|
|
2
|
+
// FileNullifierStore is the durable, cross-process replacement for the
|
|
3
|
+
// in-memory nullifier set on the capability-token redemption path
|
|
4
|
+
// (aps_capability_sign_effect in src/index.ts). These tests exercise the
|
|
5
|
+
// properties an in-memory Set cannot provide: survival across process
|
|
6
|
+
// restarts, and a single winner when multiple processes race to redeem
|
|
7
|
+
// the same token.
|
|
8
|
+
import { test } from "node:test";
|
|
9
|
+
import assert from "node:assert/strict";
|
|
10
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
11
|
+
import { mkdtempSync, mkdirSync, chmodSync, closeSync, openSync, readFileSync, readdirSync, rmSync, statSync, symlinkSync, } from "node:fs";
|
|
12
|
+
import { tmpdir } from "node:os";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import { FileNullifierStore, HOSTED_NULLIFIER_SENTINEL, NullifierReplayError, } from "../capabilityToken/nullifierSet.js";
|
|
15
|
+
import { sha256Hex } from "../capabilityToken/canonical.js";
|
|
16
|
+
// Absolute file:// URL to the compiled module, for child processes spawned
|
|
17
|
+
// via `node --input-type=module -e`, which have no relative-import context
|
|
18
|
+
// of their own.
|
|
19
|
+
const NULLIFIER_MODULE_URL = new URL("../capabilityToken/nullifierSet.js", import.meta.url).href;
|
|
20
|
+
function freshDir() {
|
|
21
|
+
return mkdtempSync(join(tmpdir(), "aps-nullifier-"));
|
|
22
|
+
}
|
|
23
|
+
// Runs `store.consume(preimage)` against `dir` in a brand-new node process.
|
|
24
|
+
// Returns the exit code (0 = consumed, 1 = threw — replay or otherwise) and
|
|
25
|
+
// stderr (for asserting on the replay message).
|
|
26
|
+
function consumeInChildProcess(dir, preimage) {
|
|
27
|
+
const script = `
|
|
28
|
+
const { FileNullifierStore } = await import(${JSON.stringify(NULLIFIER_MODULE_URL)});
|
|
29
|
+
const store = new FileNullifierStore(${JSON.stringify(dir)});
|
|
30
|
+
try {
|
|
31
|
+
store.consume(${JSON.stringify(preimage)});
|
|
32
|
+
process.exit(0);
|
|
33
|
+
} catch (e) {
|
|
34
|
+
process.stderr.write(String(e && e.message));
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
const result = spawnSync(process.execPath, ["--input-type=module", "-e", script], {
|
|
39
|
+
encoding: "utf-8",
|
|
40
|
+
});
|
|
41
|
+
return { status: result.status, stderr: result.stderr };
|
|
42
|
+
}
|
|
43
|
+
test("consume() rejects a second attempt on the same preimage with NullifierReplayError", () => {
|
|
44
|
+
const dir = freshDir();
|
|
45
|
+
try {
|
|
46
|
+
const store = new FileNullifierStore(dir);
|
|
47
|
+
const preimage = "preimage-unit-test-001";
|
|
48
|
+
assert.equal(store.isConsumed(preimage), false);
|
|
49
|
+
store.consume(preimage);
|
|
50
|
+
assert.equal(store.isConsumed(preimage), true);
|
|
51
|
+
assert.throws(() => store.consume(preimage), NullifierReplayError);
|
|
52
|
+
assert.equal(store.size(), 1);
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
rmSync(dir, { recursive: true, force: true });
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
test("release() un-burns a token so a later consume() succeeds", () => {
|
|
59
|
+
const dir = freshDir();
|
|
60
|
+
try {
|
|
61
|
+
const store = new FileNullifierStore(dir);
|
|
62
|
+
const preimage = "preimage-unit-test-release";
|
|
63
|
+
store.consume(preimage);
|
|
64
|
+
store.release(preimage);
|
|
65
|
+
assert.equal(store.isConsumed(preimage), false);
|
|
66
|
+
store.consume(preimage); // does not throw
|
|
67
|
+
assert.equal(store.size(), 1);
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
rmSync(dir, { recursive: true, force: true });
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
test("clear() removes every consumed marker in the directory", () => {
|
|
74
|
+
const dir = freshDir();
|
|
75
|
+
try {
|
|
76
|
+
const store = new FileNullifierStore(dir);
|
|
77
|
+
store.consume("a");
|
|
78
|
+
store.consume("b");
|
|
79
|
+
assert.equal(store.size(), 2);
|
|
80
|
+
store.clear();
|
|
81
|
+
assert.equal(store.size(), 0);
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
rmSync(dir, { recursive: true, force: true });
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
test("the preimage itself never appears on disk — only its SHA-256 hash as a filename", () => {
|
|
88
|
+
const dir = freshDir();
|
|
89
|
+
try {
|
|
90
|
+
const store = new FileNullifierStore(dir);
|
|
91
|
+
const preimage = "super-secret-token-preimage-do-not-persist";
|
|
92
|
+
store.consume(preimage);
|
|
93
|
+
const entries = readdirSync(dir);
|
|
94
|
+
assert.equal(entries.length, 1);
|
|
95
|
+
const [filename] = entries;
|
|
96
|
+
// Filename is the hash, not the preimage, and matches sha256Hex exactly.
|
|
97
|
+
assert.equal(filename, sha256Hex(preimage));
|
|
98
|
+
assert.notEqual(filename, preimage);
|
|
99
|
+
assert.doesNotMatch(filename, /secret|preimage/);
|
|
100
|
+
// File contents (a timestamp) never contain the preimage either.
|
|
101
|
+
const contents = readFileSync(join(dir, filename), "utf-8");
|
|
102
|
+
assert.doesNotMatch(contents, /secret|preimage/);
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
rmSync(dir, { recursive: true, force: true });
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
test("an unwritable directory fails closed on redemption instead of falling back to memory", () => {
|
|
109
|
+
const parent = freshDir();
|
|
110
|
+
const dir = join(parent, "locked");
|
|
111
|
+
try {
|
|
112
|
+
// Directory exists but is read-only: mkdirSync(recursive) succeeds
|
|
113
|
+
// (no-op), so the writability probe in the constructor is what must
|
|
114
|
+
// catch this.
|
|
115
|
+
mkdirSync(dir);
|
|
116
|
+
chmodSync(dir, 0o500); // r-x------: cannot create files inside
|
|
117
|
+
const store = new FileNullifierStore(dir);
|
|
118
|
+
assert.throws(() => store.consume("whatever"), /not usable|not writable|EACCES|permission/i);
|
|
119
|
+
assert.throws(() => store.isConsumed("whatever"), /not usable|not writable|EACCES|permission/i);
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
chmodSync(dir, 0o700);
|
|
123
|
+
rmSync(parent, { recursive: true, force: true });
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
test("a freshly created directory and marker are owner-only (0700 / 0600)", () => {
|
|
127
|
+
const parent = freshDir();
|
|
128
|
+
const dir = join(parent, "nested", "nullifiers");
|
|
129
|
+
try {
|
|
130
|
+
const store = new FileNullifierStore(dir);
|
|
131
|
+
assert.equal(statSync(dir).mode & 0o777, 0o700);
|
|
132
|
+
store.consume("mode-check-preimage");
|
|
133
|
+
const [filename] = readdirSync(dir);
|
|
134
|
+
assert.equal(statSync(join(dir, filename)).mode & 0o777, 0o600);
|
|
135
|
+
}
|
|
136
|
+
finally {
|
|
137
|
+
rmSync(parent, { recursive: true, force: true });
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
test("refuses an existing directory that is group- or world-writable", () => {
|
|
141
|
+
const parent = freshDir();
|
|
142
|
+
const dir = join(parent, "shared");
|
|
143
|
+
try {
|
|
144
|
+
mkdirSync(dir);
|
|
145
|
+
chmodSync(dir, 0o777); // chmod bypasses umask, unlike mkdirSync's mode option
|
|
146
|
+
const store = new FileNullifierStore(dir);
|
|
147
|
+
assert.throws(() => store.consume("whatever"), /group- or world-writable/i);
|
|
148
|
+
assert.throws(() => store.isConsumed("whatever"), /group- or world-writable/i);
|
|
149
|
+
}
|
|
150
|
+
finally {
|
|
151
|
+
chmodSync(dir, 0o700);
|
|
152
|
+
rmSync(parent, { recursive: true, force: true });
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
test("hosted mode refuses a missing APS_NULLIFIER_DIR", () => {
|
|
156
|
+
const store = new FileNullifierStore(undefined, { hosted: true });
|
|
157
|
+
assert.throws(() => store.consume("whatever"), /APS_NULLIFIER_DIR must be set explicitly/i);
|
|
158
|
+
assert.throws(() => store.isConsumed("whatever"), /APS_NULLIFIER_DIR must be set explicitly/i);
|
|
159
|
+
});
|
|
160
|
+
test("hosted mode refuses a directory that does not exist", () => {
|
|
161
|
+
const parent = freshDir();
|
|
162
|
+
const dir = join(parent, "never-provisioned");
|
|
163
|
+
try {
|
|
164
|
+
const store = new FileNullifierStore(dir, { hosted: true });
|
|
165
|
+
assert.throws(() => store.consume("whatever"), /does not exist/i);
|
|
166
|
+
}
|
|
167
|
+
finally {
|
|
168
|
+
rmSync(parent, { recursive: true, force: true });
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
test("hosted mode refuses an existing directory missing the provisioning sentinel", () => {
|
|
172
|
+
const dir = freshDir();
|
|
173
|
+
try {
|
|
174
|
+
// Directory exists (as it would if only the volume were mounted) but
|
|
175
|
+
// was never actually provisioned with the sentinel file.
|
|
176
|
+
const store = new FileNullifierStore(dir, { hosted: true });
|
|
177
|
+
assert.throws(() => store.consume("whatever"), new RegExp(HOSTED_NULLIFIER_SENTINEL));
|
|
178
|
+
}
|
|
179
|
+
finally {
|
|
180
|
+
rmSync(dir, { recursive: true, force: true });
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
test("hosted mode works with a pre-created directory plus sentinel, and never creates the directory itself", () => {
|
|
184
|
+
const parent = freshDir();
|
|
185
|
+
const dir = join(parent, "provisioned");
|
|
186
|
+
try {
|
|
187
|
+
mkdirSync(dir, { mode: 0o700 });
|
|
188
|
+
closeSync(openSync(join(dir, HOSTED_NULLIFIER_SENTINEL), "w", 0o600));
|
|
189
|
+
const store = new FileNullifierStore(dir, { hosted: true });
|
|
190
|
+
const preimage = "hosted-preimage-001";
|
|
191
|
+
assert.equal(store.isConsumed(preimage), false);
|
|
192
|
+
store.consume(preimage);
|
|
193
|
+
assert.equal(store.isConsumed(preimage), true);
|
|
194
|
+
assert.throws(() => store.consume(preimage), NullifierReplayError);
|
|
195
|
+
}
|
|
196
|
+
finally {
|
|
197
|
+
rmSync(parent, { recursive: true, force: true });
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
test("hosted mode refuses a directory that is actually a symlink", () => {
|
|
201
|
+
const parent = freshDir();
|
|
202
|
+
const realDir = join(parent, "real");
|
|
203
|
+
const linkDir = join(parent, "link");
|
|
204
|
+
try {
|
|
205
|
+
mkdirSync(realDir, { mode: 0o700 });
|
|
206
|
+
closeSync(openSync(join(realDir, HOSTED_NULLIFIER_SENTINEL), "w", 0o600));
|
|
207
|
+
symlinkSync(realDir, linkDir);
|
|
208
|
+
const store = new FileNullifierStore(linkDir, { hosted: true });
|
|
209
|
+
assert.throws(() => store.consume("whatever"), /symbolic link/i);
|
|
210
|
+
assert.throws(() => store.isConsumed("whatever"), /symbolic link/i);
|
|
211
|
+
}
|
|
212
|
+
finally {
|
|
213
|
+
rmSync(parent, { recursive: true, force: true });
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
test("hosted mode refuses a sentinel that is a directory", () => {
|
|
217
|
+
const dir = freshDir();
|
|
218
|
+
try {
|
|
219
|
+
mkdirSync(join(dir, HOSTED_NULLIFIER_SENTINEL));
|
|
220
|
+
const store = new FileNullifierStore(dir, { hosted: true });
|
|
221
|
+
assert.throws(() => store.consume("whatever"), /not a regular file|is a directory/i);
|
|
222
|
+
}
|
|
223
|
+
finally {
|
|
224
|
+
rmSync(dir, { recursive: true, force: true });
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
test("hosted mode refuses a sentinel that is a symlink", () => {
|
|
228
|
+
const parent = freshDir();
|
|
229
|
+
const dir = join(parent, "provisioned");
|
|
230
|
+
try {
|
|
231
|
+
mkdirSync(dir, { mode: 0o700 });
|
|
232
|
+
const realSentinel = join(parent, "real-sentinel");
|
|
233
|
+
closeSync(openSync(realSentinel, "w", 0o600));
|
|
234
|
+
symlinkSync(realSentinel, join(dir, HOSTED_NULLIFIER_SENTINEL));
|
|
235
|
+
const store = new FileNullifierStore(dir, { hosted: true });
|
|
236
|
+
assert.throws(() => store.consume("whatever"), /not a regular file|symbolic link/i);
|
|
237
|
+
}
|
|
238
|
+
finally {
|
|
239
|
+
rmSync(parent, { recursive: true, force: true });
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
test("hosted mode: replay across two independently spawned processes is rejected", () => {
|
|
243
|
+
const dir = freshDir();
|
|
244
|
+
try {
|
|
245
|
+
closeSync(openSync(join(dir, HOSTED_NULLIFIER_SENTINEL), "w", 0o600));
|
|
246
|
+
const preimage = "hosted-cross-process-preimage-001";
|
|
247
|
+
const script = (p) => `
|
|
248
|
+
const { FileNullifierStore } = await import(${JSON.stringify(NULLIFIER_MODULE_URL)});
|
|
249
|
+
const store = new FileNullifierStore(${JSON.stringify(dir)}, { hosted: true });
|
|
250
|
+
try {
|
|
251
|
+
store.consume(${JSON.stringify(p)});
|
|
252
|
+
process.exit(0);
|
|
253
|
+
} catch (e) {
|
|
254
|
+
process.stderr.write(String(e && e.message));
|
|
255
|
+
process.exit(1);
|
|
256
|
+
}
|
|
257
|
+
`;
|
|
258
|
+
const first = spawnSync(process.execPath, ["--input-type=module", "-e", script(preimage)], {
|
|
259
|
+
encoding: "utf-8",
|
|
260
|
+
});
|
|
261
|
+
assert.equal(first.status, 0, `first redemption should succeed: ${first.stderr}`);
|
|
262
|
+
const second = spawnSync(process.execPath, ["--input-type=module", "-e", script(preimage)], {
|
|
263
|
+
encoding: "utf-8",
|
|
264
|
+
});
|
|
265
|
+
assert.equal(second.status, 1, "second redemption over the same directory must be rejected");
|
|
266
|
+
assert.match(second.stderr, /nullifier replay/);
|
|
267
|
+
}
|
|
268
|
+
finally {
|
|
269
|
+
rmSync(dir, { recursive: true, force: true });
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
test("replay across two independently spawned processes is rejected", () => {
|
|
273
|
+
const dir = freshDir();
|
|
274
|
+
try {
|
|
275
|
+
const preimage = "cross-process-preimage-001";
|
|
276
|
+
const first = consumeInChildProcess(dir, preimage);
|
|
277
|
+
assert.equal(first.status, 0, `first redemption should succeed: ${first.stderr}`);
|
|
278
|
+
const second = consumeInChildProcess(dir, preimage);
|
|
279
|
+
assert.equal(second.status, 1, "second redemption over the same directory must be rejected");
|
|
280
|
+
assert.match(second.stderr, /nullifier replay/);
|
|
281
|
+
}
|
|
282
|
+
finally {
|
|
283
|
+
rmSync(dir, { recursive: true, force: true });
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
test("replay is rejected after the first process has fully exited (restart)", () => {
|
|
287
|
+
const dir = freshDir();
|
|
288
|
+
try {
|
|
289
|
+
const preimage = "restart-preimage-001";
|
|
290
|
+
// spawnSync blocks until the child has fully terminated — there is no
|
|
291
|
+
// process holding this preimage in memory by the time this line
|
|
292
|
+
// returns, which is exactly the "server restarted" scenario.
|
|
293
|
+
const first = consumeInChildProcess(dir, preimage);
|
|
294
|
+
assert.equal(first.status, 0, `pre-restart redemption should succeed: ${first.stderr}`);
|
|
295
|
+
const second = consumeInChildProcess(dir, preimage);
|
|
296
|
+
assert.equal(second.status, 1, "redemption after restart must still be rejected as replay");
|
|
297
|
+
assert.match(second.stderr, /nullifier replay/);
|
|
298
|
+
}
|
|
299
|
+
finally {
|
|
300
|
+
rmSync(dir, { recursive: true, force: true });
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
test("concurrent redemption from several processes: exactly one succeeds", async () => {
|
|
304
|
+
const dir = freshDir();
|
|
305
|
+
try {
|
|
306
|
+
const preimage = "concurrent-preimage-001";
|
|
307
|
+
const N = 8;
|
|
308
|
+
const script = `
|
|
309
|
+
const { FileNullifierStore } = await import(${JSON.stringify(NULLIFIER_MODULE_URL)});
|
|
310
|
+
const store = new FileNullifierStore(${JSON.stringify(dir)});
|
|
311
|
+
try {
|
|
312
|
+
store.consume(${JSON.stringify(preimage)});
|
|
313
|
+
process.exit(0);
|
|
314
|
+
} catch (e) {
|
|
315
|
+
process.exit(1);
|
|
316
|
+
}
|
|
317
|
+
`;
|
|
318
|
+
const runs = Array.from({ length: N }, () => new Promise((resolve) => {
|
|
319
|
+
const child = spawn(process.execPath, ["--input-type=module", "-e", script]);
|
|
320
|
+
child.on("close", (code) => resolve(code));
|
|
321
|
+
}));
|
|
322
|
+
const codes = await Promise.all(runs);
|
|
323
|
+
const successes = codes.filter((c) => c === 0).length;
|
|
324
|
+
const rejections = codes.filter((c) => c === 1).length;
|
|
325
|
+
assert.equal(successes, 1, `expected exactly one winner, got exit codes: ${codes}`);
|
|
326
|
+
assert.equal(rejections, N - 1);
|
|
327
|
+
}
|
|
328
|
+
finally {
|
|
329
|
+
rmSync(dir, { recursive: true, force: true });
|
|
330
|
+
}
|
|
331
|
+
});
|
|
@@ -4,7 +4,7 @@ export { issueSinkChallenge, challengeHash } from "./sinkChallenge.js";
|
|
|
4
4
|
export { buildEvaluationRequest, deriveDelegationChainRoot, } from "./authorityEvaluation.js";
|
|
5
5
|
export { mintChallengeReceipt, challengeReceiptHash } from "./challengeReceipt.js";
|
|
6
6
|
export { signEffectReceipt } from "./effectReceipt.js";
|
|
7
|
-
export { InMemoryNullifierSet } from "./nullifierSet.js";
|
|
8
|
-
export type { NullifierStore } from "./nullifierSet.js";
|
|
7
|
+
export { InMemoryNullifierSet, FileNullifierStore, NullifierReplayError, HOSTED_NULLIFIER_SENTINEL, } from "./nullifierSet.js";
|
|
8
|
+
export type { NullifierStore, FileNullifierStoreOptions } from "./nullifierSet.js";
|
|
9
9
|
export { verifySinkChallenge, verifyAuthorityEvaluationRequest, verifyChallengeReceipt, verifyEffectReceipt, reconstructAttestationChain, } from "./verify.js";
|
|
10
10
|
export type { VerifyResult } from "./verify.js";
|
|
@@ -6,5 +6,5 @@ export { issueSinkChallenge, challengeHash } from "./sinkChallenge.js";
|
|
|
6
6
|
export { buildEvaluationRequest, deriveDelegationChainRoot, } from "./authorityEvaluation.js";
|
|
7
7
|
export { mintChallengeReceipt, challengeReceiptHash } from "./challengeReceipt.js";
|
|
8
8
|
export { signEffectReceipt } from "./effectReceipt.js";
|
|
9
|
-
export { InMemoryNullifierSet } from "./nullifierSet.js";
|
|
9
|
+
export { InMemoryNullifierSet, FileNullifierStore, NullifierReplayError, HOSTED_NULLIFIER_SENTINEL, } from "./nullifierSet.js";
|
|
10
10
|
export { verifySinkChallenge, verifyAuthorityEvaluationRequest, verifyChallengeReceipt, verifyEffectReceipt, reconstructAttestationChain, } from "./verify.js";
|
|
@@ -1,13 +1,72 @@
|
|
|
1
|
+
export declare const HOSTED_NULLIFIER_SENTINEL = ".aps-nullifier-store";
|
|
1
2
|
export interface NullifierStore {
|
|
2
3
|
isConsumed(preimage: string): boolean;
|
|
3
4
|
consume(preimage: string): void;
|
|
5
|
+
/**
|
|
6
|
+
* Best-effort undo of a consume() that is not going to produce a valid
|
|
7
|
+
* result (e.g. the signing step after it threw). Not part of the replay
|
|
8
|
+
* guarantee — only used to avoid permanently burning a token on a
|
|
9
|
+
* transient failure unrelated to redemption itself.
|
|
10
|
+
*/
|
|
11
|
+
release?(preimage: string): void;
|
|
4
12
|
size(): number;
|
|
5
13
|
clear(): void;
|
|
6
14
|
}
|
|
15
|
+
export declare class NullifierReplayError extends Error {
|
|
16
|
+
constructor(preimage: string);
|
|
17
|
+
}
|
|
7
18
|
export declare class InMemoryNullifierSet implements NullifierStore {
|
|
8
19
|
private readonly seen;
|
|
9
20
|
isConsumed(preimage: string): boolean;
|
|
10
21
|
consume(preimage: string): void;
|
|
22
|
+
release(preimage: string): void;
|
|
23
|
+
size(): number;
|
|
24
|
+
clear(): void;
|
|
25
|
+
}
|
|
26
|
+
export interface FileNullifierStoreOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Hosted mode: MCP_REMOTE === '1' on the hosted bridge. The store never
|
|
29
|
+
* creates `dir` — it must already exist as a real directory (not a
|
|
30
|
+
* symlink) and contain the HOSTED_NULLIFIER_SENTINEL file, itself a
|
|
31
|
+
* regular file (not a symlink, directory, or fifo), written when the
|
|
32
|
+
* directory was provisioned. This refuses a directory that was not
|
|
33
|
+
* provisioned as expected. The sentinel shows that provisioning
|
|
34
|
+
* happened; it does not by itself prove the path is backed by a
|
|
35
|
+
* persistent volume — that is confirmed operationally, by restarting the
|
|
36
|
+
* deployed service and checking that a consumed token is still rejected.
|
|
37
|
+
* Local stdio mode does not set this.
|
|
38
|
+
*/
|
|
39
|
+
hosted?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Durable, cross-process nullifier store. One file per consumed preimage,
|
|
43
|
+
* named by its SHA-256 hex digest, under `dir`. Consuming is a single
|
|
44
|
+
* `open(path, 'wx')` call: it either creates the file (first consumption)
|
|
45
|
+
* or fails with EEXIST (replay), with no separate check-then-act window
|
|
46
|
+
* for concurrent processes to race through.
|
|
47
|
+
*
|
|
48
|
+
* If `dir` cannot be used, construction does not throw (so an unrelated
|
|
49
|
+
* server with 150+ other tools does not fail to start over one
|
|
50
|
+
* misconfigured directory); instead every operation on this store throws,
|
|
51
|
+
* so the one redemption path that depends on it fails closed with a clear
|
|
52
|
+
* error naming which check failed.
|
|
53
|
+
*/
|
|
54
|
+
export declare class FileNullifierStore implements NullifierStore {
|
|
55
|
+
private readonly dir;
|
|
56
|
+
private readonly initError;
|
|
57
|
+
constructor(dir: string | undefined, options?: FileNullifierStoreOptions);
|
|
58
|
+
private static readonly DIR_MODE;
|
|
59
|
+
private static readonly MARKER_MODE;
|
|
60
|
+
private static checkDirPermissions;
|
|
61
|
+
private static tryInitLocal;
|
|
62
|
+
private static tryInitHosted;
|
|
63
|
+
private ensureReady;
|
|
64
|
+
private pathFor;
|
|
65
|
+
private fsyncDir;
|
|
66
|
+
isConsumed(preimage: string): boolean;
|
|
67
|
+
consume(preimage: string): void;
|
|
68
|
+
release(preimage: string): void;
|
|
11
69
|
size(): number;
|
|
12
70
|
clear(): void;
|
|
71
|
+
private listMarkers;
|
|
13
72
|
}
|
|
@@ -1,5 +1,45 @@
|
|
|
1
|
-
//
|
|
2
|
-
// sink consults
|
|
1
|
+
// Nullifier stores for the v0.1 capability-token reference implementation.
|
|
2
|
+
// The sink consults one of these on every M3 redemption to prevent token
|
|
3
|
+
// replay: a preimage may be consumed exactly once.
|
|
4
|
+
//
|
|
5
|
+
// InMemoryNullifierSet is process-local and does not survive a restart or
|
|
6
|
+
// span multiple processes. It exists for tests and as a building block; it
|
|
7
|
+
// must never be the silent default for a real redemption path, because the
|
|
8
|
+
// hosted bridge spawns a fresh subprocess per session and every process
|
|
9
|
+
// would start with an empty set.
|
|
10
|
+
//
|
|
11
|
+
// FileNullifierStore is durable and safe across concurrent processes: it
|
|
12
|
+
// consumes a token via an exclusive file create (`wx`), which is atomic at
|
|
13
|
+
// the filesystem level, so two processes racing to consume the same
|
|
14
|
+
// preimage can never both succeed. Only the preimage's SHA-256 hash is
|
|
15
|
+
// ever written to disk. The directory is created 0700 and markers 0600 —
|
|
16
|
+
// this state is security-sensitive (each marker names a consumed token's
|
|
17
|
+
// hash) and must not be readable or writable by other local users.
|
|
18
|
+
//
|
|
19
|
+
// In hosted mode (MCP_REMOTE === '1') the store never creates its
|
|
20
|
+
// directory and requires it to already exist — as a real directory, not a
|
|
21
|
+
// symlink — with a provisioning sentinel file (HOSTED_NULLIFIER_SENTINEL)
|
|
22
|
+
// that is itself a regular file, not a symlink, directory, or fifo. This
|
|
23
|
+
// refuses a directory that was not provisioned as expected. The sentinel
|
|
24
|
+
// shows that provisioning happened; it does not by itself prove the path
|
|
25
|
+
// is backed by a persistent volume — that is confirmed operationally, by
|
|
26
|
+
// restarting the deployed service and checking that a consumed token is
|
|
27
|
+
// still rejected.
|
|
28
|
+
import { closeSync, existsSync, fsyncSync, lstatSync, mkdirSync, openSync, readdirSync, statSync, unlinkSync, writeSync, } from "node:fs";
|
|
29
|
+
import { join } from "node:path";
|
|
30
|
+
import { sha256Hex } from "./canonical.js";
|
|
31
|
+
// Provisioning sentinel required in hosted mode (see FileNullifierStore
|
|
32
|
+
// below). Written by whatever process provisions the directory, never by
|
|
33
|
+
// this store itself. Its presence shows provisioning happened; it is not
|
|
34
|
+
// proof the directory is backed by a persistent volume (see hosted-mode
|
|
35
|
+
// note above).
|
|
36
|
+
export const HOSTED_NULLIFIER_SENTINEL = ".aps-nullifier-store";
|
|
37
|
+
export class NullifierReplayError extends Error {
|
|
38
|
+
constructor(preimage) {
|
|
39
|
+
super(`nullifier replay: token preimage ${preimage.slice(0, 12)}... already consumed`);
|
|
40
|
+
this.name = "NullifierReplayError";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
3
43
|
export class InMemoryNullifierSet {
|
|
4
44
|
seen = new Set();
|
|
5
45
|
isConsumed(preimage) {
|
|
@@ -7,10 +47,13 @@ export class InMemoryNullifierSet {
|
|
|
7
47
|
}
|
|
8
48
|
consume(preimage) {
|
|
9
49
|
if (this.seen.has(preimage)) {
|
|
10
|
-
throw new
|
|
50
|
+
throw new NullifierReplayError(preimage);
|
|
11
51
|
}
|
|
12
52
|
this.seen.add(preimage);
|
|
13
53
|
}
|
|
54
|
+
release(preimage) {
|
|
55
|
+
this.seen.delete(preimage);
|
|
56
|
+
}
|
|
14
57
|
size() {
|
|
15
58
|
return this.seen.size;
|
|
16
59
|
}
|
|
@@ -18,3 +61,195 @@ export class InMemoryNullifierSet {
|
|
|
18
61
|
this.seen.clear();
|
|
19
62
|
}
|
|
20
63
|
}
|
|
64
|
+
const NULLIFIER_FILENAME = /^[0-9a-f]{64}$/;
|
|
65
|
+
/**
|
|
66
|
+
* Durable, cross-process nullifier store. One file per consumed preimage,
|
|
67
|
+
* named by its SHA-256 hex digest, under `dir`. Consuming is a single
|
|
68
|
+
* `open(path, 'wx')` call: it either creates the file (first consumption)
|
|
69
|
+
* or fails with EEXIST (replay), with no separate check-then-act window
|
|
70
|
+
* for concurrent processes to race through.
|
|
71
|
+
*
|
|
72
|
+
* If `dir` cannot be used, construction does not throw (so an unrelated
|
|
73
|
+
* server with 150+ other tools does not fail to start over one
|
|
74
|
+
* misconfigured directory); instead every operation on this store throws,
|
|
75
|
+
* so the one redemption path that depends on it fails closed with a clear
|
|
76
|
+
* error naming which check failed.
|
|
77
|
+
*/
|
|
78
|
+
export class FileNullifierStore {
|
|
79
|
+
dir;
|
|
80
|
+
initError;
|
|
81
|
+
constructor(dir, options = {}) {
|
|
82
|
+
this.dir = dir;
|
|
83
|
+
this.initError = options.hosted
|
|
84
|
+
? FileNullifierStore.tryInitHosted(dir)
|
|
85
|
+
: FileNullifierStore.tryInitLocal(dir);
|
|
86
|
+
}
|
|
87
|
+
// Directory and marker files are owner-only (0700 / 0600): a nullifier
|
|
88
|
+
// marker's existence is itself sensitive (it names a consumed capability
|
|
89
|
+
// token preimage's hash), and a group/world-writable directory would let
|
|
90
|
+
// another local user delete markers to reopen replay.
|
|
91
|
+
static DIR_MODE = 0o700;
|
|
92
|
+
static MARKER_MODE = 0o600;
|
|
93
|
+
static checkDirPermissions(dir, stat) {
|
|
94
|
+
const groupOrWorldWritable = (stat.mode & 0o022) !== 0;
|
|
95
|
+
if (groupOrWorldWritable) {
|
|
96
|
+
return new Error(`nullifier store: directory "${dir}" is group- or world-writable (mode ${(stat.mode & 0o777).toString(8)}). ` +
|
|
97
|
+
`Refusing to use it: anyone else with access could delete replay markers and reopen replay. ` +
|
|
98
|
+
`chmod it to 0700 (owner read/write/execute only) and retry.`);
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
static tryInitLocal(dir) {
|
|
103
|
+
if (!dir) {
|
|
104
|
+
return new Error(`nullifier store: no directory configured.`);
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
mkdirSync(dir, { recursive: true, mode: FileNullifierStore.DIR_MODE });
|
|
108
|
+
// mkdirSync is a silent no-op if dir already exists, even if its mode
|
|
109
|
+
// is looser than DIR_MODE (e.g. created before this hardening, or
|
|
110
|
+
// changed since), so check the actual mode explicitly rather than
|
|
111
|
+
// trusting mkdirSync alone.
|
|
112
|
+
const stat = statSync(dir);
|
|
113
|
+
const permError = FileNullifierStore.checkDirPermissions(dir, stat);
|
|
114
|
+
if (permError)
|
|
115
|
+
return permError;
|
|
116
|
+
// Also probe writability explicitly: an owner-only-but-read-only
|
|
117
|
+
// directory (e.g. 0500) passes the permission check above but still
|
|
118
|
+
// can't hold markers.
|
|
119
|
+
const probe = join(dir, `.write-probe-${process.pid}-${Date.now()}`);
|
|
120
|
+
closeSync(openSync(probe, "w", FileNullifierStore.MARKER_MODE));
|
|
121
|
+
unlinkSync(probe);
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
catch (e) {
|
|
125
|
+
return new Error(`nullifier store: directory "${dir}" is not usable (${e.message}). ` +
|
|
126
|
+
`Set APS_NULLIFIER_DIR to a writable directory. Redemption fails closed rather than falling back to an in-memory store.`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
static tryInitHosted(dir) {
|
|
130
|
+
if (!dir) {
|
|
131
|
+
return new Error(`nullifier store (hosted mode): APS_NULLIFIER_DIR must be set explicitly when MCP_REMOTE=1. ` +
|
|
132
|
+
`Point it at a directory that has been provisioned as expected — hosted mode never picks a default ` +
|
|
133
|
+
`and never creates the directory.`);
|
|
134
|
+
}
|
|
135
|
+
// lstatSync (not statSync/existsSync) so a symlinked directory is
|
|
136
|
+
// caught rather than silently followed.
|
|
137
|
+
let dirStat;
|
|
138
|
+
try {
|
|
139
|
+
dirStat = lstatSync(dir);
|
|
140
|
+
}
|
|
141
|
+
catch (e) {
|
|
142
|
+
return new Error(`nullifier store (hosted mode): directory "${dir}" does not exist (${e.message}). ` +
|
|
143
|
+
`Hosted mode never creates it — provision the directory (mode 0700) before starting the server, and ` +
|
|
144
|
+
`write the "${HOSTED_NULLIFIER_SENTINEL}" sentinel into it.`);
|
|
145
|
+
}
|
|
146
|
+
if (dirStat.isSymbolicLink()) {
|
|
147
|
+
return new Error(`nullifier store (hosted mode): "${dir}" is a symbolic link, not a real directory. Refusing to use it — ` +
|
|
148
|
+
`APS_NULLIFIER_DIR must point at the provisioned directory itself, not a link to it.`);
|
|
149
|
+
}
|
|
150
|
+
if (!dirStat.isDirectory()) {
|
|
151
|
+
return new Error(`nullifier store (hosted mode): "${dir}" exists but is not a directory.`);
|
|
152
|
+
}
|
|
153
|
+
const permError = FileNullifierStore.checkDirPermissions(dir, dirStat);
|
|
154
|
+
if (permError)
|
|
155
|
+
return permError;
|
|
156
|
+
const sentinelPath = join(dir, HOSTED_NULLIFIER_SENTINEL);
|
|
157
|
+
let sentinelStat;
|
|
158
|
+
try {
|
|
159
|
+
sentinelStat = lstatSync(sentinelPath);
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
return new Error(`nullifier store (hosted mode): directory "${dir}" is missing the provisioning sentinel ` +
|
|
163
|
+
`"${HOSTED_NULLIFIER_SENTINEL}". This means the directory was not provisioned as expected — refusing ` +
|
|
164
|
+
`to use it as the nullifier store. Persistence itself is confirmed operationally: after deploy, ` +
|
|
165
|
+
`consume a token, restart the service, and confirm the same token is still rejected.`);
|
|
166
|
+
}
|
|
167
|
+
if (!sentinelStat.isFile()) {
|
|
168
|
+
const kind = sentinelStat.isDirectory() ? "a directory" : sentinelStat.isSymbolicLink() ? "a symbolic link" : "not a regular file";
|
|
169
|
+
return new Error(`nullifier store (hosted mode): the provisioning sentinel "${HOSTED_NULLIFIER_SENTINEL}" in "${dir}" is ` +
|
|
170
|
+
`${kind}, not a regular file. Refusing to use it as the nullifier store — recreate it as an empty ` +
|
|
171
|
+
`regular file (mode 0600).`);
|
|
172
|
+
}
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
ensureReady() {
|
|
176
|
+
if (this.initError)
|
|
177
|
+
throw this.initError;
|
|
178
|
+
}
|
|
179
|
+
pathFor(preimage) {
|
|
180
|
+
// this.dir is defined whenever initError is null (both tryInitLocal and
|
|
181
|
+
// tryInitHosted fail closed on an undefined dir), and ensureReady() is
|
|
182
|
+
// called by every caller of pathFor() before it is reached.
|
|
183
|
+
return join(this.dir, sha256Hex(preimage));
|
|
184
|
+
}
|
|
185
|
+
fsyncDir() {
|
|
186
|
+
try {
|
|
187
|
+
const dfd = openSync(this.dir, "r");
|
|
188
|
+
try {
|
|
189
|
+
fsyncSync(dfd);
|
|
190
|
+
}
|
|
191
|
+
finally {
|
|
192
|
+
closeSync(dfd);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
196
|
+
// Directory fsync isn't available on every platform. Best-effort only:
|
|
197
|
+
// the per-file fsync in consume() is what actually matters for
|
|
198
|
+
// durability of the marker itself.
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
isConsumed(preimage) {
|
|
202
|
+
this.ensureReady();
|
|
203
|
+
return existsSync(this.pathFor(preimage));
|
|
204
|
+
}
|
|
205
|
+
consume(preimage) {
|
|
206
|
+
this.ensureReady();
|
|
207
|
+
const path = this.pathFor(preimage);
|
|
208
|
+
let fd;
|
|
209
|
+
try {
|
|
210
|
+
// Markers are never pruned by this store, and none should be added
|
|
211
|
+
// without care: a marker deleted before a token's signed `expires_at`
|
|
212
|
+
// has passed reopens replay for that token. Any future pruning must
|
|
213
|
+
// keep every marker at least as long as the maximum validity window
|
|
214
|
+
// of a capability token.
|
|
215
|
+
fd = openSync(path, "wx", FileNullifierStore.MARKER_MODE);
|
|
216
|
+
}
|
|
217
|
+
catch (e) {
|
|
218
|
+
const err = e;
|
|
219
|
+
if (err.code === "EEXIST") {
|
|
220
|
+
throw new NullifierReplayError(preimage);
|
|
221
|
+
}
|
|
222
|
+
throw new Error(`nullifier store: cannot consume token: ${err.message}`);
|
|
223
|
+
}
|
|
224
|
+
try {
|
|
225
|
+
// Only a timestamp is written — never the preimage itself.
|
|
226
|
+
writeSync(fd, new Date().toISOString());
|
|
227
|
+
fsyncSync(fd);
|
|
228
|
+
}
|
|
229
|
+
finally {
|
|
230
|
+
closeSync(fd);
|
|
231
|
+
}
|
|
232
|
+
this.fsyncDir();
|
|
233
|
+
}
|
|
234
|
+
release(preimage) {
|
|
235
|
+
try {
|
|
236
|
+
unlinkSync(this.pathFor(preimage));
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
// Already gone, or never existed — nothing to roll back.
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
size() {
|
|
243
|
+
this.ensureReady();
|
|
244
|
+
return this.listMarkers().length;
|
|
245
|
+
}
|
|
246
|
+
clear() {
|
|
247
|
+
this.ensureReady();
|
|
248
|
+
for (const name of this.listMarkers()) {
|
|
249
|
+
unlinkSync(join(this.dir, name));
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
listMarkers() {
|
|
253
|
+
return readdirSync(this.dir).filter((name) => NULLIFIER_FILENAME.test(name));
|
|
254
|
+
}
|
|
255
|
+
}
|
package/build/index.js
CHANGED
|
@@ -73,9 +73,31 @@ import { toolCount } from "./toolManifest.js";
|
|
|
73
73
|
// Capability Token v0.1 (reference implementation)
|
|
74
74
|
// Spec: agent-passport-system/docs/CAPABILITY-TOKEN-SPEC-DRAFT.md
|
|
75
75
|
// ═══════════════════════════════════════
|
|
76
|
-
import { issueSinkChallenge as issueCapabilitySinkChallenge, buildEvaluationRequest as buildCapabilityEvaluationRequest, mintChallengeReceipt as mintCapabilityChallengeReceipt, signEffectReceipt as signCapabilityEffectReceipt,
|
|
77
|
-
//
|
|
78
|
-
|
|
76
|
+
import { issueSinkChallenge as issueCapabilitySinkChallenge, buildEvaluationRequest as buildCapabilityEvaluationRequest, mintChallengeReceipt as mintCapabilityChallengeReceipt, signEffectReceipt as signCapabilityEffectReceipt, FileNullifierStore, NullifierReplayError, verifyChallengeReceipt as verifyCapabilityChallengeReceipt, challengeHash as capabilityChallengeHash, } from "./capabilityToken/index.js";
|
|
77
|
+
// Durable, cross-process nullifier store for capability-token redemption
|
|
78
|
+
// (aps_capability_sign_effect). The hosted bridge spawns a fresh subprocess
|
|
79
|
+
// per session, so an in-memory set would let a consumed token be redeemed
|
|
80
|
+
// again in another process or after a restart. Never fall back to an
|
|
81
|
+
// in-memory store here if the directory is unusable — let FileNullifierStore
|
|
82
|
+
// fail closed on redemption instead.
|
|
83
|
+
//
|
|
84
|
+
// MCP_REMOTE === '1' is set by the hosted bridge on every subprocess it
|
|
85
|
+
// spawns (spawnMCPProcess in agent-passport-remote-mcp/src/remote.ts). In
|
|
86
|
+
// that mode APS_NULLIFIER_DIR must be set explicitly to a directory that was
|
|
87
|
+
// provisioned as expected (see FileNullifierStore's hosted-mode checks) —
|
|
88
|
+
// no default, and the store never creates it. The provisioning sentinel
|
|
89
|
+
// those checks require shows that provisioning happened; it does not by
|
|
90
|
+
// itself prove the path is backed by a persistent volume. That is confirmed
|
|
91
|
+
// operationally, by restarting the deployed service and checking that a
|
|
92
|
+
// consumed token is still rejected. Local stdio mode keeps the previous
|
|
93
|
+
// behavior: a default directory under the server's existing state
|
|
94
|
+
// directory, created on demand.
|
|
95
|
+
const isHostedNullifierMode = process.env.MCP_REMOTE === "1";
|
|
96
|
+
const APS_NULLIFIER_DIR = process.env.APS_NULLIFIER_DIR ||
|
|
97
|
+
(isHostedNullifierMode ? undefined : join(process.env.HOME || ".", ".agent-passport-nullifiers"));
|
|
98
|
+
const capabilityNullifierSet = new FileNullifierStore(APS_NULLIFIER_DIR, {
|
|
99
|
+
hosted: isHostedNullifierMode,
|
|
100
|
+
});
|
|
79
101
|
// ═══════════════════════════════════════
|
|
80
102
|
// State Management
|
|
81
103
|
// ═══════════════════════════════════════
|
|
@@ -4732,23 +4754,37 @@ server.registerTool("aps_capability_sign_effect", { description: "v0.1 capabilit
|
|
|
4732
4754
|
};
|
|
4733
4755
|
}
|
|
4734
4756
|
const preimage = receipt.authority_token_preimage;
|
|
4735
|
-
//
|
|
4736
|
-
//
|
|
4737
|
-
//
|
|
4738
|
-
//
|
|
4739
|
-
//
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4757
|
+
// Consume is the single atomic replay gate: with a durable, cross-process
|
|
4758
|
+
// store, two concurrent redemptions can both pass an isConsumed() peek
|
|
4759
|
+
// before either consumes, so the peek-then-sign-then-consume order this
|
|
4760
|
+
// used to run in is not safe across processes. Consuming first means at
|
|
4761
|
+
// most one caller ever gets past this point for a given preimage. If
|
|
4762
|
+
// signing then fails, release() best-effort un-burns the token rather than
|
|
4763
|
+
// permanently losing it to a transient failure.
|
|
4764
|
+
try {
|
|
4765
|
+
capabilityNullifierSet.consume(preimage);
|
|
4766
|
+
}
|
|
4767
|
+
catch (e) {
|
|
4768
|
+
if (e instanceof NullifierReplayError) {
|
|
4769
|
+
return {
|
|
4770
|
+
content: [{ type: "text", text: JSON.stringify({ error: "nullifier replay: token preimage already consumed" }) }],
|
|
4771
|
+
isError: true,
|
|
4772
|
+
};
|
|
4773
|
+
}
|
|
4774
|
+
throw e;
|
|
4775
|
+
}
|
|
4776
|
+
let effectReceipt;
|
|
4777
|
+
try {
|
|
4778
|
+
effectReceipt = signCapabilityEffectReceipt({
|
|
4779
|
+
challenge_receipt: receipt,
|
|
4780
|
+
effect: args.effect,
|
|
4781
|
+
sink_key: sinkKey,
|
|
4782
|
+
});
|
|
4783
|
+
}
|
|
4784
|
+
catch (e) {
|
|
4785
|
+
capabilityNullifierSet.release?.(preimage);
|
|
4786
|
+
throw e;
|
|
4745
4787
|
}
|
|
4746
|
-
const effectReceipt = signCapabilityEffectReceipt({
|
|
4747
|
-
challenge_receipt: receipt,
|
|
4748
|
-
effect: args.effect,
|
|
4749
|
-
sink_key: sinkKey,
|
|
4750
|
-
});
|
|
4751
|
-
capabilityNullifierSet.consume(preimage);
|
|
4752
4788
|
return {
|
|
4753
4789
|
content: [{
|
|
4754
4790
|
type: "text",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-passport-system-mcp",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"mcpName": "io.github.aeoess/agent-passport-mcp",
|
|
5
5
|
"description": "MCP server for the Agent Passport System, protocol-layer tools only. Identity, delegation, reputation, attestation, coordination, commerce, charter amendment lifecycle, attribution. Counts and the SDK version it tracks live in the README.",
|
|
6
6
|
"type": "module",
|