protect-mcp 0.7.4 → 0.7.6
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/{chunk-NVJHGXXG.mjs → chunk-6E2DHBAR.mjs} +12 -5
- package/dist/{chunk-36UID5WY.mjs → chunk-JCMDLN5I.mjs} +399 -8
- package/dist/{chunk-LYKNULYU.mjs → chunk-LJQOALYR.mjs} +152 -0
- package/dist/{chunk-KPSICBAJ.mjs → chunk-SETXVE2K.mjs} +2 -2
- package/dist/{chunk-UBZJ3VI2.mjs → chunk-VTPZ4G5I.mjs} +1 -1
- package/dist/{chunk-D2RDY2JR.mjs → chunk-WIPWNWMJ.mjs} +1 -1
- package/dist/{chunk-F2FKQ4XN.mjs → chunk-WV4DKYE4.mjs} +78 -2
- package/dist/cli.js +649 -44
- package/dist/cli.mjs +247 -39
- package/dist/demo-server.js +2 -2
- package/dist/demo-server.mjs +1 -1
- package/dist/{ed25519-DZMMNNVE.mjs → ed25519-BSHMMVNX.mjs} +1 -1
- package/dist/hook-server.js +11 -4
- package/dist/hook-server.mjs +2 -2
- package/dist/{http-transport-4GMMRPW7.mjs → http-transport-JBORN27G.mjs} +3 -3
- package/dist/index.d.mts +46 -12
- package/dist/index.d.ts +46 -12
- package/dist/index.js +1747 -37
- package/dist/index.mjs +1182 -34
- package/dist/{signing-committed-MMLJ6OGG.mjs → signing-committed-QXCW24RF.mjs} +2 -2
- package/package.json +2 -2
- package/policies/agent.cedar +50 -0
|
@@ -136,6 +136,24 @@ var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
|
136
136
|
528734635,
|
|
137
137
|
1541459225
|
|
138
138
|
]);
|
|
139
|
+
var SHA384_IV = /* @__PURE__ */ Uint32Array.from([
|
|
140
|
+
3418070365,
|
|
141
|
+
3238371032,
|
|
142
|
+
1654270250,
|
|
143
|
+
914150663,
|
|
144
|
+
2438529370,
|
|
145
|
+
812702999,
|
|
146
|
+
355462360,
|
|
147
|
+
4144912697,
|
|
148
|
+
1731405415,
|
|
149
|
+
4290775857,
|
|
150
|
+
2394180231,
|
|
151
|
+
1750603025,
|
|
152
|
+
3675008525,
|
|
153
|
+
1694076839,
|
|
154
|
+
1203062813,
|
|
155
|
+
3204075428
|
|
156
|
+
]);
|
|
139
157
|
var SHA512_IV = /* @__PURE__ */ Uint32Array.from([
|
|
140
158
|
1779033703,
|
|
141
159
|
4089235720,
|
|
@@ -525,8 +543,30 @@ var SHA512 = class extends HashMD {
|
|
|
525
543
|
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
526
544
|
}
|
|
527
545
|
};
|
|
546
|
+
var SHA384 = class extends SHA512 {
|
|
547
|
+
constructor() {
|
|
548
|
+
super(48);
|
|
549
|
+
this.Ah = SHA384_IV[0] | 0;
|
|
550
|
+
this.Al = SHA384_IV[1] | 0;
|
|
551
|
+
this.Bh = SHA384_IV[2] | 0;
|
|
552
|
+
this.Bl = SHA384_IV[3] | 0;
|
|
553
|
+
this.Ch = SHA384_IV[4] | 0;
|
|
554
|
+
this.Cl = SHA384_IV[5] | 0;
|
|
555
|
+
this.Dh = SHA384_IV[6] | 0;
|
|
556
|
+
this.Dl = SHA384_IV[7] | 0;
|
|
557
|
+
this.Eh = SHA384_IV[8] | 0;
|
|
558
|
+
this.El = SHA384_IV[9] | 0;
|
|
559
|
+
this.Fh = SHA384_IV[10] | 0;
|
|
560
|
+
this.Fl = SHA384_IV[11] | 0;
|
|
561
|
+
this.Gh = SHA384_IV[12] | 0;
|
|
562
|
+
this.Gl = SHA384_IV[13] | 0;
|
|
563
|
+
this.Hh = SHA384_IV[14] | 0;
|
|
564
|
+
this.Hl = SHA384_IV[15] | 0;
|
|
565
|
+
}
|
|
566
|
+
};
|
|
528
567
|
var sha256 = /* @__PURE__ */ createHasher(() => new SHA256());
|
|
529
568
|
var sha512 = /* @__PURE__ */ createHasher(() => new SHA512());
|
|
569
|
+
var sha384 = /* @__PURE__ */ createHasher(() => new SHA384());
|
|
530
570
|
|
|
531
571
|
// node_modules/@noble/curves/esm/utils.js
|
|
532
572
|
var _0n = /* @__PURE__ */ BigInt(0);
|
|
@@ -550,6 +590,10 @@ function _abytes2(value, length, title = "") {
|
|
|
550
590
|
}
|
|
551
591
|
return value;
|
|
552
592
|
}
|
|
593
|
+
function numberToHexUnpadded(num) {
|
|
594
|
+
const hex = num.toString(16);
|
|
595
|
+
return hex.length & 1 ? "0" + hex : hex;
|
|
596
|
+
}
|
|
553
597
|
function hexToNumber(hex) {
|
|
554
598
|
if (typeof hex !== "string")
|
|
555
599
|
throw new Error("hex string expected, got " + typeof hex);
|
|
@@ -612,6 +656,56 @@ function bitLen(n) {
|
|
|
612
656
|
return len;
|
|
613
657
|
}
|
|
614
658
|
var bitMask = (n) => (_1n << BigInt(n)) - _1n;
|
|
659
|
+
function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
660
|
+
if (typeof hashLen !== "number" || hashLen < 2)
|
|
661
|
+
throw new Error("hashLen must be a number");
|
|
662
|
+
if (typeof qByteLen !== "number" || qByteLen < 2)
|
|
663
|
+
throw new Error("qByteLen must be a number");
|
|
664
|
+
if (typeof hmacFn !== "function")
|
|
665
|
+
throw new Error("hmacFn must be a function");
|
|
666
|
+
const u8n = (len) => new Uint8Array(len);
|
|
667
|
+
const u8of = (byte) => Uint8Array.of(byte);
|
|
668
|
+
let v = u8n(hashLen);
|
|
669
|
+
let k = u8n(hashLen);
|
|
670
|
+
let i = 0;
|
|
671
|
+
const reset = () => {
|
|
672
|
+
v.fill(1);
|
|
673
|
+
k.fill(0);
|
|
674
|
+
i = 0;
|
|
675
|
+
};
|
|
676
|
+
const h = (...b) => hmacFn(k, v, ...b);
|
|
677
|
+
const reseed = (seed = u8n(0)) => {
|
|
678
|
+
k = h(u8of(0), seed);
|
|
679
|
+
v = h();
|
|
680
|
+
if (seed.length === 0)
|
|
681
|
+
return;
|
|
682
|
+
k = h(u8of(1), seed);
|
|
683
|
+
v = h();
|
|
684
|
+
};
|
|
685
|
+
const gen = () => {
|
|
686
|
+
if (i++ >= 1e3)
|
|
687
|
+
throw new Error("drbg: tried 1000 values");
|
|
688
|
+
let len = 0;
|
|
689
|
+
const out = [];
|
|
690
|
+
while (len < qByteLen) {
|
|
691
|
+
v = h();
|
|
692
|
+
const sl = v.slice();
|
|
693
|
+
out.push(sl);
|
|
694
|
+
len += v.length;
|
|
695
|
+
}
|
|
696
|
+
return concatBytes(...out);
|
|
697
|
+
};
|
|
698
|
+
const genUntil = (seed, pred) => {
|
|
699
|
+
reset();
|
|
700
|
+
reseed(seed);
|
|
701
|
+
let res = void 0;
|
|
702
|
+
while (!(res = pred(gen())))
|
|
703
|
+
reseed();
|
|
704
|
+
reset();
|
|
705
|
+
return res;
|
|
706
|
+
};
|
|
707
|
+
return genUntil;
|
|
708
|
+
}
|
|
615
709
|
function isHash(val) {
|
|
616
710
|
return typeof val === "function" && Number.isSafeInteger(val.outputLen);
|
|
617
711
|
}
|
|
@@ -975,6 +1069,26 @@ function FpSqrtEven(Fp2, elm) {
|
|
|
975
1069
|
const root = Fp2.sqrt(elm);
|
|
976
1070
|
return Fp2.isOdd(root) ? Fp2.neg(root) : root;
|
|
977
1071
|
}
|
|
1072
|
+
function getFieldBytesLength(fieldOrder) {
|
|
1073
|
+
if (typeof fieldOrder !== "bigint")
|
|
1074
|
+
throw new Error("field order must be bigint");
|
|
1075
|
+
const bitLength = fieldOrder.toString(2).length;
|
|
1076
|
+
return Math.ceil(bitLength / 8);
|
|
1077
|
+
}
|
|
1078
|
+
function getMinHashLength(fieldOrder) {
|
|
1079
|
+
const length = getFieldBytesLength(fieldOrder);
|
|
1080
|
+
return length + Math.ceil(length / 2);
|
|
1081
|
+
}
|
|
1082
|
+
function mapHashToField(key, fieldOrder, isLE = false) {
|
|
1083
|
+
const len = key.length;
|
|
1084
|
+
const fieldLen = getFieldBytesLength(fieldOrder);
|
|
1085
|
+
const minLen = getMinHashLength(fieldOrder);
|
|
1086
|
+
if (len < 16 || len < minLen || len > 1024)
|
|
1087
|
+
throw new Error("expected " + minLen + "-1024 bytes of input, got " + len);
|
|
1088
|
+
const num = isLE ? bytesToNumberLE(key) : bytesToNumberBE(key);
|
|
1089
|
+
const reduced = mod(num, fieldOrder - _1n2) + _1n2;
|
|
1090
|
+
return isLE ? numberToBytesLE(reduced, fieldLen) : numberToBytesBE(reduced, fieldLen);
|
|
1091
|
+
}
|
|
978
1092
|
|
|
979
1093
|
// node_modules/@noble/curves/esm/abstract/curve.js
|
|
980
1094
|
var _0n3 = BigInt(0);
|
|
@@ -1168,6 +1282,21 @@ var wNAF = class {
|
|
|
1168
1282
|
return getW(elm) !== 1;
|
|
1169
1283
|
}
|
|
1170
1284
|
};
|
|
1285
|
+
function mulEndoUnsafe(Point, point, k1, k2) {
|
|
1286
|
+
let acc = point;
|
|
1287
|
+
let p1 = Point.ZERO;
|
|
1288
|
+
let p2 = Point.ZERO;
|
|
1289
|
+
while (k1 > _0n3 || k2 > _0n3) {
|
|
1290
|
+
if (k1 & _1n3)
|
|
1291
|
+
p1 = p1.add(acc);
|
|
1292
|
+
if (k2 & _1n3)
|
|
1293
|
+
p2 = p2.add(acc);
|
|
1294
|
+
acc = acc.double();
|
|
1295
|
+
k1 >>= _1n3;
|
|
1296
|
+
k2 >>= _1n3;
|
|
1297
|
+
}
|
|
1298
|
+
return { p1, p2 };
|
|
1299
|
+
}
|
|
1171
1300
|
function pippenger(c, fieldN, points, scalars) {
|
|
1172
1301
|
validateMSMPoints(points, c);
|
|
1173
1302
|
validateMSMScalars(scalars, fieldN);
|
|
@@ -2417,6 +2546,29 @@ var hash_to_ristretto255 = /* @__PURE__ */ (() => ristretto255_hasher.hashToCurv
|
|
|
2417
2546
|
|
|
2418
2547
|
export {
|
|
2419
2548
|
sha256,
|
|
2549
|
+
sha512,
|
|
2550
|
+
sha384,
|
|
2551
|
+
_abool2,
|
|
2552
|
+
_abytes2,
|
|
2553
|
+
numberToHexUnpadded,
|
|
2554
|
+
bytesToNumberBE,
|
|
2555
|
+
ensureBytes,
|
|
2556
|
+
aInRange,
|
|
2557
|
+
bitLen,
|
|
2558
|
+
bitMask,
|
|
2559
|
+
createHmacDrbg,
|
|
2560
|
+
_validateObject,
|
|
2561
|
+
memoized,
|
|
2562
|
+
nLength,
|
|
2563
|
+
Field,
|
|
2564
|
+
getMinHashLength,
|
|
2565
|
+
mapHashToField,
|
|
2566
|
+
negateCt,
|
|
2567
|
+
normalizeZ,
|
|
2568
|
+
wNAF,
|
|
2569
|
+
mulEndoUnsafe,
|
|
2570
|
+
pippenger,
|
|
2571
|
+
_createCurveFields,
|
|
2420
2572
|
ed25519,
|
|
2421
2573
|
ed25519ctx,
|
|
2422
2574
|
ed25519ph,
|
|
@@ -35091,7 +35091,7 @@ function handleRequest(request) {
|
|
|
35091
35091
|
id: request.id,
|
|
35092
35092
|
result: {
|
|
35093
35093
|
protocolVersion: "2024-11-05",
|
|
35094
|
-
serverInfo: { name: "protect-mcp-demo", version: "0.5.3" },
|
|
35094
|
+
serverInfo: { name: "protect-mcp-demo", version: process.env.PROTECT_MCP_VERSION || "0.5.3" },
|
|
35095
35095
|
capabilities: { tools: {} }
|
|
35096
35096
|
}
|
|
35097
35097
|
});
|
|
@@ -35177,7 +35177,7 @@ function createSandboxServer() {
|
|
|
35177
35177
|
const { z } = require_zod();
|
|
35178
35178
|
const server = new McpServer({
|
|
35179
35179
|
name: "protect-mcp",
|
|
35180
|
-
version: "0.4.5",
|
|
35180
|
+
version: process.env.PROTECT_MCP_VERSION || "0.4.5",
|
|
35181
35181
|
description: "Security gateway for MCP servers. Per-tool policies, Ed25519-signed receipts, human approval gates, trust tiers."
|
|
35182
35182
|
});
|
|
35183
35183
|
server.tool(
|
|
@@ -524,7 +524,7 @@ function handleHealth(res, startTime, config) {
|
|
|
524
524
|
status: "ok",
|
|
525
525
|
uptime_ms: Date.now() - startTime,
|
|
526
526
|
mode: config.mode,
|
|
527
|
-
version:
|
|
527
|
+
version: process.env.PROTECT_MCP_VERSION || "unknown"
|
|
528
528
|
}));
|
|
529
529
|
}
|
|
530
530
|
function handleStatus(res, logDir) {
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ed25519,
|
|
3
3
|
sha256
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LJQOALYR.mjs";
|
|
5
5
|
import {
|
|
6
|
+
Hash,
|
|
7
|
+
abytes,
|
|
8
|
+
aexists,
|
|
9
|
+
ahash,
|
|
6
10
|
bytesToHex,
|
|
11
|
+
clean,
|
|
7
12
|
hexToBytes,
|
|
8
|
-
randomBytes
|
|
13
|
+
randomBytes,
|
|
14
|
+
toBytes
|
|
9
15
|
} from "./chunk-D733KAPG.mjs";
|
|
10
16
|
|
|
11
17
|
// node_modules/@noble/hashes/esm/sha256.js
|
|
@@ -122,6 +128,74 @@ function largestPowerOfTwoLessThan(n) {
|
|
|
122
128
|
return k;
|
|
123
129
|
}
|
|
124
130
|
|
|
131
|
+
// node_modules/@noble/hashes/esm/hmac.js
|
|
132
|
+
var HMAC = class extends Hash {
|
|
133
|
+
constructor(hash, _key) {
|
|
134
|
+
super();
|
|
135
|
+
this.finished = false;
|
|
136
|
+
this.destroyed = false;
|
|
137
|
+
ahash(hash);
|
|
138
|
+
const key = toBytes(_key);
|
|
139
|
+
this.iHash = hash.create();
|
|
140
|
+
if (typeof this.iHash.update !== "function")
|
|
141
|
+
throw new Error("Expected instance of class which extends utils.Hash");
|
|
142
|
+
this.blockLen = this.iHash.blockLen;
|
|
143
|
+
this.outputLen = this.iHash.outputLen;
|
|
144
|
+
const blockLen = this.blockLen;
|
|
145
|
+
const pad = new Uint8Array(blockLen);
|
|
146
|
+
pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);
|
|
147
|
+
for (let i = 0; i < pad.length; i++)
|
|
148
|
+
pad[i] ^= 54;
|
|
149
|
+
this.iHash.update(pad);
|
|
150
|
+
this.oHash = hash.create();
|
|
151
|
+
for (let i = 0; i < pad.length; i++)
|
|
152
|
+
pad[i] ^= 54 ^ 92;
|
|
153
|
+
this.oHash.update(pad);
|
|
154
|
+
clean(pad);
|
|
155
|
+
}
|
|
156
|
+
update(buf) {
|
|
157
|
+
aexists(this);
|
|
158
|
+
this.iHash.update(buf);
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
digestInto(out) {
|
|
162
|
+
aexists(this);
|
|
163
|
+
abytes(out, this.outputLen);
|
|
164
|
+
this.finished = true;
|
|
165
|
+
this.iHash.digestInto(out);
|
|
166
|
+
this.oHash.update(out);
|
|
167
|
+
this.oHash.digestInto(out);
|
|
168
|
+
this.destroy();
|
|
169
|
+
}
|
|
170
|
+
digest() {
|
|
171
|
+
const out = new Uint8Array(this.oHash.outputLen);
|
|
172
|
+
this.digestInto(out);
|
|
173
|
+
return out;
|
|
174
|
+
}
|
|
175
|
+
_cloneInto(to) {
|
|
176
|
+
to || (to = Object.create(Object.getPrototypeOf(this), {}));
|
|
177
|
+
const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
|
|
178
|
+
to = to;
|
|
179
|
+
to.finished = finished;
|
|
180
|
+
to.destroyed = destroyed;
|
|
181
|
+
to.blockLen = blockLen;
|
|
182
|
+
to.outputLen = outputLen;
|
|
183
|
+
to.oHash = oHash._cloneInto(to.oHash);
|
|
184
|
+
to.iHash = iHash._cloneInto(to.iHash);
|
|
185
|
+
return to;
|
|
186
|
+
}
|
|
187
|
+
clone() {
|
|
188
|
+
return this._cloneInto();
|
|
189
|
+
}
|
|
190
|
+
destroy() {
|
|
191
|
+
this.destroyed = true;
|
|
192
|
+
this.oHash.destroy();
|
|
193
|
+
this.iHash.destroy();
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
var hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();
|
|
197
|
+
hmac.create = (hash, key) => new HMAC(hash, key);
|
|
198
|
+
|
|
125
199
|
// src/commitments/primitives.ts
|
|
126
200
|
function jcs(value) {
|
|
127
201
|
if (value === null || value === void 0) return "null";
|
|
@@ -403,6 +477,8 @@ function verifyCommittedReceiptSignature(receipt) {
|
|
|
403
477
|
}
|
|
404
478
|
|
|
405
479
|
export {
|
|
480
|
+
sha2562 as sha256,
|
|
481
|
+
hmac,
|
|
406
482
|
signCommittedDecision,
|
|
407
483
|
discloseField,
|
|
408
484
|
createSelectiveDisclosurePackage,
|