@gvnrdao/dh-mcp 0.5.10 → 0.5.11

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 CHANGED
@@ -21,9 +21,11 @@ Downloads landing page (which file is for which system, checksums, security note
21
21
 
22
22
  Local installs serve local MCP hosts only — **claude.ai web / mobile / Cowork cannot
23
23
  reach them**. A hosted remote connector (paste-a-URL, wallet-only: OAuth 2.1 + Sign-In-
24
- with-Ethereum, external-wallet signing, no keystore mode in that build) is IMPLEMENTED
25
- but **not yet publicly served** — it goes live only after its security audit and rollout
26
- gates, and will appear here with its URL when it does.
24
+ with-Ethereum, external-wallet signing, no keystore mode in that build) is IMPLEMENTED;
25
+ whether it is publicly served, and on which networks, is the operator's rollout decision
26
+ (security audit first) and is stated by the running deployment itself — its `guide
27
+ connector` topic and `boundary://info` capabilities. This file cannot know: if you have
28
+ not been given a URL, use the install paths above.
27
29
 
28
30
  Unsigned-binary honesty: the macOS and Windows binaries are **not yet code-signed** —
29
31
  macOS Gatekeeper may quarantine the download (right-click → Open, or
@@ -24,6 +24,29 @@ export interface EmbeddedConnectorOptions {
24
24
  allowedNetworks?: readonly ("sepolia" | "mainnet")[];
25
25
  /** Idle windows (ms): `sessionMs` MCP-session expiry, `worldMs` tenant-world eviction. */
26
26
  idle?: { sessionMs?: number; worldMs?: number };
27
+ /** Maximum tenant worlds held at once (default 200). A world is a full boundary per
28
+ * distinct wallet, so this is the memory ceiling of the whole service. Reaching it
29
+ * first RECLAIMS the least-recently-active world that has no session, no attached
30
+ * approval page and no pending signature; only when no slot is reclaimable does it
31
+ * refuse the newcomer with a 503. A tenant who is using the service is never evicted
32
+ * to admit a stranger. */
33
+ maxTenants?: number;
34
+ /** Maximum MCP sessions held for ONE tenant (default 16). Each holds an McpServer and
35
+ * a transport and outlives its client by the session idle window; reaching the cap
36
+ * closes that tenant's least-recently-seen session (its client re-initializes on the
37
+ * 404) rather than refusing. Keyed by tenant, so it can only ever cost the identity
38
+ * that asked for the new session. */
39
+ maxSessionsPerTenant?: number;
40
+ /** Maximum bytes in a single /mcp request body (default 1 MiB), enforced on every
41
+ * POST — the initialize and the established-session legs alike, since the MCP SDK
42
+ * applies no limit of its own. Over the cap is a 413 naming the limit, with the
43
+ * connection closed rather than the upload drained. */
44
+ maxBodyBytes?: number;
45
+ /** Proxy hops in front of the HOST's listener (default 1). Decides what `req.ip`
46
+ * resolves to and therefore what every per-IP rate limit keys on: set 0 when nothing
47
+ * fronts the process, because trusting an absent hop lets a caller forge
48
+ * X-Forwarded-For and mint unlimited limiter keys. Never `true`. */
49
+ trustProxyHops?: number;
27
50
  /** Request caps with truthful 429s: per-tenant on /mcp, global on the whole surface. */
28
51
  rateLimits?: { tenantPerMin?: number; globalPerMin?: number };
29
52
  }
package/dist/boundary.js CHANGED
@@ -498,7 +498,7 @@ var require_utils = __commonJS({
498
498
  exports2.createHasher = createHasher2;
499
499
  exports2.createOptHasher = createOptHasher;
500
500
  exports2.createXOFer = createXOFer;
501
- exports2.randomBytes = randomBytes3;
501
+ exports2.randomBytes = randomBytes4;
502
502
  var crypto_1 = require_cryptoNode();
503
503
  function isBytes2(a) {
504
504
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
@@ -696,7 +696,7 @@ var require_utils = __commonJS({
696
696
  exports2.wrapConstructor = createHasher2;
697
697
  exports2.wrapConstructorWithOpts = createOptHasher;
698
698
  exports2.wrapXOFConstructorWithOpts = createXOFer;
699
- function randomBytes3(bytesLength = 32) {
699
+ function randomBytes4(bytesLength = 32) {
700
700
  if (crypto_1.crypto && typeof crypto_1.crypto.getRandomValues === "function") {
701
701
  return crypto_1.crypto.getRandomValues(new Uint8Array(bytesLength));
702
702
  }
@@ -40622,7 +40622,7 @@ __export(boundary_exports, {
40622
40622
  resolveBoundaryConfig: () => resolveBoundaryConfig
40623
40623
  });
40624
40624
  module.exports = __toCommonJS(boundary_exports);
40625
- var import_node_crypto7 = require("crypto");
40625
+ var import_node_crypto8 = require("crypto");
40626
40626
  var fs5 = __toESM(require("fs"));
40627
40627
  var os2 = __toESM(require("os"));
40628
40628
  var path4 = __toESM(require("path"));
@@ -79538,13 +79538,20 @@ var BridgeEthersSigner = class _BridgeEthersSigner extends import_ethers37.ether
79538
79538
  const outcome = await this.deps.bridge.requestSignature({
79539
79539
  id: (0, import_node_crypto5.randomUUID)(),
79540
79540
  kind: "personal-sign",
79541
- action: "btc-withdrawal authorization (blind hash)",
79541
+ action: "btc-withdrawal EXECUTE step (blind hash)",
79542
79542
  card: [
79543
- "BLIND SIGNATURE \u2014 BTC withdrawal authorization step",
79543
+ "BLIND SIGNATURE \u2014 BTC withdrawal, EXECUTE step",
79544
79544
  `hash: ${hashHex}`,
79545
79545
  "This hash is built inside the SDK and its contents CANNOT be decoded or verified by this page",
79546
79546
  "(identical to how diamondhands.credit signs withdrawals).",
79547
- "Approve ONLY if you initiated this exact BTC withdrawal in the conversation."
79547
+ "Approve ONLY if you initiated this exact BTC withdrawal in the conversation.",
79548
+ "",
79549
+ "SIGN NOW \u2014 this one is on a clock. The payload was stamped before this card was",
79550
+ `raised and is only valid inside a single ${QUANTUM_WINDOW_SECONDS}-second window, so the time left is`,
79551
+ "under a minute and often nearer twenty seconds \u2014 far less than the approval page",
79552
+ "itself allows. If it expires the signature is refused, the withdrawal does not",
79553
+ "complete, and the reserved coins stay reserved until that is cleared. Decline and",
79554
+ "start again rather than signing something you have not finished reading."
79548
79555
  ],
79549
79556
  expectedSigner: this.deps.borrower,
79550
79557
  chainId: this.deps.chainId,
@@ -80477,10 +80484,10 @@ var RealUpstreamPlugin = class {
80477
80484
  // src/boundary/upstream/shared/external-bridge/bridge.ts
80478
80485
  var fs4 = __toESM(require("fs"));
80479
80486
  var http3 = __toESM(require("http"));
80480
- var import_node_crypto6 = require("crypto");
80487
+ var import_node_crypto7 = require("crypto");
80481
80488
 
80482
80489
  // src/boundary/upstream/shared/external-bridge/approval-page.ts
80483
- function renderApprovalPage(sessionId) {
80490
+ function renderApprovalPage(sessionId, nonce) {
80484
80491
  return `<!doctype html>
80485
80492
  <html lang="en">
80486
80493
  <head>
@@ -80530,15 +80537,17 @@ function renderApprovalPage(sessionId) {
80530
80537
  </div>
80531
80538
  </div>
80532
80539
  </main>
80533
- <script>
80540
+ <script nonce="${nonce}">
80534
80541
  ${PAGE_CRYPTO_JS}
80535
80542
  </script>
80536
- <script>
80543
+ <script nonce="${nonce}">
80537
80544
  "use strict";
80538
80545
  const SESSION = ${JSON.stringify(sessionId)};
80539
80546
  // One-time token leaves the address bar (and history) immediately.
80540
80547
  // Plan 12 C1: endpoints resolve relative to the page DIRECTORY, so the same page works
80541
80548
  // at loopback root ("/") and under a hosted tenant mount ("/approval/<id>/").
80549
+ // EVERY endpoint reference goes through BASE \u2014 an origin-absolute "/x" resolves to the
80550
+ // ORIGIN root, which on a mount is the host, not the bridge, and 404s silently.
80542
80551
  const BASE = location.pathname.replace(/[^/]*$/, "");
80543
80552
  history.replaceState(null, "", location.pathname);
80544
80553
 
@@ -80610,14 +80619,14 @@ async function connect() {
80610
80619
  // wallet's own state transition and can report the stale value.
80611
80620
  async function onAccountsChanged(accounts) {
80612
80621
  account = (accounts && accounts[0]) || null;
80613
- await post("/wallet-event", { account: account, chainId: chainId });
80622
+ await post(BASE + "wallet-event", { account: account, chainId: chainId });
80614
80623
  showWallet();
80615
80624
  clearRequest("Wallet changed \u2014 pending request invalidated.");
80616
80625
  }
80617
80626
 
80618
80627
  async function onChainChanged(cid) {
80619
80628
  chainId = typeof cid === "string" ? parseInt(cid, 16) : Number(cid);
80620
- await post("/wallet-event", { account: account, chainId: chainId });
80629
+ await post(BASE + "wallet-event", { account: account, chainId: chainId });
80621
80630
  showWallet();
80622
80631
  clearRequest("Network changed \u2014 pending request invalidated.");
80623
80632
  }
@@ -80725,7 +80734,7 @@ connect();
80725
80734
  </body>
80726
80735
  </html>`;
80727
80736
  }
80728
- function renderUnlockPage(sessionId) {
80737
+ function renderUnlockPage(sessionId, nonce) {
80729
80738
  return `<!doctype html>
80730
80739
  <html lang="en">
80731
80740
  <head>
@@ -80767,7 +80776,7 @@ function renderUnlockPage(sessionId) {
80767
80776
  <div id="status" class="status"></div>
80768
80777
  </div>
80769
80778
  </main>
80770
- <script>
80779
+ <script nonce="${nonce}">
80771
80780
  "use strict";
80772
80781
  const SESSION = ${JSON.stringify(sessionId)};
80773
80782
  // Plan 12 C1: endpoints resolve relative to the page DIRECTORY, so the same page works
@@ -80798,6 +80807,21 @@ document.getElementById("generate").onclick = () => submit(true);
80798
80807
  </html>`;
80799
80808
  }
80800
80809
 
80810
+ // src/util/page-headers.ts
80811
+ var import_node_crypto6 = require("crypto");
80812
+ function htmlPageSecurityHeaders() {
80813
+ const nonce = (0, import_node_crypto6.randomBytes)(16).toString("base64");
80814
+ return {
80815
+ nonce,
80816
+ headers: {
80817
+ "Content-Security-Policy": `default-src 'none'; script-src 'nonce-${nonce}'; style-src 'unsafe-inline'; connect-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'`,
80818
+ "X-Frame-Options": "DENY",
80819
+ "Referrer-Policy": "no-referrer",
80820
+ "X-Content-Type-Options": "nosniff"
80821
+ }
80822
+ };
80823
+ }
80824
+
80801
80825
  // src/boundary/upstream/shared/external-bridge/bridge.ts
80802
80826
  var MAX_SESSIONS = 16;
80803
80827
  var DEFAULT_EXPIRY_MS = 5 * 60 * 1e3;
@@ -80825,7 +80849,7 @@ var SignatureBridge = class {
80825
80849
  /** Started state independent of the transport binding (mounted bridges own no server). */
80826
80850
  started = false;
80827
80851
  mount;
80828
- token = (0, import_node_crypto6.randomBytes)(24).toString("hex");
80852
+ token = (0, import_node_crypto7.randomBytes)(24).toString("hex");
80829
80853
  /** Hosted mounts: when the current page token was minted (rotation basis). */
80830
80854
  tokenMintedAt = 0;
80831
80855
  /** Ceremony-scoped link (plan 06 §1.5): the SAME URL is multi-visit and multi-owner —
@@ -80862,7 +80886,7 @@ var SignatureBridge = class {
80862
80886
  unlockUrl() {
80863
80887
  if (!this.started) throw new Error("bridge is not started");
80864
80888
  if (!this.keystoreUnlock) throw new Error("keystore unlock is not wired on this bridge");
80865
- this.unlockToken = (0, import_node_crypto6.randomBytes)(24).toString("hex");
80889
+ this.unlockToken = (0, import_node_crypto7.randomBytes)(24).toString("hex");
80866
80890
  return this.mount ? `${this.mount.baseUrl}/unlock?t=${this.unlockToken}` : `http://127.0.0.1:${this.port}/unlock?t=${this.unlockToken}`;
80867
80891
  }
80868
80892
  /** Idempotent — the bridge spawns on the first write that needs it (plan 04 §2).
@@ -80903,7 +80927,7 @@ var SignatureBridge = class {
80903
80927
  if (this.mount) {
80904
80928
  const now = this.clock();
80905
80929
  if (this.tokenMintedAt === 0 || now - this.tokenMintedAt > HOSTED_PAGE_TOKEN_TTL_MS) {
80906
- this.token = (0, import_node_crypto6.randomBytes)(24).toString("hex");
80930
+ this.token = (0, import_node_crypto7.randomBytes)(24).toString("hex");
80907
80931
  this.tokenMintedAt = now;
80908
80932
  }
80909
80933
  return `${this.mount.baseUrl}/?t=${this.token}`;
@@ -81119,7 +81143,7 @@ var SignatureBridge = class {
81119
81143
  this.server = null;
81120
81144
  this.started = false;
81121
81145
  this.wallet = null;
81122
- this.token = (0, import_node_crypto6.randomBytes)(24).toString("hex");
81146
+ this.token = (0, import_node_crypto7.randomBytes)(24).toString("hex");
81123
81147
  this.tokenMintedAt = 0;
81124
81148
  if (this.urlFile) fs4.rmSync(this.urlFile, { force: true });
81125
81149
  void this.wcTransport?.close().catch(() => void 0);
@@ -81189,10 +81213,11 @@ var SignatureBridge = class {
81189
81213
  this.deny(res, 429, `too many open approval pages (${MAX_SESSIONS}) \u2014 close one and retry`);
81190
81214
  return;
81191
81215
  }
81192
- const sessionId = (0, import_node_crypto6.randomBytes)(24).toString("hex");
81216
+ const sessionId = (0, import_node_crypto7.randomBytes)(24).toString("hex");
81193
81217
  this.sessions.set(sessionId, { wallet: null, sse: null });
81194
- res.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store" });
81195
- res.end(renderApprovalPage(sessionId));
81218
+ const page = htmlPageSecurityHeaders();
81219
+ res.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store", ...page.headers });
81220
+ res.end(renderApprovalPage(sessionId, page.nonce));
81196
81221
  }
81197
81222
  /** Target-network hints for the page's chain self-heal (session-gated). */
81198
81223
  serveConfig(url2, res) {
@@ -81252,9 +81277,10 @@ var SignatureBridge = class {
81252
81277
  return;
81253
81278
  }
81254
81279
  this.unlockToken = null;
81255
- this.unlockSession = (0, import_node_crypto6.randomBytes)(24).toString("hex");
81256
- res.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store" });
81257
- res.end(renderUnlockPage(this.unlockSession));
81280
+ this.unlockSession = (0, import_node_crypto7.randomBytes)(24).toString("hex");
81281
+ const page = htmlPageSecurityHeaders();
81282
+ res.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store", ...page.headers });
81283
+ res.end(renderUnlockPage(this.unlockSession, page.nonce));
81258
81284
  }
81259
81285
  async onUnlockSubmit(body, res) {
81260
81286
  if (!this.keystoreUnlock) {
@@ -81701,7 +81727,7 @@ function createBoundary(config, opts) {
81701
81727
  "createBoundary(real) is async \u2014 use createRealBoundary() so the write SDK can be built."
81702
81728
  );
81703
81729
  }
81704
- const configFingerprint = (0, import_node_crypto7.createHash)("sha256").update(JSON.stringify({ adapter: config.adapter, latency: config.latency, db: config.mockDb, signer: config.signer ?? "auto" })).digest("hex").slice(0, 12);
81730
+ const configFingerprint = (0, import_node_crypto8.createHash)("sha256").update(JSON.stringify({ adapter: config.adapter, latency: config.latency, db: config.mockDb, signer: config.signer ?? "auto" })).digest("hex").slice(0, 12);
81705
81731
  if (opts?.ceremony) {
81706
81732
  const plugin2 = new MockUpstreamPlugin(config, { ceremony: opts.ceremony });
81707
81733
  const boundary2 = new BoundaryCore({
@@ -81870,7 +81896,7 @@ async function createRealBoundary(config, wallet, overrides) {
81870
81896
  }
81871
81897
  const plugin = new RealUpstreamPlugin(config, wallet, { manager, bridge, keystore });
81872
81898
  await plugin.initWriteSdk();
81873
- const configFingerprint = (0, import_node_crypto7.createHash)("sha256").update(JSON.stringify({ adapter: config.adapter, network: config.network, ops: config.serviceEndpoint })).digest("hex").slice(0, 12);
81899
+ const configFingerprint = (0, import_node_crypto8.createHash)("sha256").update(JSON.stringify({ adapter: config.adapter, network: config.network, ops: config.serviceEndpoint })).digest("hex").slice(0, 12);
81874
81900
  const capabilities = () => ({
81875
81901
  reads: {
81876
81902
  public: true,