@gvnrdao/dh-mcp 0.5.20 → 0.5.21

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/boundary.js CHANGED
@@ -13422,6 +13422,12 @@ var require_follow_redirects = __commonJS({
13422
13422
  RedirectableRequest.prototype._sanitizeOptions = function(options) {
13423
13423
  if (!options.headers) {
13424
13424
  options.headers = {};
13425
+ } else if (Array.isArray(options.headers)) {
13426
+ var headerList = options.headers;
13427
+ options.headers = {};
13428
+ for (var i = 0; i < headerList.length; i += 2) {
13429
+ options.headers[headerList[i]] = headerList[i + 1];
13430
+ }
13425
13431
  }
13426
13432
  if (!isArray2(options.sensitiveHeaders)) {
13427
13433
  options.sensitiveHeaders = [];
@@ -13696,7 +13702,7 @@ var require_follow_redirects = __commonJS({
13696
13702
  return URL3 && value instanceof URL3;
13697
13703
  }
13698
13704
  function escapeRegex(regex) {
13699
- return regex.replace(/[\]\\/()*+?.$]/g, "\\$&");
13705
+ return regex.replace(/[[\]\\/()*+?.^$|]/g, "\\$&");
13700
13706
  }
13701
13707
  module2.exports = wrap({ http: http4, https: https2 });
13702
13708
  module2.exports.wrap = wrap;
@@ -14688,6 +14694,32 @@ var require_pkg_src = __commonJS({
14688
14694
  deployedAt: 1790246264563,
14689
14695
  size: 69219,
14690
14696
  hash: "bda048d8cd6b5a39c2774bcf1320e82d1eea935c2a521006fb8b887e13b6dd8d"
14697
+ },
14698
+ carryCollateralAttestation: {
14699
+ cid: "QmYWULmXD9S5AmTdQqWqoZ28ctsZQNcXkAgre9G2Xo9dh8",
14700
+ authorizedCidHex: cidToHex(
14701
+ "QmYWULmXD9S5AmTdQqWqoZ28ctsZQNcXkAgre9G2Xo9dh8"
14702
+ ),
14703
+ name: "Carry Collateral Attestation",
14704
+ description: "LoanCarryVault collateral attestation (borrower, BTC vault, confirmed BTC)",
14705
+ version: "1.0.0",
14706
+ deployed: true,
14707
+ deployedAt: 1790927734070,
14708
+ size: 21156,
14709
+ hash: "05b177e0bb36b0483db4a42d33c1bbbf47eb9ef34ae278459397d51a7f8957ff"
14710
+ },
14711
+ carryFundingAttestation: {
14712
+ cid: "QmWhox3xUZMNR5NpPZ9WLSPC5GoW4ms88GanVRKr8uuS3W",
14713
+ authorizedCidHex: cidToHex(
14714
+ "QmWhox3xUZMNR5NpPZ9WLSPC5GoW4ms88GanVRKr8uuS3W"
14715
+ ),
14716
+ name: "Carry Funding Attestation",
14717
+ description: "LoanCarryVault funding attestation (Hyperliquid BTC windowed hourly average)",
14718
+ version: "1.0.0",
14719
+ deployed: true,
14720
+ deployedAt: 1790925699980,
14721
+ size: 7193,
14722
+ hash: "4944ada61610cf64b32e33b5be62087088dcf5e821040c69e67942e643ce74c9"
14691
14723
  }
14692
14724
  };
14693
14725
  function getDeploymentsForNetwork(network) {
@@ -15431,7 +15463,7 @@ ${errorReport}`);
15431
15463
  }
15432
15464
  init_debug_logger();
15433
15465
  init_session_signature_cache();
15434
- var import_ethers50 = require("ethers");
15466
+ var import_ethers52 = require("ethers");
15435
15467
  var EXPIRED_LOAN_MIN_LIQUIDATION_THRESHOLD_BPS = 11e3;
15436
15468
  var GRACE_PERIOD_DAYS = 30;
15437
15469
  var SATOSHIS_PER_BITCOIN = 100000000n;
@@ -18427,12 +18459,12 @@ ${auth.clientId}`;
18427
18459
  }
18428
18460
  async function executeVaultSnapshot(params) {
18429
18461
  global.ethers = {
18430
- ...import_ethers50.ethers,
18462
+ ...import_ethers52.ethers,
18431
18463
  providers: {
18432
- StaticJsonRpcProvider: import_ethers50.ethers.JsonRpcProvider
18464
+ StaticJsonRpcProvider: import_ethers52.ethers.JsonRpcProvider
18433
18465
  },
18434
- Contract: import_ethers50.ethers.Contract,
18435
- utils: import_ethers50.ethers
18466
+ Contract: import_ethers52.ethers.Contract,
18467
+ utils: import_ethers52.ethers
18436
18468
  // v6 moved utils to top level
18437
18469
  };
18438
18470
  global.Lit = {
@@ -27312,7 +27344,7 @@ var require_lit_ops_module = __commonJS({
27312
27344
  break;
27313
27345
  case 11155111:
27314
27346
  chain = "sepolia";
27315
- bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://dh-btc-faucet-jw-bb7756976029.herokuapp.com/api/esplora";
27347
+ bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://regtest.diamondhands.credit/api/esplora";
27316
27348
  break;
27317
27349
  case 1337:
27318
27350
  // Hardhat local testnet (actual deployment chainId)
@@ -27501,7 +27533,7 @@ var require_lit_ops_module = __commonJS({
27501
27533
  break;
27502
27534
  case 11155111:
27503
27535
  chain = "sepolia";
27504
- bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://dh-btc-faucet-jw-bb7756976029.herokuapp.com/api/esplora";
27536
+ bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://regtest.diamondhands.credit/api/esplora";
27505
27537
  break;
27506
27538
  case 1337:
27507
27539
  // Hardhat local testnet (actual deployment chainId)
@@ -27692,7 +27724,7 @@ var require_lit_ops_module = __commonJS({
27692
27724
  break;
27693
27725
  case 11155111:
27694
27726
  chain = "sepolia";
27695
- bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://dh-btc-faucet-jw-bb7756976029.herokuapp.com/api/esplora";
27727
+ bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://regtest.diamondhands.credit/api/esplora";
27696
27728
  break;
27697
27729
  case 1337:
27698
27730
  case 31337:
@@ -27840,7 +27872,7 @@ var require_lit_ops_module = __commonJS({
27840
27872
  break;
27841
27873
  case 11155111:
27842
27874
  chain = "sepolia";
27843
- bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://dh-btc-faucet-jw-bb7756976029.herokuapp.com/api/esplora";
27875
+ bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://regtest.diamondhands.credit/api/esplora";
27844
27876
  break;
27845
27877
  case 1337:
27846
27878
  // Hardhat local testnet (actual deployment chainId)
@@ -28060,7 +28092,7 @@ var require_lit_ops_module = __commonJS({
28060
28092
  bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://mempool.space/api";
28061
28093
  break;
28062
28094
  case 11155111:
28063
- bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://dh-btc-faucet-jw-bb7756976029.herokuapp.com/api/esplora";
28095
+ bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://regtest.diamondhands.credit/api/esplora";
28064
28096
  break;
28065
28097
  case 1337:
28066
28098
  // Hardhat local testnet (actual deployment chainId)
@@ -40751,7 +40783,8 @@ var init_wc_transport = __esm({
40751
40783
  this.client = client;
40752
40784
  this.cfg = cfg;
40753
40785
  this.scratch = scratch;
40754
- client.on("session_delete", () => {
40786
+ client.on("session_delete", ({ topic }) => {
40787
+ if (this.session === null || this.session.topic !== topic) return;
40755
40788
  this.session = null;
40756
40789
  this.sessionListener?.(null);
40757
40790
  });
@@ -40763,7 +40796,7 @@ var init_wc_transport = __esm({
40763
40796
  const client = await import_sign_client.default.init({
40764
40797
  core,
40765
40798
  projectId: cfg.projectId,
40766
- metadata: WC_DAPP_METADATA
40799
+ metadata: cfg.metadata ?? WC_DAPP_METADATA
40767
40800
  });
40768
40801
  return new _WcTransport(client, cfg, scratch);
40769
40802
  }
@@ -40781,14 +40814,21 @@ var init_wc_transport = __esm({
40781
40814
  optionalNamespaces: wcSessionNamespaces(this.cfg.chainId)
40782
40815
  });
40783
40816
  if (!uri) throw new Error("WalletConnect returned no pairing URI");
40817
+ const pairingId = /^wc:([0-9a-f]+)@/i.exec(uri)?.[1];
40818
+ if (!pairingId) throw new Error(`WalletConnect pairing URI has no recognisable topic: ${uri.slice(0, 12)}\u2026`);
40784
40819
  void approval().then((session) => {
40785
40820
  const first = session.namespaces["eip155"]?.accounts[0];
40786
40821
  if (!first) throw new Error("WalletConnect session carries no eip155 account");
40787
40822
  const [, chainIdStr, account] = first.split(":");
40823
+ const previous = this.session;
40788
40824
  this.session = { topic: session.topic, account, chainId: Number(chainIdStr) };
40789
- this.sessionListener?.(this.active());
40825
+ const verdict = this.sessionListener?.({ ...this.active(), pairingId });
40826
+ if (verdict === false) {
40827
+ this.session = previous;
40828
+ void this.client.disconnect({ topic: session.topic, reason: { code: 6e3, message: "session refused by the bridge" } }).catch(() => void 0);
40829
+ }
40790
40830
  }).catch((e) => console.error(`[dh-mcp] WalletConnect pairing failed: ${e.message}`));
40791
- return { uri };
40831
+ return { uri, pairingId };
40792
40832
  }
40793
40833
  /** Route one wallet request over the active session. Throws on user rejection. */
40794
40834
  async request(method, params) {
@@ -40823,6 +40863,7 @@ var import_node_crypto8 = require("crypto");
40823
40863
  var fs5 = __toESM(require("fs"));
40824
40864
  var os2 = __toESM(require("os"));
40825
40865
  var path4 = __toESM(require("path"));
40866
+ var import_ethers51 = require("ethers");
40826
40867
 
40827
40868
  // src/boundary/envelope.ts
40828
40869
  function okEnvelope(data, source, warnings = []) {
@@ -43321,8 +43362,13 @@ var SignerManager = class {
43321
43362
  mode: deps.initialMode,
43322
43363
  borrower: deps.configuredBorrower ?? null
43323
43364
  };
43365
+ if (deps.authenticatedBorrower) this.state = { ...this.state, borrower: deps.authenticatedBorrower };
43324
43366
  }
43325
43367
  state;
43368
+ /** True when the borrower is the signed-in identity and cannot be swapped. */
43369
+ identityPinned() {
43370
+ return this.deps.authenticatedBorrower !== void 0;
43371
+ }
43326
43372
  mode() {
43327
43373
  return this.state.mode;
43328
43374
  }
@@ -43362,7 +43408,7 @@ var SignerManager = class {
43362
43408
  this.deps.persistence.save(this.state);
43363
43409
  }
43364
43410
  resetBorrower() {
43365
- this.state = { ...this.state, borrower: null };
43411
+ this.state = { ...this.state, borrower: this.deps.authenticatedBorrower ?? null };
43366
43412
  this.deps.persistence.save(this.state);
43367
43413
  }
43368
43414
  async use(mode, opts) {
@@ -51742,11 +51788,11 @@ var init_deployment_addresses = __esm2({
51742
51788
  reason: "Shared upgrade script: AdminModule implementation update"
51743
51789
  },
51744
51790
  PositionManagerViews: {
51745
- previousImplementation: "0x1EB2B1d058006ACd9033E01e846D73eDE686b620",
51746
- newImplementation: "0xA455B542cFb36AF8451fc420dB89e590E5c87cef",
51747
- upgradedAt: "2026-07-03T20:11:25.817Z",
51748
- upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
51749
- reason: "Shared upgrade script: PositionManagerViews implementation update"
51791
+ previousImplementation: "0xA455B542cFb36AF8451fc420dB89e590E5c87cef",
51792
+ newImplementation: "0x8cEB3F1c07fDB3301f55b96a5B9aDb33C8d36Da3",
51793
+ upgradedAt: "2026-10-02T17:04:25.853Z",
51794
+ upgradedBy: "0x0f8f23674cc90Ef7107930a4437341fD8B460362",
51795
+ reason: "1.1.2: getBackingVaults (PoR backing set) + implementation lock (constructor)"
51750
51796
  },
51751
51797
  TestPositionManager: {
51752
51798
  previousImplementation: "0x0B46Ee1a9C6b42559758B7FF78294Cd867BB08f8",
@@ -53206,6 +53252,32 @@ var require_pkg_src2 = __commonJS2({
53206
53252
  deployedAt: 1790246264563,
53207
53253
  size: 69219,
53208
53254
  hash: "bda048d8cd6b5a39c2774bcf1320e82d1eea935c2a521006fb8b887e13b6dd8d"
53255
+ },
53256
+ carryCollateralAttestation: {
53257
+ cid: "QmYWULmXD9S5AmTdQqWqoZ28ctsZQNcXkAgre9G2Xo9dh8",
53258
+ authorizedCidHex: cidToHex(
53259
+ "QmYWULmXD9S5AmTdQqWqoZ28ctsZQNcXkAgre9G2Xo9dh8"
53260
+ ),
53261
+ name: "Carry Collateral Attestation",
53262
+ description: "LoanCarryVault collateral attestation (borrower, BTC vault, confirmed BTC)",
53263
+ version: "1.0.0",
53264
+ deployed: true,
53265
+ deployedAt: 1790927734070,
53266
+ size: 21156,
53267
+ hash: "05b177e0bb36b0483db4a42d33c1bbbf47eb9ef34ae278459397d51a7f8957ff"
53268
+ },
53269
+ carryFundingAttestation: {
53270
+ cid: "QmWhox3xUZMNR5NpPZ9WLSPC5GoW4ms88GanVRKr8uuS3W",
53271
+ authorizedCidHex: cidToHex(
53272
+ "QmWhox3xUZMNR5NpPZ9WLSPC5GoW4ms88GanVRKr8uuS3W"
53273
+ ),
53274
+ name: "Carry Funding Attestation",
53275
+ description: "LoanCarryVault funding attestation (Hyperliquid BTC windowed hourly average)",
53276
+ version: "1.0.0",
53277
+ deployed: true,
53278
+ deployedAt: 1790925699980,
53279
+ size: 7193,
53280
+ hash: "4944ada61610cf64b32e33b5be62087088dcf5e821040c69e67942e643ce74c9"
53209
53281
  }
53210
53282
  };
53211
53283
  function getDeploymentsForNetwork(network) {
@@ -82616,7 +82688,7 @@ var RealUpstreamPlugin = class {
82616
82688
  }
82617
82689
  if (mode === "external") {
82618
82690
  const borrower = await rt.manager.resolveBorrowerForWrite();
82619
- if (!borrower) {
82691
+ if (!borrower || this.pinnedWalletUnreachable(borrower, { allowCachedLogin: false })) {
82620
82692
  return {
82621
82693
  ok: false,
82622
82694
  failure: {
@@ -82666,6 +82738,20 @@ var RealUpstreamPlugin = class {
82666
82738
  }
82667
82739
  };
82668
82740
  }
82741
+ /** Hosted tier: the SIWE borrower is bound from boot, so "bound" no longer implies a
82742
+ * wallet can sign. Refuse as "no wallet is connected" instead of starting a ceremony
82743
+ * nobody can answer.
82744
+ *
82745
+ * `allowCachedLogin` is for `connectExternal` ONLY: a still-valid lit-ops login lets it
82746
+ * succeed without a wallet (it signs nothing). A WRITE always needs a fresh wallet
82747
+ * signature (ExternalEoaDHSigner), so a cached JWT must not admit it — that would queue
82748
+ * an approval with no wallet attached to sign it. */
82749
+ pinnedWalletUnreachable(borrower, opts) {
82750
+ if (!this.runtime?.manager.identityPinned()) return false;
82751
+ if (this.runtime.bridge.walletState() !== null) return false;
82752
+ if (!opts.allowCachedLogin) return true;
82753
+ return !this.sessionCache.get(`external:${borrower.toLowerCase()}`)?.hasValidToken();
82754
+ }
82669
82755
  /** The EXPLICIT login action (plan 10 OV-10 / A0.7): the ONLY path that may summon the
82670
82756
  * wallet for a lit-ops login outside a write ceremony. Binds the borrower on success —
82671
82757
  * the first verified ceremony fixes the identity. */
@@ -82676,7 +82762,7 @@ var RealUpstreamPlugin = class {
82676
82762
  return { ok: false, reason: `the active mode is '${manager.mode()}' \u2014 run signer_setup action 'use' mode 'external' first` };
82677
82763
  }
82678
82764
  const borrower = manager.borrowerForWrite();
82679
- if (!borrower) {
82765
+ if (!borrower || this.pinnedWalletUnreachable(borrower, { allowCachedLogin: true })) {
82680
82766
  return { ok: false, reason: "no wallet is connected \u2014 open the approval page (signer_setup action 'status') and connect your wallet first" };
82681
82767
  }
82682
82768
  const key = `external:${borrower.toLowerCase()}`;
@@ -83213,6 +83299,81 @@ var RealUpstreamPlugin = class {
83213
83299
  var fs4 = __toESM(require("fs"));
83214
83300
  var http3 = __toESM(require("http"));
83215
83301
  var import_node_crypto7 = require("crypto");
83302
+ var import_ethers50 = require("ethers");
83303
+
83304
+ // src/util/brand-assets.ts
83305
+ var FAVICON_SVG = `<svg width="512" height="512" viewBox="-6 -11 88 88" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Diamond Hands"><path d="M1.08325 20.7041L37.9038 64.4967L74.2886 20.7041L61.8699 0.877686H13.502L1.08325 20.7041Z" fill="#C9F284" stroke="#34440E" stroke-width="1.75559"/><path d="M13.9385 0.877441L37.9045 64.2785" stroke="#34440E" stroke-width="1.75559"/><path d="M61.6553 0.877441L37.9071 64.4964" stroke="#34440E" stroke-width="1.75559"/><path d="M1.08276 20.7029H74.2882" stroke="#34440E" stroke-width="1.75559"/></svg>`;
83306
+ var FAVICON_DATA_URI = `data:image/svg+xml,${encodeURIComponent(FAVICON_SVG).replace(/'/g, "%27")}`;
83307
+ var GVNR_PILL_LOGO_DATA_URI = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAACXCAYAAABjhOMoAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnr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K/0MaPTqH+oMBv4zWrpBnVcxWDDloY6giAIQq1xCJvDgp3hnBilrLrY4Kj1IgiCIAiCkBR+f78oi7fKHtBH1S9ruOiL3lzmshxBEARBSI3R7o2jZc39MsCRvujLXpYjCIIgCCnhT/xbF1+MjDQvBMClvuhLO6hDEARBEFLicsMufW4uZhoUAoDaUo4Op/BRgEpGEwqCIAiCEI7Rhl0002S0v8RFJ0CjVqipx9ALsHFidkUECIIgCEJN+ad5+ni0e+Po6Z+4EAAUBbAjc6oR8UHZowkFQRAEQVick/ynTYtuZ/i1debJ5e6SX8zxujTukHU0oSAIgiAIYaFW3S4DCv0PG9cdrant9uXnfTEMKMdsdDhKMZrwJN+V/gCCIAiCEDlk4h/d/Gk/zz6ZsVMnvxAAlArQaO6NigBU+Ip7KpEgCIIgCNfn2Ow+yLT+bPOnaaaTBkvhpB9EA3KM029HJ+U5cF1j7P12Q2ajC4IgCEIM0Kl/0MOnM3xs2uY/eM5kSATkLns54gkYcpAb80SEgCAIgiBUw7iNn/AH93eNT2Zr2kjpKwXAEJoDDYhfpAAoIgAOD8CZd8baI2j0ZKytIAiCIASGptNCr9HSqrHh0G4oVFSld2lkPZ6hs09W9aPns/zMmQQAQdGAnlU7ONJRSBAEQRCEKHidfTIPp536R5lZAAwZCgGFeHfUHyAIgiAIQpngmXXml5Vz93yejf/iv4YFOHVPO9bCBiJ5BLDlf9g3PjHQBEEQBEEQAoI+ve5+8wfvI+dT70rB0RoW03wFQRAEQRBm5/8BP0+mvgFrTN4AAAAASUVORK5CYII=";
83308
+
83309
+ // src/util/house-style.ts
83310
+ var APP_BACKGROUND_ORIGIN = "https://images.diamondhands.credit";
83311
+ var APP_BACKGROUND_URL = `${APP_BACKGROUND_ORIGIN}/bg-diamond-hands.png`;
83312
+ var FONT_ORIGIN = "https://images.gvnr.xyz";
83313
+ var MANROPE_BASE = `${FONT_ORIGIN}/fonts/manrope`;
83314
+ var HOUSE_CSP_EXTRA = {
83315
+ "img-src": [APP_BACKGROUND_ORIGIN, "data:"],
83316
+ "font-src": [FONT_ORIGIN]
83317
+ };
83318
+ var HOUSE_HEAD_LINKS = `<link rel="icon" type="image/svg+xml" href="${FAVICON_DATA_URI}">
83319
+ <link rel="apple-touch-icon" href="${FAVICON_DATA_URI}">`;
83320
+ var MANROPE_WEIGHTS = [
83321
+ [300, "Light"],
83322
+ [400, "Regular"],
83323
+ [500, "Medium"],
83324
+ [600, "SemiBold"],
83325
+ [700, "Bold"]
83326
+ ];
83327
+ var HOUSE_BASE_CSS = `
83328
+ ${MANROPE_WEIGHTS.map(([w, n]) => `@font-face { font-family: "Manrope"; font-weight: ${w}; font-display: swap; src: url("${MANROPE_BASE}/Manrope-${n}.ttf") format("truetype"); }`).join("\n")}
83329
+ * { box-sizing: border-box; }
83330
+ html { min-height: 100%; background: #000006; }
83331
+ body { margin: 0; min-height: 100vh; color: #fff; font: 14px/1.5 "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
83332
+ background: #000006 url("${APP_BACKGROUND_URL}") center / cover no-repeat fixed; }
83333
+ .house-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem; }
83334
+ @media (min-width: 768px) { .house-header { padding: 1rem 2.5rem; } }
83335
+ .house-header > img { height: 1.92rem; width: auto; display: block; flex: none; }
83336
+ /* Narrow viewports: the chip may shrink (its label ellipsises), and below 400px the label
83337
+ is dropped so logo + chip icon always fit a 320px phone with no horizontal page scroll. */
83338
+ .house-header .chip { min-width: 0; }
83339
+ .chip-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
83340
+ /* ".house-header .chip", not ".chip": the base .chip rule below declares padding too, and at
83341
+ equal specificity the LATER rule wins regardless of the media query; this selector outranks it. */
83342
+ @media (max-width: 400px) { .chip-label { display: none; } .house-header .chip { padding: 0.4rem 0.6rem; } }
83343
+ .chip { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.4rem 0.85rem; border-radius: 999px;
83344
+ background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(255, 255, 255, 0.1); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
83345
+ font-size: 0.8rem; font-weight: 600; color: #dbff91; white-space: nowrap; }
83346
+ .chip img { height: 1rem; }
83347
+ main { max-width: 34rem; margin: 2.5rem auto 3rem; padding: 0 1rem; }
83348
+ .panel { background: #121212; border: 1px solid rgba(255, 255, 255, 0.06); border-radius: 12px; padding: 1rem;
83349
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05); }
83350
+ @media (min-width: 768px) { .panel { padding: 1.25rem; } }
83351
+ h1 { font-size: 1.25rem; font-weight: 600; line-height: 1.375; color: #fafafa; margin: 0 0 1rem; }
83352
+ @media (min-width: 768px) { h1 { font-size: 1.5rem; margin-bottom: 1.25rem; } }
83353
+ h2 { font-size: 1rem; font-weight: 600; line-height: 1.375; color: #fafafa; margin: 0 0 0.75rem; }
83354
+ p { margin: 0 0 1rem; color: #e5e5e5; font-size: 0.875rem; font-weight: 300; line-height: 1.5; }
83355
+ button { font: inherit; font-size: 0.875rem; cursor: pointer; border: 0; display: inline-flex; align-items: center; justify-content: center;
83356
+ min-height: 2.75rem; padding: 0.65rem 1.25rem; transition: opacity 0.2s, background-color 0.2s; }
83357
+ button:focus-visible { outline: 2px solid #84cc16; outline-offset: 2px; }
83358
+ button:disabled { opacity: 0.5; cursor: not-allowed; }
83359
+ /* Primary = lime-700 (#4d7c0f): white 14px text on it is 4.99:1 (WCAG AA needs 4.5:1; the
83360
+ brighter #65a30d was 3.09:1). Hover = lime-800 (#3f6212), 7.08:1. A test recomputes both. */
83361
+ .btn-primary { background: #4d7c0f; color: #fff; font-weight: 700; letter-spacing: 0.025em; border-radius: 12px; box-shadow: 0 4px 18px rgba(74, 222, 128, 0.2); }
83362
+ .btn-primary:hover:not(:disabled) { background: #3f6212; }
83363
+ .btn-secondary { background: #34440e; color: #dbff91; font-weight: 500; border-radius: 20px; }
83364
+ .btn-secondary:hover:not(:disabled) { background: #3d5210; }
83365
+ .btn-danger { background: transparent; color: #fca5a5; font-weight: 600; border-radius: 12px; border: 1px solid rgba(248, 113, 113, 0.45); }
83366
+ .btn-danger:hover:not(:disabled) { background: rgba(220, 38, 38, 0.15); }
83367
+ /* A QR needs dark-on-light to scan: it keeps a white plate on the dark page. */
83368
+ .qr-plate { max-width: 16rem; margin-top: 1rem; background: #fff; border-radius: 12px; padding: 0.5rem; }
83369
+ .qr-plate svg { width: 100%; height: auto; display: block; }
83370
+ `;
83371
+ function houseHeader(label) {
83372
+ return `<header class="house-header">
83373
+ <img src="${GVNR_PILL_LOGO_DATA_URI}" alt="GVNR">
83374
+ <span class="chip"><img src="${FAVICON_DATA_URI}" alt=""><span class="chip-label">${label}</span></span>
83375
+ </header>`;
83376
+ }
83216
83377
 
83217
83378
  // src/boundary/upstream/shared/external-bridge/approval-page.ts
83218
83379
  function renderApprovalPage(sessionId, nonce) {
@@ -83222,46 +83383,47 @@ function renderApprovalPage(sessionId, nonce) {
83222
83383
  <meta charset="utf-8">
83223
83384
  <meta name="viewport" content="width=device-width, initial-scale=1">
83224
83385
  <title>Diamond Hands \u2014 signature approval</title>
83386
+ ${HOUSE_HEAD_LINKS}
83225
83387
  <style>
83226
- :root { --bg:#0d1117; --panel:#161b22; --line:#30363d; --text:#e6edf3; --dim:#8b949e;
83227
- --accent:#58a6ff; --approve:#238636; --reject:#da3633; }
83228
- * { box-sizing:border-box; }
83229
- body { margin:0; font:15px/1.5 system-ui,sans-serif; background:var(--bg); color:var(--text);
83230
- display:flex; min-height:100vh; align-items:center; justify-content:center; }
83231
- main { width:min(560px,94vw); }
83232
- h1 { font-size:18px; font-weight:600; letter-spacing:.02em; }
83233
- h1 span { color:var(--accent); }
83234
- .panel { background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:20px; margin-top:12px; }
83235
- .status { color:var(--dim); font-size:13px; }
83236
- .card { white-space:pre-wrap; font-family:ui-monospace,monospace; font-size:14px;
83237
- background:var(--bg); border:1px solid var(--line); border-radius:8px; padding:14px; margin:14px 0; }
83238
- .action { text-transform:uppercase; letter-spacing:.08em; font-size:12px; color:var(--accent); }
83239
- button { border:0; border-radius:8px; padding:10px 22px; font-size:15px; color:#fff; cursor:pointer; }
83240
- #approve { background:var(--approve); margin-right:10px; }
83241
- #reject { background:var(--reject); }
83242
- #wallet { font-family:ui-monospace,monospace; font-size:12px; color:var(--dim); margin-top:10px; }
83388
+ ${HOUSE_BASE_CSS}
83389
+ /* \u2500\u2500 approval page only \u2500\u2500 */
83390
+ main { max-width: 36rem; }
83391
+ .status { color:#a1a1a1; font-size:0.875rem; }
83392
+ .action { text-transform:uppercase; letter-spacing:.08em; font-size:0.75rem; font-weight:600; color:#dbff91; margin-top:0.25rem; }
83393
+ /* The decoded card IS the operation (decode-equivalence): kept monospace and pre-wrapped
83394
+ exactly as the server rendered it, on an inset well darker than the panel. */
83395
+ .card { white-space:pre-wrap; font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:0.875rem; color:#fafafa;
83396
+ background:#0a0a0a; border:1px solid rgba(255,255,255,0.1); border-radius:10px; padding:14px; margin:0.75rem 0 1rem; }
83397
+ .actions { display:flex; flex-wrap:wrap; gap:0.75rem; }
83398
+ #deadline { margin-bottom:1rem; }
83399
+ #wallet { font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:0.75rem; color:#a1a1a1; margin-top:1rem; }
83400
+ #wallet:empty { display:none; }
83401
+ #wc { margin-top:1.25rem; border-top:1px solid rgba(255,255,255,0.06); padding-top:1rem; }
83402
+ #wc-uri { user-select:all; word-break:break-all; font-size:0.75rem; }
83403
+ #wc-hint { margin-top:0.75rem; }
83243
83404
  .hidden { display:none; }
83244
83405
  </style>
83245
83406
  </head>
83246
83407
  <body>
83408
+ ${houseHeader("Diamond Hands \xB7 signature approval")}
83247
83409
  <main>
83248
- <h1><span>\u25C6</span> Diamond Hands \u2014 signature approval</h1>
83410
+ <h1>Signature approval</h1>
83249
83411
  <div class="panel">
83250
83412
  <div id="status" class="status">Connecting to your wallet\u2026</div>
83251
83413
  <div id="request" class="hidden">
83252
83414
  <div id="action" class="action"></div>
83253
83415
  <div id="card" class="card"></div>
83254
83416
  <div id="deadline" class="status hidden"></div>
83255
- <button id="approve">Approve in wallet</button>
83256
- <button id="reject">Reject</button>
83417
+ <div class="actions">
83418
+ <button id="approve" class="btn-primary">Approve in wallet</button>
83419
+ <button id="reject" class="btn-danger">Reject</button>
83420
+ </div>
83257
83421
  </div>
83258
83422
  <div id="wallet"></div>
83259
- <div id="wc" style="margin-top:14px; border-top:1px solid var(--line); padding-top:12px;">
83260
- <button id="wc-connect" style="background:var(--panel); border:1px solid var(--line); color:var(--text);">
83261
- Use a mobile wallet instead (WalletConnect)
83262
- </button>
83263
- <div id="wc-qr" class="hidden" style="background:#fff; border-radius:8px; padding:8px; margin-top:10px; max-width:280px;"></div>
83264
- <div id="wc-uri" class="card hidden" style="user-select:all; word-break:break-all; font-size:12px;"></div>
83423
+ <div id="wc">
83424
+ <button id="wc-connect" class="btn-secondary">Use a mobile wallet instead (WalletConnect)</button>
83425
+ <div id="wc-qr" class="qr-plate hidden"></div>
83426
+ <div id="wc-uri" class="card hidden"></div>
83265
83427
  <div id="wc-hint" class="status hidden">Scan the QR with your wallet app (or open the app \u2192 WalletConnect \u2192 paste the pairing code). Approvals then happen on your phone.</div>
83266
83428
  </div>
83267
83429
  </div>
@@ -83336,21 +83498,63 @@ async function healChain() {
83336
83498
  }).catch(() => undefined);
83337
83499
  }
83338
83500
  await readWallet();
83339
- await post(BASE + "hello", { account: account, chainId: chainId });
83501
+ await sayHello();
83340
83502
  showWallet();
83341
83503
  }
83342
83504
 
83505
+ function utf8Hex(text) {
83506
+ return "0x" + Array.from(new TextEncoder().encode(text)).map((b) => b.toString(16).padStart(2, "0")).join("");
83507
+ }
83508
+
83509
+ // Presence proof: the bridge only believes a wallet is at this page once the wallet has
83510
+ // SIGNED a short statement naming this page's origin, the chain and a per-page nonce. Saying
83511
+ // an address proves nothing (it is public); signing proves the key is here. One prompt per
83512
+ // page session: once this account has proven itself the bridge accepts later hellos for it
83513
+ // (a chain switch) without asking the wallet again.
83514
+ let provenFor = null;
83515
+ async function sayHello() {
83516
+ let signature;
83517
+ if (provenFor === null || provenFor.toLowerCase() !== String(account).toLowerCase()) {
83518
+ const ch = await fetch(BASE + "challenge?s=" + SESSION + "&chainId=" + chainId).then((r) => r.json());
83519
+ showIdleStatus("Sign the short statement in your wallet to prove it is yours \u2014 it moves no funds.");
83520
+ signature = await window.ethereum.request({ method: "personal_sign", params: [utf8Hex(ch.statement), account] });
83521
+ }
83522
+ const r = await post(BASE + "hello", { account: account, chainId: chainId, signature: signature });
83523
+ if (!r.ok) {
83524
+ const b = await r.json().catch(() => ({}));
83525
+ showStatus("This wallet was not accepted: " + (b.error || "HTTP " + r.status));
83526
+ return false;
83527
+ }
83528
+ provenFor = account;
83529
+ return true;
83530
+ }
83531
+
83532
+ // The stream opens at load, so a card can be on screen BEFORE connect() finishes. The status
83533
+ // line then belongs to that card (its review / mobile-wallet guidance), and connection
83534
+ // progress must not overwrite it. Connection progress lines (idle / "sign the statement", whose
83535
+ // wallet popup is self-explanatory) go through here; failures (a refused hello, a lost
83536
+ // stream, a wrong network) still show unconditionally.
83537
+ function showIdleStatus(text) {
83538
+ if (current !== null) return;
83539
+ showStatus(text);
83540
+ }
83541
+
83343
83542
  async function connect() {
83344
- if (!window.ethereum) { showStatus("No wallet detected \u2014 install MetaMask (or open this page in a wallet browser)."); return; }
83543
+ if (!window.ethereum) {
83544
+ // The event stream is already open (see the bottom of this script) \u2014 a phone paired
83545
+ // below still mirrors its cards here.
83546
+ showIdleStatus("No browser wallet detected \u2014 use the mobile wallet option below, or install MetaMask (or open this page in a wallet browser).");
83547
+ return;
83548
+ }
83345
83549
  await window.ethereum.request({ method: "eth_requestAccounts" });
83346
83550
  await readWallet();
83347
- await post(BASE + "hello", { account: account, chainId: chainId });
83551
+ const accepted = await sayHello();
83348
83552
  showWallet();
83349
83553
  window.ethereum.on("accountsChanged", onAccountsChanged);
83350
83554
  window.ethereum.on("chainChanged", onChainChanged);
83555
+ if (!accepted) return;
83351
83556
  await healChain();
83352
- showStatus("Connected. Waiting for a signature request\u2026");
83353
- listen();
83557
+ showIdleStatus("Connected. Waiting for a signature request\u2026");
83354
83558
  }
83355
83559
 
83356
83560
  // Handlers trust the EVENT payloads \u2014 re-reading eth_accounts/eth_chainId here races the
@@ -83360,6 +83564,8 @@ async function onAccountsChanged(accounts) {
83360
83564
  await post(BASE + "wallet-event", { account: account, chainId: chainId });
83361
83565
  showWallet();
83362
83566
  invalidatePageRequests("Wallet changed \u2014 pending request invalidated.");
83567
+ // The bridge adopts no account from an event alone \u2014 a different account proves itself.
83568
+ if (account) await sayHello();
83363
83569
  }
83364
83570
 
83365
83571
  async function onChainChanged(cid) {
@@ -83369,8 +83575,14 @@ async function onChainChanged(cid) {
83369
83575
  invalidatePageRequests("Network changed \u2014 pending request invalidated.");
83370
83576
  }
83371
83577
 
83578
+ // ONE stream per page, opened at load whatever wallet this browser has: a phone paired
83579
+ // through WalletConnect needs no injected wallet, and its read-only mirror arrives on this
83580
+ // stream. Opening it proves nothing \u2014 the bridge sends this page NOTHING until a person is
83581
+ // proven (a signed hello, or a pairing a phone answered).
83582
+ let es = null;
83372
83583
  function listen() {
83373
- const es = new EventSource(BASE + "events?s=" + SESSION);
83584
+ if (es !== null) return;
83585
+ es = new EventSource(BASE + "events?s=" + SESSION);
83374
83586
  es.onmessage = (ev) => {
83375
83587
  const next = JSON.parse(ev.data);
83376
83588
  // A later frame for an id REPLACES the earlier one: driveWc re-stamps a personal-sign
@@ -83562,6 +83774,7 @@ document.getElementById("wc-connect").onclick = async () => {
83562
83774
  showStatus("Scan the QR (or paste the code) in your mobile wallet \u2014 it becomes the signing wallet.");
83563
83775
  };
83564
83776
 
83777
+ listen();
83565
83778
  connect();
83566
83779
  </script>
83567
83780
  </body>
@@ -83670,6 +83883,16 @@ function htmlPageSecurityHeaders(extra) {
83670
83883
 
83671
83884
  // src/boundary/upstream/shared/external-bridge/bridge.ts
83672
83885
  var MAX_SESSIONS = 16;
83886
+ var MAX_PENDING_PAIRINGS = 64;
83887
+ function presenceStatement(origin2, chainId, nonce) {
83888
+ return [
83889
+ "Diamond Hands approval page",
83890
+ "Sign to prove this wallet is yours. This moves no funds and approves no operation.",
83891
+ `Origin: ${origin2}`,
83892
+ `Chain ID: ${chainId}`,
83893
+ `Session nonce: ${nonce}`
83894
+ ].join("\n");
83895
+ }
83673
83896
  var DEFAULT_EXPIRY_MS = 5 * 60 * 1e3;
83674
83897
  var DEFAULT_ATTACH_GRACE_MS = 60 * 1e3;
83675
83898
  var DEFAULT_HOSTED_ATTACH_GRACE_MS = 180 * 1e3;
@@ -83683,6 +83906,7 @@ function wcDeclineOrFault(e) {
83683
83906
  }
83684
83907
  var SignatureBridge = class {
83685
83908
  clock;
83909
+ sweepIntervalMs;
83686
83910
  /** Lowercased at construction so every comparison is case-flat — EIP-55 checksum casing
83687
83911
  * differs between what SIWE signs and what a wallet reports for the SAME address. */
83688
83912
  boundAccount;
@@ -83713,13 +83937,20 @@ var SignatureBridge = class {
83713
83937
  wcTransport = null;
83714
83938
  /** True while a WalletConnect session is THE wallet — ceremonies route over WC. */
83715
83939
  wcActive = false;
83716
- /** Page session that most recently asked for a pairing QR — see `serveWcPairing`. */
83717
- pairingSessionId = null;
83940
+ /** Which page session asked for which pairing (pairing id → session id). The transport's
83941
+ * `onSession` says WHICH PAIRING a phone answered; this says whose it was. The previous
83942
+ * "most recent asker" guess let a second session claim the credit for a QR the user's
83943
+ * phone scanned (Sentinel 2 PoC-B). */
83944
+ pairingOwners = /* @__PURE__ */ new Map();
83718
83945
  keystoreUnlock;
83719
83946
  unlockToken = null;
83720
83947
  unlockSession = null;
83721
83948
  constructor(opts) {
83722
83949
  this.clock = opts?.clock ?? Date.now;
83950
+ this.sweepIntervalMs = opts?.sweepIntervalMs ?? 1e3;
83951
+ if (!Number.isInteger(this.sweepIntervalMs) || this.sweepIntervalMs < 0) {
83952
+ throw new Error(`bridge sweepIntervalMs must be a non-negative integer (got ${String(opts?.sweepIntervalMs)})`);
83953
+ }
83723
83954
  this.boundAccount = opts?.boundAccount?.toLowerCase();
83724
83955
  this.expiryMs = opts?.expiryMs ?? DEFAULT_EXPIRY_MS;
83725
83956
  this.maxPending = opts?.maxPending ?? null;
@@ -83755,8 +83986,10 @@ var SignatureBridge = class {
83755
83986
  this.server = server;
83756
83987
  }
83757
83988
  this.started = true;
83758
- this.sweepTimer = setInterval(() => this.sweep(), 1e3);
83759
- this.sweepTimer.unref();
83989
+ if (this.sweepIntervalMs > 0) {
83990
+ this.sweepTimer = setInterval(() => this.sweep(), this.sweepIntervalMs);
83991
+ this.sweepTimer.unref();
83992
+ }
83760
83993
  if (this.urlFile) fs4.writeFileSync(this.urlFile, this.url());
83761
83994
  }
83762
83995
  /** Plan 12 C1: the outer server's dispatch entry for a MOUNTED bridge — `req.url`
@@ -83816,6 +84049,16 @@ var SignatureBridge = class {
83816
84049
  pendingCount() {
83817
84050
  return this.pending.size;
83818
84051
  }
84052
+ /** A request lives for the bridge's expiry OR until its payload dies, whichever is first.
84053
+ * The BTC-withdraw execute leg's payload dies inside a sub-minute quantum window; holding
84054
+ * the ceremony open for the full five minutes kept a dead card on screen and let the phone
84055
+ * be asked to sign something the protocol would refuse. */
84056
+ deadlineFor(request, nowMs) {
84057
+ const bridgeDeadline = nowMs + this.expiryMs;
84058
+ if (request.expiresAtSec === void 0) return bridgeDeadline;
84059
+ if (!Number.isFinite(request.expiresAtSec)) throw new Error(`request ${request.id} carries a non-finite expiresAtSec`);
84060
+ return Math.min(bridgeDeadline, request.expiresAtSec * 1e3);
84061
+ }
83819
84062
  /**
83820
84063
  * Enqueue a request and resolve on the human's decision (or expiry/invalidation).
83821
84064
  * Chain-id mismatch with an already-connected wallet refuses BEFORE the wallet is asked.
@@ -83838,7 +84081,7 @@ var SignatureBridge = class {
83838
84081
  const now = this.clock();
83839
84082
  const entry = {
83840
84083
  request,
83841
- deadlineMs: now + this.expiryMs,
84084
+ deadlineMs: this.deadlineFor(request, now),
83842
84085
  enqueuedMs: now,
83843
84086
  resolve,
83844
84087
  settled: false,
@@ -83869,7 +84112,7 @@ var SignatureBridge = class {
83869
84112
  const now = this.clock();
83870
84113
  const entry = {
83871
84114
  request,
83872
- deadlineMs: now + this.expiryMs,
84115
+ deadlineMs: this.deadlineFor(request, now),
83873
84116
  enqueuedMs: now,
83874
84117
  resolve,
83875
84118
  settled: false,
@@ -83921,6 +84164,7 @@ var SignatureBridge = class {
83921
84164
  return;
83922
84165
  }
83923
84166
  try {
84167
+ if (this.expireIfOverdue(entry)) return;
83924
84168
  if (req.kind === "transaction") {
83925
84169
  this.pushEntry(entry);
83926
84170
  const tx2 = req.tx;
@@ -83932,15 +84176,23 @@ var SignatureBridge = class {
83932
84176
  } else if (req.kind === "personal-sign") {
83933
84177
  if (entry.finalize) {
83934
84178
  const fresh = await entry.finalize();
84179
+ if (entry.settled) return;
84180
+ if (entry.owner !== "wc") return;
84181
+ const live = transport.active();
84182
+ if (!this.wcActive || !live || live.account.toLowerCase() !== account.toLowerCase()) {
84183
+ this.settle(entry, {
84184
+ status: "invalidated",
84185
+ reason: "the WalletConnect wallet changed while this payload was being prepared \u2014 the phone was not asked. Reconnect your wallet and retry the operation."
84186
+ });
84187
+ return;
84188
+ }
83935
84189
  req.personalSign = fresh.personalSign;
83936
84190
  req.card = fresh.card;
83937
84191
  }
84192
+ if (this.expireIfOverdue(entry)) return;
83938
84193
  const ps = req.personalSign;
83939
- if (ps.layout === RAW_HASH_LAYOUT && !this.pageAttached()) {
83940
- this.settle(entry, {
83941
- status: "invalidated",
83942
- reason: `this step signs a 32-byte hash your wallet cannot decode, and no approval page is open to show you what it authorizes \u2014 open ${this.url()} and re-run the withdrawal with loan_withdraw_retry (it re-signs with a fresh stamp; your coins stay in the vault meanwhile)`
83943
- });
84194
+ if (!this.pageAttached()) {
84195
+ this.settle(entry, { status: "invalidated", reason: this.noPageReason(ps.layout === RAW_HASH_LAYOUT) });
83944
84196
  return;
83945
84197
  }
83946
84198
  this.pushEntry(entry);
@@ -83965,6 +84217,16 @@ var SignatureBridge = class {
83965
84217
  }
83966
84218
  }
83967
84219
  }
84220
+ /** Refusal for a WalletConnect personal_sign with no proven approval page attached.
84221
+ *
84222
+ * The remedy names BOTH halves, because opening the link alone does not fix it: a freshly
84223
+ * opened page is a stranger until a phone answers a pairing it showed (or its wallet signs
84224
+ * the presence statement), so it receives no card. Following "just reopen the URL" looped
84225
+ * (Sentinel 2 PoC-C). */
84226
+ noPageReason(blindHash) {
84227
+ const what = blindHash ? "this step signs a 32-byte hash your wallet cannot decode" : "this step asks your wallet to sign a message your phone shows only as a hash";
84228
+ return `${what}, and no approval page linked to your wallet is open to show you what it authorizes \u2014 open ${this.url()} in a browser AND, on that page, re-scan the WalletConnect QR with your phone (or reconnect your wallet there) so the page is tied to your wallet, then retry with loan_withdraw_retry for a withdrawal or re-run the operation (it re-signs with a fresh stamp; your coins stay in the vault meanwhile)`;
84229
+ }
83968
84230
  /** A live attachment that could still decide a request: an open approval-page SSE
83969
84231
  * stream (real page or headless driver) or an active WalletConnect session. PUBLIC
83970
84232
  * (plan 17 E1): the connector's idle-eviction predicate reads it — a tenant world
@@ -84048,6 +84310,7 @@ var SignatureBridge = class {
84048
84310
  void this.wcTransport?.close().catch(() => void 0);
84049
84311
  this.wcTransport = null;
84050
84312
  this.wcActive = false;
84313
+ this.pairingOwners.clear();
84051
84314
  }
84052
84315
  // ---- HTTP plumbing ----
84053
84316
  route(req, res) {
@@ -84055,6 +84318,7 @@ var SignatureBridge = class {
84055
84318
  const url2 = new URL(req.url ?? "/", this.mount ? this.mount.origin : `http://127.0.0.1:${this.port}`);
84056
84319
  if (req.method === "GET" && url2.pathname === "/") return this.servePage(url2, res);
84057
84320
  if (req.method === "GET" && url2.pathname === "/config") return this.serveConfig(url2, res);
84321
+ if (req.method === "GET" && url2.pathname === "/challenge") return this.serveChallenge(url2, res);
84058
84322
  if (req.method === "GET" && url2.pathname === "/wc-pairing") return void this.serveWcPairing(url2, res);
84059
84323
  if (req.method === "GET" && url2.pathname === "/unlock") return this.serveUnlockPage(url2, res);
84060
84324
  if (req.method === "POST" && url2.pathname === "/unlock-submit")
@@ -84114,8 +84378,16 @@ var SignatureBridge = class {
84114
84378
  return;
84115
84379
  }
84116
84380
  const sessionId = (0, import_node_crypto7.randomBytes)(24).toString("hex");
84117
- this.sessions.set(sessionId, { wallet: null, sse: null, refused: null, lastSeenMs: this.clock(), wcPaired: false });
84118
- const page = htmlPageSecurityHeaders();
84381
+ this.sessions.set(sessionId, {
84382
+ wallet: null,
84383
+ sse: null,
84384
+ refused: null,
84385
+ lastSeenMs: this.clock(),
84386
+ wcPaired: false,
84387
+ presenceNonce: (0, import_node_crypto7.randomBytes)(16).toString("hex"),
84388
+ provenAccount: null
84389
+ });
84390
+ const page = htmlPageSecurityHeaders(HOUSE_CSP_EXTRA);
84119
84391
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store", ...page.headers });
84120
84392
  res.end(renderApprovalPage(sessionId, page.nonce));
84121
84393
  }
@@ -84125,11 +84397,29 @@ var SignatureBridge = class {
84125
84397
  res.writeHead(200, { "Content-Type": "application/json", "Cache-Control": "no-store" });
84126
84398
  res.end(JSON.stringify({ network: this.network ?? null }));
84127
84399
  }
84400
+ /** The origin this bridge is served from — what a presence statement names. */
84401
+ publicOrigin() {
84402
+ return this.mount ? this.mount.origin : `http://127.0.0.1:${this.port}`;
84403
+ }
84404
+ /** The presence statement for this session + chain (session-gated). The page signs exactly
84405
+ * this text in its wallet; the bridge rebuilds it on `hello` rather than trusting any text
84406
+ * the client sends back. */
84407
+ serveChallenge(url2, res) {
84408
+ const session = this.sessionOf(url2.searchParams.get("s"), res);
84409
+ if (!session) return;
84410
+ const chainId = Number(url2.searchParams.get("chainId"));
84411
+ if (!Number.isInteger(chainId)) {
84412
+ this.deny(res, 400, "challenge requires an integer chainId");
84413
+ return;
84414
+ }
84415
+ res.writeHead(200, { "Content-Type": "application/json", "Cache-Control": "no-store" });
84416
+ res.end(JSON.stringify({ statement: presenceStatement(this.publicOrigin(), chainId, session.presenceNonce) }));
84417
+ }
84128
84418
  /** WalletConnect pairing (D2, session-gated): lazily boots the WC transport and serves a
84129
84419
  * fresh pairing URI. A wallet approving the pairing becomes THE wallet. */
84130
84420
  async serveWcPairing(url2, res) {
84131
84421
  if (!this.checkSession(url2.searchParams.get("s"), res)) return;
84132
- this.pairingSessionId = url2.searchParams.get("s");
84422
+ const askingSession = url2.searchParams.get("s");
84133
84423
  if (!this.wcConfig) {
84134
84424
  this.deny(res, 404, "WalletConnect is not configured (set DH_WC_PROJECT_ID)");
84135
84425
  return;
@@ -84144,17 +84434,20 @@ var SignatureBridge = class {
84144
84434
  this.wcTransport.onSession((info) => {
84145
84435
  const refusal = info ? this.accountRefusal(info.account) : null;
84146
84436
  if (info && refusal) {
84147
- this.wcActive = false;
84148
- this.rebuildSharedWallet();
84149
- this.demoteWcEntries();
84437
+ if (!this.wcActive) {
84438
+ this.rebuildSharedWallet();
84439
+ this.demoteWcEntries();
84440
+ }
84150
84441
  process.stderr.write(`[bridge] WalletConnect session refused \u2014 ${refusal}
84151
84442
  `);
84152
- return;
84443
+ return false;
84153
84444
  }
84154
84445
  this.wcActive = info !== null;
84155
84446
  this.wallet = info ? { account: info.account, chainId: info.chainId } : null;
84156
- if (info && this.pairingSessionId) {
84157
- const paired = this.sessions.get(this.pairingSessionId);
84447
+ if (info?.pairingId) {
84448
+ const owner = this.pairingOwners.get(info.pairingId);
84449
+ this.pairingOwners.delete(info.pairingId);
84450
+ const paired = owner ? this.sessions.get(owner) : void 0;
84158
84451
  if (paired) paired.wcPaired = true;
84159
84452
  }
84160
84453
  if (info === null) {
@@ -84169,7 +84462,15 @@ var SignatureBridge = class {
84169
84462
  }
84170
84463
  });
84171
84464
  }
84172
- const { uri } = await this.wcTransport.createPairing();
84465
+ const { uri, pairingId } = await this.wcTransport.createPairing();
84466
+ if (pairingId) {
84467
+ this.pairingOwners.set(pairingId, askingSession);
84468
+ while (this.pairingOwners.size > MAX_PENDING_PAIRINGS) {
84469
+ const oldest = this.pairingOwners.keys().next();
84470
+ if (oldest.done) break;
84471
+ this.pairingOwners.delete(oldest.value);
84472
+ }
84473
+ }
84173
84474
  const { default: qrcode } = await import("qrcode-generator");
84174
84475
  const qr = qrcode(0, "M");
84175
84476
  qr.addData(uri);
@@ -84257,6 +84558,34 @@ var SignatureBridge = class {
84257
84558
  this.deny(res, 403, refusal);
84258
84559
  return;
84259
84560
  }
84561
+ const alreadyProven = session.provenAccount !== null && session.provenAccount.toLowerCase() === account.toLowerCase();
84562
+ if (!alreadyProven) {
84563
+ const signature = body["signature"];
84564
+ if (typeof signature !== "string" || signature === "") {
84565
+ this.deny(
84566
+ res,
84567
+ 403,
84568
+ `hello requires a signature proving this page controls ${account} \u2014 an address alone proves nothing. Approve the short signing prompt in your wallet (the approval page asks for it on connect); reload the page if it did not appear.`
84569
+ );
84570
+ return;
84571
+ }
84572
+ const statement = presenceStatement(this.publicOrigin(), chainId, session.presenceNonce);
84573
+ let recovered = null;
84574
+ try {
84575
+ recovered = import_ethers50.ethers.verifyMessage(statement, signature);
84576
+ } catch {
84577
+ recovered = null;
84578
+ }
84579
+ if (recovered === null || recovered.toLowerCase() !== account.toLowerCase()) {
84580
+ this.deny(
84581
+ res,
84582
+ 403,
84583
+ `the presence signature was not made by ${account} for this page's statement \u2014 sign the statement the approval page shows with that account (EOA wallets only; contract wallets cannot prove presence here).`
84584
+ );
84585
+ return;
84586
+ }
84587
+ session.provenAccount = account;
84588
+ }
84260
84589
  session.wallet = { account, chainId };
84261
84590
  this.wallet = { account, chainId };
84262
84591
  this.replayPending(session);
@@ -84298,17 +84627,21 @@ var SignatureBridge = class {
84298
84627
  if (refusedSwitch) {
84299
84628
  this.quarantine(session, switchRefusal);
84300
84629
  } else {
84301
- session.wallet = offered;
84630
+ const sameProven = offered !== null && session.provenAccount !== null && offered.account.toLowerCase() === session.provenAccount.toLowerCase();
84631
+ session.wallet = sameProven ? offered : null;
84302
84632
  if (this.wallet !== null && prev !== null && this.wallet.account.toLowerCase() === prev.account.toLowerCase()) {
84303
84633
  this.wallet = session.wallet;
84634
+ } else if (this.wallet === null && prev === null && session.wallet !== null) {
84635
+ this.wallet = session.wallet;
84304
84636
  }
84305
84637
  }
84306
- const unchanged = prev !== null && session.wallet !== null && prev.account.toLowerCase() === session.wallet.account.toLowerCase() && prev.chainId === session.wallet.chainId;
84307
- if (unchanged) {
84638
+ const reported = refusedSwitch ? null : offered;
84639
+ const unchanged = prev !== null && reported !== null && prev.account.toLowerCase() === reported.account.toLowerCase() && prev.chainId === reported.chainId;
84640
+ if (unchanged || prev === null) {
84308
84641
  this.ok(res);
84309
84642
  return;
84310
84643
  }
84311
- const reason = refusedSwitch ? "the wallet switched to an account this session is not signed in as" : prev && session.wallet && prev.account.toLowerCase() !== session.wallet.account.toLowerCase() ? "the wallet account changed while approval was pending" : prev && session.wallet && prev.chainId !== session.wallet.chainId ? "the wallet network changed while approval was pending" : "the wallet disconnected while approval was pending";
84644
+ const reason = refusedSwitch ? "the wallet switched to an account this session is not signed in as" : prev && reported && prev.account.toLowerCase() !== reported.account.toLowerCase() ? "the wallet account changed while approval was pending" : prev && reported && prev.chainId !== reported.chainId ? "the wallet network changed while approval was pending" : "the wallet disconnected while approval was pending";
84312
84645
  for (const entry of this.pending.values()) {
84313
84646
  if (entry.settled || entry.collect) continue;
84314
84647
  if (this.ownedByWc(entry)) continue;
@@ -84351,6 +84684,10 @@ var SignatureBridge = class {
84351
84684
  this.deny(res, 404, "unknown or already-settled requestId");
84352
84685
  return;
84353
84686
  }
84687
+ if (this.expireIfOverdue(entry)) {
84688
+ this.deny(res, 410, "this request has expired \u2014 retry the operation");
84689
+ return;
84690
+ }
84354
84691
  if (entry.request.kind !== "personal-sign") {
84355
84692
  this.deny(res, 400, "finalize applies only to personal-sign requests");
84356
84693
  return;
@@ -84377,6 +84714,10 @@ var SignatureBridge = class {
84377
84714
  this.deny(res, 404, "request settled while finalizing");
84378
84715
  return;
84379
84716
  }
84717
+ if (this.expireIfOverdue(entry)) {
84718
+ this.deny(res, 410, "this request expired while its payload was being prepared \u2014 retry the operation");
84719
+ return;
84720
+ }
84380
84721
  entry.request.personalSign = fresh.personalSign;
84381
84722
  entry.request.card = fresh.card;
84382
84723
  }
@@ -84390,6 +84731,10 @@ var SignatureBridge = class {
84390
84731
  this.deny(res, 404, "unknown or already-settled requestId");
84391
84732
  return;
84392
84733
  }
84734
+ if (this.expireIfOverdue(entry)) {
84735
+ this.deny(res, 410, "this request has expired \u2014 retry the operation");
84736
+ return;
84737
+ }
84393
84738
  if (body["approved"] !== true) {
84394
84739
  if (this.ownedByWc(entry) && entry.request.kind === "transaction") {
84395
84740
  this.settle(entry, {
@@ -84438,6 +84783,16 @@ var SignatureBridge = class {
84438
84783
  this.ok(res);
84439
84784
  }
84440
84785
  // ---- helpers ----
84786
+ /** Accept-time deadline check. The 1 s sweep is only the backstop: between the deadline and
84787
+ * the next tick a late click on /finalize or /result — or a WalletConnect dispatch — would
84788
+ * otherwise still ask for or accept a signature over a payload the protocol will refuse.
84789
+ * Settles the entry `expired` (the same outcome the sweep gives) and reports it. */
84790
+ expireIfOverdue(entry) {
84791
+ if (entry.settled) return true;
84792
+ if (this.clock() < entry.deadlineMs) return false;
84793
+ this.settle(entry, { status: "expired" });
84794
+ return true;
84795
+ }
84441
84796
  settle(entry, outcome) {
84442
84797
  entry.settled = true;
84443
84798
  this.pending.delete(entry.request.id);
@@ -85029,6 +85384,7 @@ async function createRealBoundary(config, wallet, overrides) {
85029
85384
  const manager = new SignerManager({
85030
85385
  persistence: overrides?.signerPersistence?.(config.network) ?? fileSignerPersistence(stateFile),
85031
85386
  initialMode,
85387
+ ...overrides?.boundBorrower ? { authenticatedBorrower: import_ethers51.ethers.getAddress(overrides.boundBorrower) } : {},
85032
85388
  candidate: () => bridge.walletState()?.account ?? null,
85033
85389
  pendingCeremonies: () => bridge.pendingCount(),
85034
85390
  keystore