@helm-protocol/ttt-mcp 0.4.3 → 0.4.5

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/index.js CHANGED
@@ -105,7 +105,7 @@ function toolSuccess(result) {
105
105
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
106
106
  }
107
107
  function buildMcpServer() {
108
- const s = new import_mcp.McpServer({ name: "ttt-mcp", version: "0.4.3" });
108
+ const s = new import_mcp.McpServer({ name: "ttt-mcp", version: "0.4.4" });
109
109
  const registerTool = s.tool.bind(s);
110
110
  registerTool(
111
111
  "pot_generate",
@@ -304,12 +304,13 @@ async function main() {
304
304
  const requestHandler = async (req, res) => {
305
305
  if (req.method === "GET" && (req.url === "/health" || req.url === "/ping")) {
306
306
  res.writeHead(200, { "Content-Type": "application/json" });
307
- res.end(JSON.stringify({ status: "ok", server: "ttt-mcp", version: "0.4.3" }));
307
+ res.end(JSON.stringify({ status: "ok", server: "ttt-mcp", version: "0.4.4" }));
308
308
  return;
309
309
  }
310
310
  if (req.method === "POST") {
311
311
  const apiKey = (0, import_auth.resolveApiKey)(req.headers["x-api-key"]);
312
- const clientIp = req.headers["x-forwarded-for"]?.split(",")[0].trim() || req.socket.remoteAddress || "unknown";
312
+ const trustProxy = process.env.TTTPS_TRUST_PROXY === "1";
313
+ const clientIp = (trustProxy ? req.headers["x-forwarded-for"]?.split(",")[0].trim() : "") || req.socket.remoteAddress || "unknown";
313
314
  const rl = (0, import_auth.checkRateLimit)(apiKey, clientIp);
314
315
  if (!rl.allowed) {
315
316
  res.writeHead(429, {
@@ -21,6 +21,8 @@ __export(pot_record_v2_exports, {
21
21
  HOLDER_AUTH_ED25519: () => HOLDER_AUTH_ED25519,
22
22
  HOLDER_AUTH_SHARED_SECRET: () => HOLDER_AUTH_SHARED_SECRET,
23
23
  POT_V2_INTEGRITY_SHA256: () => POT_V2_INTEGRITY_SHA256,
24
+ POT_V2_ISSUER_SIGNATURE_SIZE: () => POT_V2_ISSUER_SIGNATURE_SIZE,
25
+ POT_V2_SIGNED_PREFIX_SIZE: () => POT_V2_SIGNED_PREFIX_SIZE,
24
26
  POT_V2_SIZE: () => POT_V2_SIZE,
25
27
  POT_V2_VERSION: () => POT_V2_VERSION,
26
28
  computeV2BindingInput: () => computeV2BindingInput,
@@ -35,6 +37,8 @@ var import_crypto = require("crypto");
35
37
  const POT_V2_SIZE = 180;
36
38
  const POT_V2_VERSION = 2;
37
39
  const POT_V2_INTEGRITY_SHA256 = 1;
40
+ const POT_V2_SIGNED_PREFIX_SIZE = 116;
41
+ const POT_V2_ISSUER_SIGNATURE_SIZE = 64;
38
42
  const HOLDER_AUTH_ED25519 = 1;
39
43
  const HOLDER_AUTH_SHARED_SECRET = 2;
40
44
  const OFF = {
@@ -72,7 +76,7 @@ function encodePotRecordV2(fields, issuerPrivateKey) {
72
76
  requireLength("ctx_id", fields.ctxId, 16);
73
77
  requireLength("nonce", fields.nonce, 16);
74
78
  requireLength("holder_auth_data", fields.holderAuthData, 32);
75
- const prefix = Buffer.alloc(116);
79
+ const prefix = Buffer.alloc(POT_V2_SIGNED_PREFIX_SIZE);
76
80
  prefix.writeUInt8(POT_V2_VERSION, OFF.VERSION);
77
81
  prefix.writeUInt8(fields.holderAuthType, OFF.HOLDER_AUTH_TYPE);
78
82
  prefix.writeUInt16BE(fields.algId, OFF.ALG_ID);
@@ -88,7 +92,9 @@ function encodePotRecordV2(fields, issuerPrivateKey) {
88
92
  }
89
93
  function decodePotRecordV2(record) {
90
94
  if (record.length !== POT_V2_SIZE) throw new Error(`expected 180 octets, got ${record.length}`);
91
- const signedPrefix = record.subarray(0, 116);
95
+ const signedPrefix = record.subarray(0, POT_V2_SIGNED_PREFIX_SIZE);
96
+ const issuerSig = record.subarray(POT_V2_SIGNED_PREFIX_SIZE, POT_V2_SIZE);
97
+ requireLength("issuer signature", issuerSig, POT_V2_ISSUER_SIGNATURE_SIZE);
92
98
  return {
93
99
  holderAuthType: record.readUInt8(OFF.HOLDER_AUTH_TYPE),
94
100
  algId: record.readUInt16BE(OFF.ALG_ID),
@@ -99,7 +105,7 @@ function decodePotRecordV2(record) {
99
105
  holderAuthData: Buffer.from(record.subarray(OFF.HOLDER_AUTH_DATA, OFF.HOLDER_AUTH_DATA + 32)),
100
106
  issuerKeyId: record.readUInt32BE(OFF.ISSUER_KEY_ID),
101
107
  integrityTag: Buffer.from(record.subarray(OFF.INTEGRITY_TAG, OFF.INTEGRITY_TAG + 32)),
102
- issuerSig: Buffer.from(record.subarray(OFF.ISSUER_SIG, POT_V2_SIZE)),
108
+ issuerSig: Buffer.from(issuerSig),
103
109
  signedPrefix: Buffer.from(signedPrefix)
104
110
  };
105
111
  }
@@ -163,6 +169,8 @@ function verifyPotRecordV2(record, issuerPublicKeyRaw, freshness) {
163
169
  HOLDER_AUTH_ED25519,
164
170
  HOLDER_AUTH_SHARED_SECRET,
165
171
  POT_V2_INTEGRITY_SHA256,
172
+ POT_V2_ISSUER_SIGNATURE_SIZE,
173
+ POT_V2_SIGNED_PREFIX_SIZE,
166
174
  POT_V2_SIZE,
167
175
  POT_V2_VERSION,
168
176
  computeV2BindingInput,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helm-protocol/ttt-mcp",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "Proof-of-Time attestation — Ed25519-signed timestamps with multi-source corroboration and explicit error bounds. IETF draft-helmprotocol-tttps",
5
5
  "main": "dist/index.js",
6
6
  "bin": {