@gvnrdao/dh-mcp 0.5.10 → 0.5.12
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 +5 -3
- package/connector-embed.d.ts +23 -0
- package/dist/boundary.js +81 -28
- package/dist/connector-embed.js +2337 -1387
- package/dist/connector.js +2348 -1381
- package/dist/index.js +1383 -1043
- package/package.json +6 -5
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
|
-
|
|
26
|
-
|
|
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
|
package/connector-embed.d.ts
CHANGED
|
@@ -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 =
|
|
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
|
|
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
|
|
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"));
|
|
@@ -56700,7 +56700,17 @@ function getSepoliaConfig() {
|
|
|
56700
56700
|
function getMainnetConfig() {
|
|
56701
56701
|
return {
|
|
56702
56702
|
mode: "service",
|
|
56703
|
-
|
|
56703
|
+
// Cutover 2026-09-08: the product's own domain. `ops.gvnr.xyz` still serves the same
|
|
56704
|
+
// broker and always will — every already-installed copy of this package calls it, so
|
|
56705
|
+
// it can never be retired. This changes what NEW installs default to, nothing else.
|
|
56706
|
+
//
|
|
56707
|
+
// Safe only because the server accepts the new audience ALREADY: the SDK derives the
|
|
56708
|
+
// login audience from this endpoint (`server-session.ts` — `loginAudience ??
|
|
56709
|
+
// serviceEndpoint`) and lit-ops-server FAILS CLOSED on an unknown one. Verified live
|
|
56710
|
+
// before this edit: DH_ACCEPTED_LOGIN_AUDIENCES on the deployed revision lists
|
|
56711
|
+
// https://ops.diamondhands.credit. Publishing this ahead of that would lock out every
|
|
56712
|
+
// client that installed it.
|
|
56713
|
+
serviceEndpoint: "https://ops.diamondhands.credit",
|
|
56704
56714
|
chainId: 1,
|
|
56705
56715
|
name: "mainnet",
|
|
56706
56716
|
// No default RPC: mainnet runs in service mode (serviceEndpoint above), so
|
|
@@ -79538,13 +79548,20 @@ var BridgeEthersSigner = class _BridgeEthersSigner extends import_ethers37.ether
|
|
|
79538
79548
|
const outcome = await this.deps.bridge.requestSignature({
|
|
79539
79549
|
id: (0, import_node_crypto5.randomUUID)(),
|
|
79540
79550
|
kind: "personal-sign",
|
|
79541
|
-
action: "btc-withdrawal
|
|
79551
|
+
action: "btc-withdrawal EXECUTE step (blind hash)",
|
|
79542
79552
|
card: [
|
|
79543
|
-
"BLIND SIGNATURE \u2014 BTC withdrawal
|
|
79553
|
+
"BLIND SIGNATURE \u2014 BTC withdrawal, EXECUTE step",
|
|
79544
79554
|
`hash: ${hashHex}`,
|
|
79545
79555
|
"This hash is built inside the SDK and its contents CANNOT be decoded or verified by this page",
|
|
79546
79556
|
"(identical to how diamondhands.credit signs withdrawals).",
|
|
79547
|
-
"Approve ONLY if you initiated this exact BTC withdrawal in the conversation."
|
|
79557
|
+
"Approve ONLY if you initiated this exact BTC withdrawal in the conversation.",
|
|
79558
|
+
"",
|
|
79559
|
+
"SIGN NOW \u2014 this one is on a clock. The payload was stamped before this card was",
|
|
79560
|
+
`raised and is only valid inside a single ${QUANTUM_WINDOW_SECONDS}-second window, so the time left is`,
|
|
79561
|
+
"under a minute and often nearer twenty seconds \u2014 far less than the approval page",
|
|
79562
|
+
"itself allows. If it expires the signature is refused, the withdrawal does not",
|
|
79563
|
+
"complete, and the reserved coins stay reserved until that is cleared. Decline and",
|
|
79564
|
+
"start again rather than signing something you have not finished reading."
|
|
79548
79565
|
],
|
|
79549
79566
|
expectedSigner: this.deps.borrower,
|
|
79550
79567
|
chainId: this.deps.chainId,
|
|
@@ -80477,10 +80494,10 @@ var RealUpstreamPlugin = class {
|
|
|
80477
80494
|
// src/boundary/upstream/shared/external-bridge/bridge.ts
|
|
80478
80495
|
var fs4 = __toESM(require("fs"));
|
|
80479
80496
|
var http3 = __toESM(require("http"));
|
|
80480
|
-
var
|
|
80497
|
+
var import_node_crypto7 = require("crypto");
|
|
80481
80498
|
|
|
80482
80499
|
// src/boundary/upstream/shared/external-bridge/approval-page.ts
|
|
80483
|
-
function renderApprovalPage(sessionId) {
|
|
80500
|
+
function renderApprovalPage(sessionId, nonce) {
|
|
80484
80501
|
return `<!doctype html>
|
|
80485
80502
|
<html lang="en">
|
|
80486
80503
|
<head>
|
|
@@ -80530,15 +80547,17 @@ function renderApprovalPage(sessionId) {
|
|
|
80530
80547
|
</div>
|
|
80531
80548
|
</div>
|
|
80532
80549
|
</main>
|
|
80533
|
-
<script>
|
|
80550
|
+
<script nonce="${nonce}">
|
|
80534
80551
|
${PAGE_CRYPTO_JS}
|
|
80535
80552
|
</script>
|
|
80536
|
-
<script>
|
|
80553
|
+
<script nonce="${nonce}">
|
|
80537
80554
|
"use strict";
|
|
80538
80555
|
const SESSION = ${JSON.stringify(sessionId)};
|
|
80539
80556
|
// One-time token leaves the address bar (and history) immediately.
|
|
80540
80557
|
// Plan 12 C1: endpoints resolve relative to the page DIRECTORY, so the same page works
|
|
80541
80558
|
// at loopback root ("/") and under a hosted tenant mount ("/approval/<id>/").
|
|
80559
|
+
// EVERY endpoint reference goes through BASE \u2014 an origin-absolute "/x" resolves to the
|
|
80560
|
+
// ORIGIN root, which on a mount is the host, not the bridge, and 404s silently.
|
|
80542
80561
|
const BASE = location.pathname.replace(/[^/]*$/, "");
|
|
80543
80562
|
history.replaceState(null, "", location.pathname);
|
|
80544
80563
|
|
|
@@ -80610,14 +80629,14 @@ async function connect() {
|
|
|
80610
80629
|
// wallet's own state transition and can report the stale value.
|
|
80611
80630
|
async function onAccountsChanged(accounts) {
|
|
80612
80631
|
account = (accounts && accounts[0]) || null;
|
|
80613
|
-
await post("
|
|
80632
|
+
await post(BASE + "wallet-event", { account: account, chainId: chainId });
|
|
80614
80633
|
showWallet();
|
|
80615
80634
|
clearRequest("Wallet changed \u2014 pending request invalidated.");
|
|
80616
80635
|
}
|
|
80617
80636
|
|
|
80618
80637
|
async function onChainChanged(cid) {
|
|
80619
80638
|
chainId = typeof cid === "string" ? parseInt(cid, 16) : Number(cid);
|
|
80620
|
-
await post("
|
|
80639
|
+
await post(BASE + "wallet-event", { account: account, chainId: chainId });
|
|
80621
80640
|
showWallet();
|
|
80622
80641
|
clearRequest("Network changed \u2014 pending request invalidated.");
|
|
80623
80642
|
}
|
|
@@ -80725,7 +80744,7 @@ connect();
|
|
|
80725
80744
|
</body>
|
|
80726
80745
|
</html>`;
|
|
80727
80746
|
}
|
|
80728
|
-
function renderUnlockPage(sessionId) {
|
|
80747
|
+
function renderUnlockPage(sessionId, nonce) {
|
|
80729
80748
|
return `<!doctype html>
|
|
80730
80749
|
<html lang="en">
|
|
80731
80750
|
<head>
|
|
@@ -80767,7 +80786,7 @@ function renderUnlockPage(sessionId) {
|
|
|
80767
80786
|
<div id="status" class="status"></div>
|
|
80768
80787
|
</div>
|
|
80769
80788
|
</main>
|
|
80770
|
-
<script>
|
|
80789
|
+
<script nonce="${nonce}">
|
|
80771
80790
|
"use strict";
|
|
80772
80791
|
const SESSION = ${JSON.stringify(sessionId)};
|
|
80773
80792
|
// Plan 12 C1: endpoints resolve relative to the page DIRECTORY, so the same page works
|
|
@@ -80798,6 +80817,34 @@ document.getElementById("generate").onclick = () => submit(true);
|
|
|
80798
80817
|
</html>`;
|
|
80799
80818
|
}
|
|
80800
80819
|
|
|
80820
|
+
// src/util/page-headers.ts
|
|
80821
|
+
var import_node_crypto6 = require("crypto");
|
|
80822
|
+
function htmlPageSecurityHeaders(extra) {
|
|
80823
|
+
const nonce = (0, import_node_crypto6.randomBytes)(16).toString("base64");
|
|
80824
|
+
const base = [
|
|
80825
|
+
`default-src 'none'`,
|
|
80826
|
+
`script-src 'nonce-${nonce}'`,
|
|
80827
|
+
`style-src 'unsafe-inline'`,
|
|
80828
|
+
`connect-src 'self'`,
|
|
80829
|
+
`base-uri 'none'`,
|
|
80830
|
+
`form-action 'none'`,
|
|
80831
|
+
`frame-ancestors 'none'`
|
|
80832
|
+
];
|
|
80833
|
+
for (const [directive, sources] of Object.entries(extra ?? {})) {
|
|
80834
|
+
if (sources.length === 0) continue;
|
|
80835
|
+
base.push(`${directive} ${sources.join(" ")}`);
|
|
80836
|
+
}
|
|
80837
|
+
return {
|
|
80838
|
+
nonce,
|
|
80839
|
+
headers: {
|
|
80840
|
+
"Content-Security-Policy": base.join("; "),
|
|
80841
|
+
"X-Frame-Options": "DENY",
|
|
80842
|
+
"Referrer-Policy": "no-referrer",
|
|
80843
|
+
"X-Content-Type-Options": "nosniff"
|
|
80844
|
+
}
|
|
80845
|
+
};
|
|
80846
|
+
}
|
|
80847
|
+
|
|
80801
80848
|
// src/boundary/upstream/shared/external-bridge/bridge.ts
|
|
80802
80849
|
var MAX_SESSIONS = 16;
|
|
80803
80850
|
var DEFAULT_EXPIRY_MS = 5 * 60 * 1e3;
|
|
@@ -80825,7 +80872,7 @@ var SignatureBridge = class {
|
|
|
80825
80872
|
/** Started state independent of the transport binding (mounted bridges own no server). */
|
|
80826
80873
|
started = false;
|
|
80827
80874
|
mount;
|
|
80828
|
-
token = (0,
|
|
80875
|
+
token = (0, import_node_crypto7.randomBytes)(24).toString("hex");
|
|
80829
80876
|
/** Hosted mounts: when the current page token was minted (rotation basis). */
|
|
80830
80877
|
tokenMintedAt = 0;
|
|
80831
80878
|
/** Ceremony-scoped link (plan 06 §1.5): the SAME URL is multi-visit and multi-owner —
|
|
@@ -80862,7 +80909,7 @@ var SignatureBridge = class {
|
|
|
80862
80909
|
unlockUrl() {
|
|
80863
80910
|
if (!this.started) throw new Error("bridge is not started");
|
|
80864
80911
|
if (!this.keystoreUnlock) throw new Error("keystore unlock is not wired on this bridge");
|
|
80865
|
-
this.unlockToken = (0,
|
|
80912
|
+
this.unlockToken = (0, import_node_crypto7.randomBytes)(24).toString("hex");
|
|
80866
80913
|
return this.mount ? `${this.mount.baseUrl}/unlock?t=${this.unlockToken}` : `http://127.0.0.1:${this.port}/unlock?t=${this.unlockToken}`;
|
|
80867
80914
|
}
|
|
80868
80915
|
/** Idempotent — the bridge spawns on the first write that needs it (plan 04 §2).
|
|
@@ -80903,7 +80950,7 @@ var SignatureBridge = class {
|
|
|
80903
80950
|
if (this.mount) {
|
|
80904
80951
|
const now = this.clock();
|
|
80905
80952
|
if (this.tokenMintedAt === 0 || now - this.tokenMintedAt > HOSTED_PAGE_TOKEN_TTL_MS) {
|
|
80906
|
-
this.token = (0,
|
|
80953
|
+
this.token = (0, import_node_crypto7.randomBytes)(24).toString("hex");
|
|
80907
80954
|
this.tokenMintedAt = now;
|
|
80908
80955
|
}
|
|
80909
80956
|
return `${this.mount.baseUrl}/?t=${this.token}`;
|
|
@@ -81119,7 +81166,7 @@ var SignatureBridge = class {
|
|
|
81119
81166
|
this.server = null;
|
|
81120
81167
|
this.started = false;
|
|
81121
81168
|
this.wallet = null;
|
|
81122
|
-
this.token = (0,
|
|
81169
|
+
this.token = (0, import_node_crypto7.randomBytes)(24).toString("hex");
|
|
81123
81170
|
this.tokenMintedAt = 0;
|
|
81124
81171
|
if (this.urlFile) fs4.rmSync(this.urlFile, { force: true });
|
|
81125
81172
|
void this.wcTransport?.close().catch(() => void 0);
|
|
@@ -81189,10 +81236,11 @@ var SignatureBridge = class {
|
|
|
81189
81236
|
this.deny(res, 429, `too many open approval pages (${MAX_SESSIONS}) \u2014 close one and retry`);
|
|
81190
81237
|
return;
|
|
81191
81238
|
}
|
|
81192
|
-
const sessionId = (0,
|
|
81239
|
+
const sessionId = (0, import_node_crypto7.randomBytes)(24).toString("hex");
|
|
81193
81240
|
this.sessions.set(sessionId, { wallet: null, sse: null });
|
|
81194
|
-
|
|
81195
|
-
res.
|
|
81241
|
+
const page = htmlPageSecurityHeaders();
|
|
81242
|
+
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store", ...page.headers });
|
|
81243
|
+
res.end(renderApprovalPage(sessionId, page.nonce));
|
|
81196
81244
|
}
|
|
81197
81245
|
/** Target-network hints for the page's chain self-heal (session-gated). */
|
|
81198
81246
|
serveConfig(url2, res) {
|
|
@@ -81252,9 +81300,10 @@ var SignatureBridge = class {
|
|
|
81252
81300
|
return;
|
|
81253
81301
|
}
|
|
81254
81302
|
this.unlockToken = null;
|
|
81255
|
-
this.unlockSession = (0,
|
|
81256
|
-
|
|
81257
|
-
res.
|
|
81303
|
+
this.unlockSession = (0, import_node_crypto7.randomBytes)(24).toString("hex");
|
|
81304
|
+
const page = htmlPageSecurityHeaders();
|
|
81305
|
+
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store", ...page.headers });
|
|
81306
|
+
res.end(renderUnlockPage(this.unlockSession, page.nonce));
|
|
81258
81307
|
}
|
|
81259
81308
|
async onUnlockSubmit(body, res) {
|
|
81260
81309
|
if (!this.keystoreUnlock) {
|
|
@@ -81496,7 +81545,11 @@ var NETWORK_DEFAULTS = {
|
|
|
81496
81545
|
},
|
|
81497
81546
|
mainnet: {
|
|
81498
81547
|
rpcUrl: "https://ethereum-rpc.publicnode.com",
|
|
81499
|
-
|
|
81548
|
+
// Cutover 2026-09-08 — see sdk/src/constants/chunks/network-configs.ts for the full
|
|
81549
|
+
// reasoning. Widening, not a rename: ops.gvnr.xyz serves the same broker and cannot be
|
|
81550
|
+
// retired while installed copies call it. The sepolia entry above deliberately stays on
|
|
81551
|
+
// ops-test.gvnr.xyz — there is no ops-test.diamondhands.credit twin (open decision 2).
|
|
81552
|
+
serviceEndpoint: "https://ops.diamondhands.credit",
|
|
81500
81553
|
litNetwork: "chipotle",
|
|
81501
81554
|
// On-chain PKPValidation generation, mainnet (validatorForVersion(3) is the ONLY
|
|
81502
81555
|
// registered validator — verified live 2026-08-05). Without this the SDK defaults
|
|
@@ -81701,7 +81754,7 @@ function createBoundary(config, opts) {
|
|
|
81701
81754
|
"createBoundary(real) is async \u2014 use createRealBoundary() so the write SDK can be built."
|
|
81702
81755
|
);
|
|
81703
81756
|
}
|
|
81704
|
-
const configFingerprint = (0,
|
|
81757
|
+
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
81758
|
if (opts?.ceremony) {
|
|
81706
81759
|
const plugin2 = new MockUpstreamPlugin(config, { ceremony: opts.ceremony });
|
|
81707
81760
|
const boundary2 = new BoundaryCore({
|
|
@@ -81870,7 +81923,7 @@ async function createRealBoundary(config, wallet, overrides) {
|
|
|
81870
81923
|
}
|
|
81871
81924
|
const plugin = new RealUpstreamPlugin(config, wallet, { manager, bridge, keystore });
|
|
81872
81925
|
await plugin.initWriteSdk();
|
|
81873
|
-
const configFingerprint = (0,
|
|
81926
|
+
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
81927
|
const capabilities = () => ({
|
|
81875
81928
|
reads: {
|
|
81876
81929
|
public: true,
|