@gvnrdao/dh-mcp 0.5.20 → 0.5.22
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 +612 -111
- package/dist/connector-embed.js +1329 -495
- package/dist/connector.js +2673 -927
- package/dist/index.js +632 -124
- package/package.json +14 -3
package/dist/index.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(/[\]\\/()
|
|
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
|
|
15466
|
+
var import_ethers56 = 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
|
-
...
|
|
18462
|
+
...import_ethers56.ethers,
|
|
18431
18463
|
providers: {
|
|
18432
|
-
StaticJsonRpcProvider:
|
|
18464
|
+
StaticJsonRpcProvider: import_ethers56.ethers.JsonRpcProvider
|
|
18433
18465
|
},
|
|
18434
|
-
Contract:
|
|
18435
|
-
utils:
|
|
18466
|
+
Contract: import_ethers56.ethers.Contract,
|
|
18467
|
+
utils: import_ethers56.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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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)
|
|
@@ -28276,7 +28308,7 @@ var require_lit_ops_module = __commonJS({
|
|
|
28276
28308
|
async chipotleCreateWalletAndAddToGroup(accountApiKey) {
|
|
28277
28309
|
const baseUrl = _LitOps.LIT_CORE_API_BASE;
|
|
28278
28310
|
const createResp = await fetch(`${baseUrl}/create_wallet`, {
|
|
28279
|
-
method: "
|
|
28311
|
+
method: "POST",
|
|
28280
28312
|
headers: {
|
|
28281
28313
|
"X-Api-Key": accountApiKey
|
|
28282
28314
|
}
|
|
@@ -40696,6 +40728,7 @@ __export(wc_transport_exports, {
|
|
|
40696
40728
|
WC_DAPP_METADATA: () => WC_DAPP_METADATA,
|
|
40697
40729
|
WC_SESSION_METHODS: () => WC_SESSION_METHODS,
|
|
40698
40730
|
WcTransport: () => WcTransport,
|
|
40731
|
+
guardRelayFatal: () => guardRelayFatal,
|
|
40699
40732
|
newIsolatedCore: () => newIsolatedCore,
|
|
40700
40733
|
wcSessionNamespaces: () => wcSessionNamespaces,
|
|
40701
40734
|
withEip712DomainType: () => withEip712DomainType
|
|
@@ -40729,7 +40762,27 @@ function newIsolatedCore(cfg, label) {
|
|
|
40729
40762
|
});
|
|
40730
40763
|
return { core, scratch };
|
|
40731
40764
|
}
|
|
40732
|
-
|
|
40765
|
+
function guardRelayFatal(core, health, onFatal) {
|
|
40766
|
+
const relayer = core.relayer;
|
|
40767
|
+
const register = relayer.registerProviderListeners;
|
|
40768
|
+
if (typeof register !== "function") {
|
|
40769
|
+
throw new Error(
|
|
40770
|
+
"@walletconnect/core no longer exposes relayer.registerProviderListeners \u2014 the fatal-close guard (D-4) cannot be installed. Re-verify the relay error path for this WalletConnect version before shipping it."
|
|
40771
|
+
);
|
|
40772
|
+
}
|
|
40773
|
+
const record = (e) => {
|
|
40774
|
+
if (health.fatal !== null) return;
|
|
40775
|
+
health.fatal = e.message;
|
|
40776
|
+
console.error(`[dh-mcp] WalletConnect relay failed fatally: ${e.message}`);
|
|
40777
|
+
onFatal(e.message);
|
|
40778
|
+
};
|
|
40779
|
+
relayer.on("relayer_error", record);
|
|
40780
|
+
relayer.registerProviderListeners = () => {
|
|
40781
|
+
register.call(relayer);
|
|
40782
|
+
relayer.provider.on("error", record);
|
|
40783
|
+
};
|
|
40784
|
+
}
|
|
40785
|
+
var import_core, import_sign_client, os, path3, import_node_fs, import_ethers50, WC_SESSION_METHODS, WC_DAPP_METADATA, EVENTS, WcTransport;
|
|
40733
40786
|
var init_wc_transport = __esm({
|
|
40734
40787
|
"src/boundary/upstream/shared/external-bridge/wc-transport.ts"() {
|
|
40735
40788
|
"use strict";
|
|
@@ -40738,6 +40791,7 @@ var init_wc_transport = __esm({
|
|
|
40738
40791
|
os = __toESM(require("os"));
|
|
40739
40792
|
path3 = __toESM(require("path"));
|
|
40740
40793
|
import_node_fs = require("fs");
|
|
40794
|
+
import_ethers50 = require("ethers");
|
|
40741
40795
|
WC_SESSION_METHODS = ["personal_sign", "eth_signTypedData_v4", "eth_sendTransaction"];
|
|
40742
40796
|
WC_DAPP_METADATA = {
|
|
40743
40797
|
name: "Diamond Hands MCP",
|
|
@@ -40747,25 +40801,50 @@ var init_wc_transport = __esm({
|
|
|
40747
40801
|
};
|
|
40748
40802
|
EVENTS = ["accountsChanged", "chainChanged"];
|
|
40749
40803
|
WcTransport = class _WcTransport {
|
|
40750
|
-
constructor(client, cfg, scratch) {
|
|
40804
|
+
constructor(client, cfg, scratch, health) {
|
|
40751
40805
|
this.client = client;
|
|
40752
40806
|
this.cfg = cfg;
|
|
40753
40807
|
this.scratch = scratch;
|
|
40754
|
-
|
|
40808
|
+
this.health = health;
|
|
40809
|
+
client.on("session_delete", ({ topic }) => {
|
|
40810
|
+
const pending = this.candidates.get(topic);
|
|
40811
|
+
if (pending) pending.deleted = true;
|
|
40812
|
+
if (this.session === null || this.session.topic !== topic) return;
|
|
40755
40813
|
this.session = null;
|
|
40756
40814
|
this.sessionListener?.(null);
|
|
40757
40815
|
});
|
|
40758
40816
|
}
|
|
40759
40817
|
session = null;
|
|
40760
40818
|
sessionListener = null;
|
|
40819
|
+
/** Sessions announced but not yet adopted (awaiting a deferred verdict), by topic. */
|
|
40820
|
+
candidates = /* @__PURE__ */ new Map();
|
|
40761
40821
|
static async create(cfg) {
|
|
40762
40822
|
const { core, scratch } = newIsolatedCore(cfg, "dh-wc-dapp");
|
|
40823
|
+
const health = { fatal: null };
|
|
40824
|
+
let transport = null;
|
|
40825
|
+
guardRelayFatal(core, health, () => transport?.dropForFatal());
|
|
40763
40826
|
const client = await import_sign_client.default.init({
|
|
40764
40827
|
core,
|
|
40765
40828
|
projectId: cfg.projectId,
|
|
40766
|
-
metadata: WC_DAPP_METADATA
|
|
40829
|
+
metadata: cfg.metadata ?? WC_DAPP_METADATA
|
|
40767
40830
|
});
|
|
40768
|
-
|
|
40831
|
+
transport = new _WcTransport(client, cfg, scratch, health);
|
|
40832
|
+
return transport;
|
|
40833
|
+
}
|
|
40834
|
+
/** The relay is gone for good: no adopted session may outlive it. Listeners hear a
|
|
40835
|
+
* disconnect, exactly as if the wallet had left. */
|
|
40836
|
+
dropForFatal() {
|
|
40837
|
+
if (this.session === null) return;
|
|
40838
|
+
this.session = null;
|
|
40839
|
+
void this.sessionListener?.(null);
|
|
40840
|
+
}
|
|
40841
|
+
/** Refuse to start new work over a relay that has failed fatally — naming why. */
|
|
40842
|
+
assertRelayHealthy() {
|
|
40843
|
+
if (this.health.fatal !== null) {
|
|
40844
|
+
throw new Error(
|
|
40845
|
+
`the WalletConnect relay refused this connector (${this.health.fatal}) \u2014 mobile-wallet signing is unavailable until the relay accepts its project id (DH_WC_PROJECT_ID); use the browser-wallet approval page instead`
|
|
40846
|
+
);
|
|
40847
|
+
}
|
|
40769
40848
|
}
|
|
40770
40849
|
/** Wallet-session state changes (connect/disconnect) — the bridge mirrors them. */
|
|
40771
40850
|
onSession(cb) {
|
|
@@ -40776,22 +40855,59 @@ var init_wc_transport = __esm({
|
|
|
40776
40855
|
}
|
|
40777
40856
|
/** Create a pairing URI; resolves the session in the background when a wallet approves. */
|
|
40778
40857
|
async createPairing() {
|
|
40858
|
+
this.assertRelayHealthy();
|
|
40779
40859
|
const { uri, approval } = await this.client.connect({
|
|
40780
40860
|
// sign-client 2.21 deprecates requiredNamespaces (auto-downgraded to optional).
|
|
40781
40861
|
optionalNamespaces: wcSessionNamespaces(this.cfg.chainId)
|
|
40782
40862
|
});
|
|
40783
40863
|
if (!uri) throw new Error("WalletConnect returned no pairing URI");
|
|
40784
|
-
|
|
40864
|
+
const pairingId = /^wc:([0-9a-f]+)@/i.exec(uri)?.[1];
|
|
40865
|
+
if (!pairingId) throw new Error(`WalletConnect pairing URI has no recognisable topic: ${uri.slice(0, 12)}\u2026`);
|
|
40866
|
+
let candidateTopic = null;
|
|
40867
|
+
void approval().then(async (session) => {
|
|
40785
40868
|
const first = session.namespaces["eip155"]?.accounts[0];
|
|
40786
40869
|
if (!first) throw new Error("WalletConnect session carries no eip155 account");
|
|
40787
40870
|
const [, chainIdStr, account] = first.split(":");
|
|
40788
|
-
|
|
40789
|
-
|
|
40790
|
-
|
|
40791
|
-
|
|
40871
|
+
candidateTopic = session.topic;
|
|
40872
|
+
const candidate = { topic: session.topic, account, chainId: Number(chainIdStr) };
|
|
40873
|
+
const prove = async (statement) => {
|
|
40874
|
+
this.assertRelayHealthy();
|
|
40875
|
+
return await this.client.request({
|
|
40876
|
+
topic: candidate.topic,
|
|
40877
|
+
chainId: `eip155:${candidate.chainId}`,
|
|
40878
|
+
request: { method: "personal_sign", params: [import_ethers50.ethers.hexlify(import_ethers50.ethers.toUtf8Bytes(statement)), candidate.account] }
|
|
40879
|
+
});
|
|
40880
|
+
};
|
|
40881
|
+
const state = { deleted: false };
|
|
40882
|
+
const live = () => !state.deleted && this.health.fatal === null;
|
|
40883
|
+
const previous = this.session;
|
|
40884
|
+
this.session = candidate;
|
|
40885
|
+
this.candidates.set(candidate.topic, state);
|
|
40886
|
+
const verdict = this.sessionListener?.({ account: candidate.account, chainId: candidate.chainId, pairingId, prove, live });
|
|
40887
|
+
let adopted;
|
|
40888
|
+
if (verdict instanceof Promise) {
|
|
40889
|
+
this.session = previous;
|
|
40890
|
+
adopted = await verdict.finally(() => this.candidates.delete(candidate.topic)).then((v) => v !== false);
|
|
40891
|
+
if (adopted) this.session = candidate;
|
|
40892
|
+
} else {
|
|
40893
|
+
this.candidates.delete(candidate.topic);
|
|
40894
|
+
adopted = verdict !== false;
|
|
40895
|
+
if (!adopted) this.session = previous;
|
|
40896
|
+
}
|
|
40897
|
+
if (!adopted) {
|
|
40898
|
+
void this.client.disconnect({ topic: session.topic, reason: { code: 6e3, message: "session refused by the bridge" } }).catch(() => void 0);
|
|
40899
|
+
}
|
|
40900
|
+
}).catch((e) => {
|
|
40901
|
+
console.error(`[dh-mcp] WalletConnect pairing failed: ${e.message}`);
|
|
40902
|
+
if (candidateTopic !== null && this.session?.topic !== candidateTopic) {
|
|
40903
|
+
void this.client.disconnect({ topic: candidateTopic, reason: { code: 6e3, message: "session not adopted" } }).catch(() => void 0);
|
|
40904
|
+
}
|
|
40905
|
+
});
|
|
40906
|
+
return { uri, pairingId };
|
|
40792
40907
|
}
|
|
40793
40908
|
/** Route one wallet request over the active session. Throws on user rejection. */
|
|
40794
40909
|
async request(method, params) {
|
|
40910
|
+
this.assertRelayHealthy();
|
|
40795
40911
|
if (!this.session) throw new Error("no active WalletConnect session");
|
|
40796
40912
|
return this.client.request({
|
|
40797
40913
|
topic: this.session.topic,
|
|
@@ -41044,13 +41160,14 @@ function resolveRealConfig(env) {
|
|
|
41044
41160
|
|
|
41045
41161
|
// src/boot.ts
|
|
41046
41162
|
var fs6 = __toESM(require("fs"));
|
|
41047
|
-
var
|
|
41163
|
+
var import_ethers53 = require("ethers");
|
|
41048
41164
|
|
|
41049
41165
|
// src/boundary/index.ts
|
|
41050
41166
|
var import_node_crypto8 = require("crypto");
|
|
41051
41167
|
var fs5 = __toESM(require("fs"));
|
|
41052
41168
|
var os2 = __toESM(require("os"));
|
|
41053
41169
|
var path4 = __toESM(require("path"));
|
|
41170
|
+
var import_ethers52 = require("ethers");
|
|
41054
41171
|
|
|
41055
41172
|
// src/boundary/envelope.ts
|
|
41056
41173
|
function okEnvelope(data, source, warnings = []) {
|
|
@@ -43544,8 +43661,13 @@ var SignerManager = class {
|
|
|
43544
43661
|
mode: deps.initialMode,
|
|
43545
43662
|
borrower: deps.configuredBorrower ?? null
|
|
43546
43663
|
};
|
|
43664
|
+
if (deps.authenticatedBorrower) this.state = { ...this.state, borrower: deps.authenticatedBorrower };
|
|
43547
43665
|
}
|
|
43548
43666
|
state;
|
|
43667
|
+
/** True when the borrower is the signed-in identity and cannot be swapped. */
|
|
43668
|
+
identityPinned() {
|
|
43669
|
+
return this.deps.authenticatedBorrower !== void 0;
|
|
43670
|
+
}
|
|
43549
43671
|
mode() {
|
|
43550
43672
|
return this.state.mode;
|
|
43551
43673
|
}
|
|
@@ -43585,7 +43707,7 @@ var SignerManager = class {
|
|
|
43585
43707
|
this.deps.persistence.save(this.state);
|
|
43586
43708
|
}
|
|
43587
43709
|
resetBorrower() {
|
|
43588
|
-
this.state = { ...this.state, borrower: null };
|
|
43710
|
+
this.state = { ...this.state, borrower: this.deps.authenticatedBorrower ?? null };
|
|
43589
43711
|
this.deps.persistence.save(this.state);
|
|
43590
43712
|
}
|
|
43591
43713
|
async use(mode, opts) {
|
|
@@ -51965,11 +52087,11 @@ var init_deployment_addresses = __esm2({
|
|
|
51965
52087
|
reason: "Shared upgrade script: AdminModule implementation update"
|
|
51966
52088
|
},
|
|
51967
52089
|
PositionManagerViews: {
|
|
51968
|
-
previousImplementation: "
|
|
51969
|
-
newImplementation: "
|
|
51970
|
-
upgradedAt: "2026-
|
|
51971
|
-
upgradedBy: "
|
|
51972
|
-
reason: "
|
|
52090
|
+
previousImplementation: "0xA455B542cFb36AF8451fc420dB89e590E5c87cef",
|
|
52091
|
+
newImplementation: "0x8cEB3F1c07fDB3301f55b96a5B9aDb33C8d36Da3",
|
|
52092
|
+
upgradedAt: "2026-10-02T17:04:25.853Z",
|
|
52093
|
+
upgradedBy: "0x0f8f23674cc90Ef7107930a4437341fD8B460362",
|
|
52094
|
+
reason: "1.1.2: getBackingVaults (PoR backing set) + implementation lock (constructor)"
|
|
51973
52095
|
},
|
|
51974
52096
|
TestPositionManager: {
|
|
51975
52097
|
previousImplementation: "0x0B46Ee1a9C6b42559758B7FF78294Cd867BB08f8",
|
|
@@ -53429,6 +53551,32 @@ var require_pkg_src2 = __commonJS2({
|
|
|
53429
53551
|
deployedAt: 1790246264563,
|
|
53430
53552
|
size: 69219,
|
|
53431
53553
|
hash: "bda048d8cd6b5a39c2774bcf1320e82d1eea935c2a521006fb8b887e13b6dd8d"
|
|
53554
|
+
},
|
|
53555
|
+
carryCollateralAttestation: {
|
|
53556
|
+
cid: "QmYWULmXD9S5AmTdQqWqoZ28ctsZQNcXkAgre9G2Xo9dh8",
|
|
53557
|
+
authorizedCidHex: cidToHex(
|
|
53558
|
+
"QmYWULmXD9S5AmTdQqWqoZ28ctsZQNcXkAgre9G2Xo9dh8"
|
|
53559
|
+
),
|
|
53560
|
+
name: "Carry Collateral Attestation",
|
|
53561
|
+
description: "LoanCarryVault collateral attestation (borrower, BTC vault, confirmed BTC)",
|
|
53562
|
+
version: "1.0.0",
|
|
53563
|
+
deployed: true,
|
|
53564
|
+
deployedAt: 1790927734070,
|
|
53565
|
+
size: 21156,
|
|
53566
|
+
hash: "05b177e0bb36b0483db4a42d33c1bbbf47eb9ef34ae278459397d51a7f8957ff"
|
|
53567
|
+
},
|
|
53568
|
+
carryFundingAttestation: {
|
|
53569
|
+
cid: "QmWhox3xUZMNR5NpPZ9WLSPC5GoW4ms88GanVRKr8uuS3W",
|
|
53570
|
+
authorizedCidHex: cidToHex(
|
|
53571
|
+
"QmWhox3xUZMNR5NpPZ9WLSPC5GoW4ms88GanVRKr8uuS3W"
|
|
53572
|
+
),
|
|
53573
|
+
name: "Carry Funding Attestation",
|
|
53574
|
+
description: "LoanCarryVault funding attestation (Hyperliquid BTC windowed hourly average)",
|
|
53575
|
+
version: "1.0.0",
|
|
53576
|
+
deployed: true,
|
|
53577
|
+
deployedAt: 1790925699980,
|
|
53578
|
+
size: 7193,
|
|
53579
|
+
hash: "4944ada61610cf64b32e33b5be62087088dcf5e821040c69e67942e643ce74c9"
|
|
53432
53580
|
}
|
|
53433
53581
|
};
|
|
53434
53582
|
function getDeploymentsForNetwork(network) {
|
|
@@ -82839,7 +82987,7 @@ var RealUpstreamPlugin = class {
|
|
|
82839
82987
|
}
|
|
82840
82988
|
if (mode === "external") {
|
|
82841
82989
|
const borrower = await rt.manager.resolveBorrowerForWrite();
|
|
82842
|
-
if (!borrower) {
|
|
82990
|
+
if (!borrower || this.pinnedWalletUnreachable(borrower, { allowCachedLogin: false })) {
|
|
82843
82991
|
return {
|
|
82844
82992
|
ok: false,
|
|
82845
82993
|
failure: {
|
|
@@ -82889,6 +83037,20 @@ var RealUpstreamPlugin = class {
|
|
|
82889
83037
|
}
|
|
82890
83038
|
};
|
|
82891
83039
|
}
|
|
83040
|
+
/** Hosted tier: the SIWE borrower is bound from boot, so "bound" no longer implies a
|
|
83041
|
+
* wallet can sign. Refuse as "no wallet is connected" instead of starting a ceremony
|
|
83042
|
+
* nobody can answer.
|
|
83043
|
+
*
|
|
83044
|
+
* `allowCachedLogin` is for `connectExternal` ONLY: a still-valid lit-ops login lets it
|
|
83045
|
+
* succeed without a wallet (it signs nothing). A WRITE always needs a fresh wallet
|
|
83046
|
+
* signature (ExternalEoaDHSigner), so a cached JWT must not admit it — that would queue
|
|
83047
|
+
* an approval with no wallet attached to sign it. */
|
|
83048
|
+
pinnedWalletUnreachable(borrower, opts) {
|
|
83049
|
+
if (!this.runtime?.manager.identityPinned()) return false;
|
|
83050
|
+
if (this.runtime.bridge.walletState() !== null) return false;
|
|
83051
|
+
if (!opts.allowCachedLogin) return true;
|
|
83052
|
+
return !this.sessionCache.get(`external:${borrower.toLowerCase()}`)?.hasValidToken();
|
|
83053
|
+
}
|
|
82892
83054
|
/** The EXPLICIT login action (plan 10 OV-10 / A0.7): the ONLY path that may summon the
|
|
82893
83055
|
* wallet for a lit-ops login outside a write ceremony. Binds the borrower on success —
|
|
82894
83056
|
* the first verified ceremony fixes the identity. */
|
|
@@ -82899,7 +83061,7 @@ var RealUpstreamPlugin = class {
|
|
|
82899
83061
|
return { ok: false, reason: `the active mode is '${manager.mode()}' \u2014 run signer_setup action 'use' mode 'external' first` };
|
|
82900
83062
|
}
|
|
82901
83063
|
const borrower = manager.borrowerForWrite();
|
|
82902
|
-
if (!borrower) {
|
|
83064
|
+
if (!borrower || this.pinnedWalletUnreachable(borrower, { allowCachedLogin: true })) {
|
|
82903
83065
|
return { ok: false, reason: "no wallet is connected \u2014 open the approval page (signer_setup action 'status') and connect your wallet first" };
|
|
82904
83066
|
}
|
|
82905
83067
|
const key = `external:${borrower.toLowerCase()}`;
|
|
@@ -83436,6 +83598,81 @@ var RealUpstreamPlugin = class {
|
|
|
83436
83598
|
var fs4 = __toESM(require("fs"));
|
|
83437
83599
|
var http3 = __toESM(require("http"));
|
|
83438
83600
|
var import_node_crypto7 = require("crypto");
|
|
83601
|
+
var import_ethers51 = require("ethers");
|
|
83602
|
+
|
|
83603
|
+
// src/util/brand-assets.ts
|
|
83604
|
+
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>`;
|
|
83605
|
+
var FAVICON_DATA_URI = `data:image/svg+xml,${encodeURIComponent(FAVICON_SVG).replace(/'/g, "%27")}`;
|
|
83606
|
+
var GVNR_PILL_LOGO_DATA_URI = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAACXCAYAAABjhOMoAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAAJTxJREFUeAHtnV92E0myx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WDDloY6giAIQq1xCJvDgp3hnBilrLrY4Kj1IgiCIAiCkBR+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=";
|
|
83607
|
+
|
|
83608
|
+
// src/util/house-style.ts
|
|
83609
|
+
var APP_BACKGROUND_ORIGIN = "https://images.diamondhands.credit";
|
|
83610
|
+
var APP_BACKGROUND_URL = `${APP_BACKGROUND_ORIGIN}/bg-diamond-hands.png`;
|
|
83611
|
+
var FONT_ORIGIN = "https://images.gvnr.xyz";
|
|
83612
|
+
var MANROPE_BASE = `${FONT_ORIGIN}/fonts/manrope`;
|
|
83613
|
+
var HOUSE_CSP_EXTRA = {
|
|
83614
|
+
"img-src": [APP_BACKGROUND_ORIGIN, "data:"],
|
|
83615
|
+
"font-src": [FONT_ORIGIN]
|
|
83616
|
+
};
|
|
83617
|
+
var HOUSE_HEAD_LINKS = `<link rel="icon" type="image/svg+xml" href="${FAVICON_DATA_URI}">
|
|
83618
|
+
<link rel="apple-touch-icon" href="${FAVICON_DATA_URI}">`;
|
|
83619
|
+
var MANROPE_WEIGHTS = [
|
|
83620
|
+
[300, "Light"],
|
|
83621
|
+
[400, "Regular"],
|
|
83622
|
+
[500, "Medium"],
|
|
83623
|
+
[600, "SemiBold"],
|
|
83624
|
+
[700, "Bold"]
|
|
83625
|
+
];
|
|
83626
|
+
var HOUSE_BASE_CSS = `
|
|
83627
|
+
${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")}
|
|
83628
|
+
* { box-sizing: border-box; }
|
|
83629
|
+
html { min-height: 100%; background: #000006; }
|
|
83630
|
+
body { margin: 0; min-height: 100vh; color: #fff; font: 14px/1.5 "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
83631
|
+
background: #000006 url("${APP_BACKGROUND_URL}") center / cover no-repeat fixed; }
|
|
83632
|
+
.house-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem; }
|
|
83633
|
+
@media (min-width: 768px) { .house-header { padding: 1rem 2.5rem; } }
|
|
83634
|
+
.house-header > img { height: 1.92rem; width: auto; display: block; flex: none; }
|
|
83635
|
+
/* Narrow viewports: the chip may shrink (its label ellipsises), and below 400px the label
|
|
83636
|
+
is dropped so logo + chip icon always fit a 320px phone with no horizontal page scroll. */
|
|
83637
|
+
.house-header .chip { min-width: 0; }
|
|
83638
|
+
.chip-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
83639
|
+
/* ".house-header .chip", not ".chip": the base .chip rule below declares padding too, and at
|
|
83640
|
+
equal specificity the LATER rule wins regardless of the media query; this selector outranks it. */
|
|
83641
|
+
@media (max-width: 400px) { .chip-label { display: none; } .house-header .chip { padding: 0.4rem 0.6rem; } }
|
|
83642
|
+
.chip { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.4rem 0.85rem; border-radius: 999px;
|
|
83643
|
+
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);
|
|
83644
|
+
font-size: 0.8rem; font-weight: 600; color: #dbff91; white-space: nowrap; }
|
|
83645
|
+
.chip img { height: 1rem; }
|
|
83646
|
+
main { max-width: 34rem; margin: 2.5rem auto 3rem; padding: 0 1rem; }
|
|
83647
|
+
.panel { background: #121212; border: 1px solid rgba(255, 255, 255, 0.06); border-radius: 12px; padding: 1rem;
|
|
83648
|
+
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05); }
|
|
83649
|
+
@media (min-width: 768px) { .panel { padding: 1.25rem; } }
|
|
83650
|
+
h1 { font-size: 1.25rem; font-weight: 600; line-height: 1.375; color: #fafafa; margin: 0 0 1rem; }
|
|
83651
|
+
@media (min-width: 768px) { h1 { font-size: 1.5rem; margin-bottom: 1.25rem; } }
|
|
83652
|
+
h2 { font-size: 1rem; font-weight: 600; line-height: 1.375; color: #fafafa; margin: 0 0 0.75rem; }
|
|
83653
|
+
p { margin: 0 0 1rem; color: #e5e5e5; font-size: 0.875rem; font-weight: 300; line-height: 1.5; }
|
|
83654
|
+
button { font: inherit; font-size: 0.875rem; cursor: pointer; border: 0; display: inline-flex; align-items: center; justify-content: center;
|
|
83655
|
+
min-height: 2.75rem; padding: 0.65rem 1.25rem; transition: opacity 0.2s, background-color 0.2s; }
|
|
83656
|
+
button:focus-visible { outline: 2px solid #84cc16; outline-offset: 2px; }
|
|
83657
|
+
button:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
83658
|
+
/* Primary = lime-700 (#4d7c0f): white 14px text on it is 4.99:1 (WCAG AA needs 4.5:1; the
|
|
83659
|
+
brighter #65a30d was 3.09:1). Hover = lime-800 (#3f6212), 7.08:1. A test recomputes both. */
|
|
83660
|
+
.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); }
|
|
83661
|
+
.btn-primary:hover:not(:disabled) { background: #3f6212; }
|
|
83662
|
+
.btn-secondary { background: #34440e; color: #dbff91; font-weight: 500; border-radius: 20px; }
|
|
83663
|
+
.btn-secondary:hover:not(:disabled) { background: #3d5210; }
|
|
83664
|
+
.btn-danger { background: transparent; color: #fca5a5; font-weight: 600; border-radius: 12px; border: 1px solid rgba(248, 113, 113, 0.45); }
|
|
83665
|
+
.btn-danger:hover:not(:disabled) { background: rgba(220, 38, 38, 0.15); }
|
|
83666
|
+
/* A QR needs dark-on-light to scan: it keeps a white plate on the dark page. */
|
|
83667
|
+
.qr-plate { max-width: 16rem; margin-top: 1rem; background: #fff; border-radius: 12px; padding: 0.5rem; }
|
|
83668
|
+
.qr-plate svg { width: 100%; height: auto; display: block; }
|
|
83669
|
+
`;
|
|
83670
|
+
function houseHeader(label) {
|
|
83671
|
+
return `<header class="house-header">
|
|
83672
|
+
<img src="${GVNR_PILL_LOGO_DATA_URI}" alt="GVNR">
|
|
83673
|
+
<span class="chip"><img src="${FAVICON_DATA_URI}" alt=""><span class="chip-label">${label}</span></span>
|
|
83674
|
+
</header>`;
|
|
83675
|
+
}
|
|
83439
83676
|
|
|
83440
83677
|
// src/boundary/upstream/shared/external-bridge/approval-page.ts
|
|
83441
83678
|
function renderApprovalPage(sessionId, nonce) {
|
|
@@ -83445,47 +83682,48 @@ function renderApprovalPage(sessionId, nonce) {
|
|
|
83445
83682
|
<meta charset="utf-8">
|
|
83446
83683
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
83447
83684
|
<title>Diamond Hands \u2014 signature approval</title>
|
|
83685
|
+
${HOUSE_HEAD_LINKS}
|
|
83448
83686
|
<style>
|
|
83449
|
-
|
|
83450
|
-
|
|
83451
|
-
|
|
83452
|
-
|
|
83453
|
-
|
|
83454
|
-
|
|
83455
|
-
|
|
83456
|
-
|
|
83457
|
-
|
|
83458
|
-
.
|
|
83459
|
-
|
|
83460
|
-
|
|
83461
|
-
|
|
83462
|
-
|
|
83463
|
-
#
|
|
83464
|
-
#
|
|
83465
|
-
#wallet { font-family:ui-monospace,monospace; font-size:12px; color:var(--dim); margin-top:10px; }
|
|
83687
|
+
${HOUSE_BASE_CSS}
|
|
83688
|
+
/* \u2500\u2500 approval page only \u2500\u2500 */
|
|
83689
|
+
main { max-width: 36rem; }
|
|
83690
|
+
.status { color:#a1a1a1; font-size:0.875rem; }
|
|
83691
|
+
.action { text-transform:uppercase; letter-spacing:.08em; font-size:0.75rem; font-weight:600; color:#dbff91; margin-top:0.25rem; }
|
|
83692
|
+
/* The decoded card IS the operation (decode-equivalence): kept monospace and pre-wrapped
|
|
83693
|
+
exactly as the server rendered it, on an inset well darker than the panel. */
|
|
83694
|
+
.card { white-space:pre-wrap; font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:0.875rem; color:#fafafa;
|
|
83695
|
+
background:#0a0a0a; border:1px solid rgba(255,255,255,0.1); border-radius:10px; padding:14px; margin:0.75rem 0 1rem; }
|
|
83696
|
+
.actions { display:flex; flex-wrap:wrap; gap:0.75rem; }
|
|
83697
|
+
#deadline { margin-bottom:1rem; }
|
|
83698
|
+
#wallet { font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:0.75rem; color:#a1a1a1; margin-top:1rem; }
|
|
83699
|
+
#wallet:empty { display:none; }
|
|
83700
|
+
#wc { margin-top:1.25rem; border-top:1px solid rgba(255,255,255,0.06); padding-top:1rem; }
|
|
83701
|
+
#wc-uri { user-select:all; word-break:break-all; font-size:0.75rem; }
|
|
83702
|
+
#wc-hint { margin-top:0.75rem; }
|
|
83466
83703
|
.hidden { display:none; }
|
|
83467
83704
|
</style>
|
|
83468
83705
|
</head>
|
|
83469
83706
|
<body>
|
|
83707
|
+
${houseHeader("Diamond Hands \xB7 signature approval")}
|
|
83470
83708
|
<main>
|
|
83471
|
-
<h1
|
|
83709
|
+
<h1>Signature approval</h1>
|
|
83472
83710
|
<div class="panel">
|
|
83473
83711
|
<div id="status" class="status">Connecting to your wallet\u2026</div>
|
|
83474
83712
|
<div id="request" class="hidden">
|
|
83475
83713
|
<div id="action" class="action"></div>
|
|
83476
83714
|
<div id="card" class="card"></div>
|
|
83477
83715
|
<div id="deadline" class="status hidden"></div>
|
|
83478
|
-
<
|
|
83479
|
-
|
|
83716
|
+
<div class="actions">
|
|
83717
|
+
<button id="approve" class="btn-primary">Approve in wallet</button>
|
|
83718
|
+
<button id="reject" class="btn-danger">Reject</button>
|
|
83719
|
+
</div>
|
|
83480
83720
|
</div>
|
|
83481
83721
|
<div id="wallet"></div>
|
|
83482
|
-
<div id="wc"
|
|
83483
|
-
<button id="wc-connect"
|
|
83484
|
-
|
|
83485
|
-
|
|
83486
|
-
<div id="wc-
|
|
83487
|
-
<div id="wc-uri" class="card hidden" style="user-select:all; word-break:break-all; font-size:12px;"></div>
|
|
83488
|
-
<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>
|
|
83722
|
+
<div id="wc">
|
|
83723
|
+
<button id="wc-connect" class="btn-secondary">Use a mobile wallet instead (WalletConnect)</button>
|
|
83724
|
+
<div id="wc-qr" class="qr-plate hidden"></div>
|
|
83725
|
+
<div id="wc-uri" class="card hidden"></div>
|
|
83726
|
+
<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). Your wallet first asks you to sign a short statement proving the wallet is yours \u2014 it moves no funds. Approvals then happen on your phone.</div>
|
|
83489
83727
|
</div>
|
|
83490
83728
|
</div>
|
|
83491
83729
|
</main>
|
|
@@ -83559,21 +83797,63 @@ async function healChain() {
|
|
|
83559
83797
|
}).catch(() => undefined);
|
|
83560
83798
|
}
|
|
83561
83799
|
await readWallet();
|
|
83562
|
-
await
|
|
83800
|
+
await sayHello();
|
|
83563
83801
|
showWallet();
|
|
83564
83802
|
}
|
|
83565
83803
|
|
|
83804
|
+
function utf8Hex(text) {
|
|
83805
|
+
return "0x" + Array.from(new TextEncoder().encode(text)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
83806
|
+
}
|
|
83807
|
+
|
|
83808
|
+
// Presence proof: the bridge only believes a wallet is at this page once the wallet has
|
|
83809
|
+
// SIGNED a short statement naming this page's origin, the chain and a per-page nonce. Saying
|
|
83810
|
+
// an address proves nothing (it is public); signing proves the key is here. One prompt per
|
|
83811
|
+
// page session: once this account has proven itself the bridge accepts later hellos for it
|
|
83812
|
+
// (a chain switch) without asking the wallet again.
|
|
83813
|
+
let provenFor = null;
|
|
83814
|
+
async function sayHello() {
|
|
83815
|
+
let signature;
|
|
83816
|
+
if (provenFor === null || provenFor.toLowerCase() !== String(account).toLowerCase()) {
|
|
83817
|
+
const ch = await fetch(BASE + "challenge?s=" + SESSION + "&chainId=" + chainId).then((r) => r.json());
|
|
83818
|
+
showIdleStatus("Sign the short statement in your wallet to prove it is yours \u2014 it moves no funds.");
|
|
83819
|
+
signature = await window.ethereum.request({ method: "personal_sign", params: [utf8Hex(ch.statement), account] });
|
|
83820
|
+
}
|
|
83821
|
+
const r = await post(BASE + "hello", { account: account, chainId: chainId, signature: signature });
|
|
83822
|
+
if (!r.ok) {
|
|
83823
|
+
const b = await r.json().catch(() => ({}));
|
|
83824
|
+
showStatus("This wallet was not accepted: " + (b.error || "HTTP " + r.status));
|
|
83825
|
+
return false;
|
|
83826
|
+
}
|
|
83827
|
+
provenFor = account;
|
|
83828
|
+
return true;
|
|
83829
|
+
}
|
|
83830
|
+
|
|
83831
|
+
// The stream opens at load, so a card can be on screen BEFORE connect() finishes. The status
|
|
83832
|
+
// line then belongs to that card (its review / mobile-wallet guidance), and connection
|
|
83833
|
+
// progress must not overwrite it. Connection progress lines (idle / "sign the statement", whose
|
|
83834
|
+
// wallet popup is self-explanatory) go through here; failures (a refused hello, a lost
|
|
83835
|
+
// stream, a wrong network) still show unconditionally.
|
|
83836
|
+
function showIdleStatus(text) {
|
|
83837
|
+
if (current !== null) return;
|
|
83838
|
+
showStatus(text);
|
|
83839
|
+
}
|
|
83840
|
+
|
|
83566
83841
|
async function connect() {
|
|
83567
|
-
if (!window.ethereum) {
|
|
83842
|
+
if (!window.ethereum) {
|
|
83843
|
+
// The event stream is already open (see the bottom of this script) \u2014 a phone paired
|
|
83844
|
+
// below still mirrors its cards here.
|
|
83845
|
+
showIdleStatus("No browser wallet detected \u2014 use the mobile wallet option below, or install MetaMask (or open this page in a wallet browser).");
|
|
83846
|
+
return;
|
|
83847
|
+
}
|
|
83568
83848
|
await window.ethereum.request({ method: "eth_requestAccounts" });
|
|
83569
83849
|
await readWallet();
|
|
83570
|
-
|
|
83850
|
+
const accepted = await sayHello();
|
|
83571
83851
|
showWallet();
|
|
83572
83852
|
window.ethereum.on("accountsChanged", onAccountsChanged);
|
|
83573
83853
|
window.ethereum.on("chainChanged", onChainChanged);
|
|
83854
|
+
if (!accepted) return;
|
|
83574
83855
|
await healChain();
|
|
83575
|
-
|
|
83576
|
-
listen();
|
|
83856
|
+
showIdleStatus("Connected. Waiting for a signature request\u2026");
|
|
83577
83857
|
}
|
|
83578
83858
|
|
|
83579
83859
|
// Handlers trust the EVENT payloads \u2014 re-reading eth_accounts/eth_chainId here races the
|
|
@@ -83583,6 +83863,8 @@ async function onAccountsChanged(accounts) {
|
|
|
83583
83863
|
await post(BASE + "wallet-event", { account: account, chainId: chainId });
|
|
83584
83864
|
showWallet();
|
|
83585
83865
|
invalidatePageRequests("Wallet changed \u2014 pending request invalidated.");
|
|
83866
|
+
// The bridge adopts no account from an event alone \u2014 a different account proves itself.
|
|
83867
|
+
if (account) await sayHello();
|
|
83586
83868
|
}
|
|
83587
83869
|
|
|
83588
83870
|
async function onChainChanged(cid) {
|
|
@@ -83592,8 +83874,14 @@ async function onChainChanged(cid) {
|
|
|
83592
83874
|
invalidatePageRequests("Network changed \u2014 pending request invalidated.");
|
|
83593
83875
|
}
|
|
83594
83876
|
|
|
83877
|
+
// ONE stream per page, opened at load whatever wallet this browser has: a phone paired
|
|
83878
|
+
// through WalletConnect needs no injected wallet, and its read-only mirror arrives on this
|
|
83879
|
+
// stream. Opening it proves nothing \u2014 the bridge sends this page NOTHING until a person is
|
|
83880
|
+
// proven (a signed hello, or a pairing a phone answered).
|
|
83881
|
+
let es = null;
|
|
83595
83882
|
function listen() {
|
|
83596
|
-
|
|
83883
|
+
if (es !== null) return;
|
|
83884
|
+
es = new EventSource(BASE + "events?s=" + SESSION);
|
|
83597
83885
|
es.onmessage = (ev) => {
|
|
83598
83886
|
const next = JSON.parse(ev.data);
|
|
83599
83887
|
// A later frame for an id REPLACES the earlier one: driveWc re-stamps a personal-sign
|
|
@@ -83782,9 +84070,10 @@ document.getElementById("wc-connect").onclick = async () => {
|
|
|
83782
84070
|
qrEl.classList.remove("hidden");
|
|
83783
84071
|
}
|
|
83784
84072
|
document.getElementById("wc-hint").classList.remove("hidden");
|
|
83785
|
-
|
|
84073
|
+
showIdleStatus("Scan the QR (or paste the code) in your mobile wallet, then sign the short statement it shows (it proves the wallet is yours and moves no funds) \u2014 it then becomes the signing wallet.");
|
|
83786
84074
|
};
|
|
83787
84075
|
|
|
84076
|
+
listen();
|
|
83788
84077
|
connect();
|
|
83789
84078
|
</script>
|
|
83790
84079
|
</body>
|
|
@@ -83893,6 +84182,22 @@ function htmlPageSecurityHeaders(extra) {
|
|
|
83893
84182
|
|
|
83894
84183
|
// src/boundary/upstream/shared/external-bridge/bridge.ts
|
|
83895
84184
|
var MAX_SESSIONS = 16;
|
|
84185
|
+
function presenceStatement(origin2, chainId, nonce) {
|
|
84186
|
+
return [
|
|
84187
|
+
"Diamond Hands approval page",
|
|
84188
|
+
"Sign to prove this wallet is yours. This moves no funds and approves no operation.",
|
|
84189
|
+
`Origin: ${origin2}`,
|
|
84190
|
+
`Chain ID: ${chainId}`,
|
|
84191
|
+
`Session nonce: ${nonce}`
|
|
84192
|
+
].join("\n");
|
|
84193
|
+
}
|
|
84194
|
+
function recoverPresenceSigner(statement, signature) {
|
|
84195
|
+
try {
|
|
84196
|
+
return import_ethers51.ethers.verifyMessage(statement, signature);
|
|
84197
|
+
} catch {
|
|
84198
|
+
return null;
|
|
84199
|
+
}
|
|
84200
|
+
}
|
|
83896
84201
|
var DEFAULT_EXPIRY_MS = 5 * 60 * 1e3;
|
|
83897
84202
|
var DEFAULT_ATTACH_GRACE_MS = 60 * 1e3;
|
|
83898
84203
|
var DEFAULT_HOSTED_ATTACH_GRACE_MS = 180 * 1e3;
|
|
@@ -83906,6 +84211,7 @@ function wcDeclineOrFault(e) {
|
|
|
83906
84211
|
}
|
|
83907
84212
|
var SignatureBridge = class {
|
|
83908
84213
|
clock;
|
|
84214
|
+
sweepIntervalMs;
|
|
83909
84215
|
/** Lowercased at construction so every comparison is case-flat — EIP-55 checksum casing
|
|
83910
84216
|
* differs between what SIWE signs and what a wallet reports for the SAME address. */
|
|
83911
84217
|
boundAccount;
|
|
@@ -83936,13 +84242,24 @@ var SignatureBridge = class {
|
|
|
83936
84242
|
wcTransport = null;
|
|
83937
84243
|
/** True while a WalletConnect session is THE wallet — ceremonies route over WC. */
|
|
83938
84244
|
wcActive = false;
|
|
83939
|
-
/**
|
|
83940
|
-
|
|
84245
|
+
/** Which page session asked for which pairing (pairing id → session id). The transport's
|
|
84246
|
+
* `onSession` says WHICH PAIRING a phone answered; this says whose it was. The previous
|
|
84247
|
+
* "most recent asker" guess let a second session claim the credit for a QR the user's
|
|
84248
|
+
* phone scanned (Sentinel 2 PoC-B). */
|
|
84249
|
+
pairingOwners = /* @__PURE__ */ new Map();
|
|
84250
|
+
/** The page session the ADMITTED WalletConnect session's proof was made for — the one page
|
|
84251
|
+
* credited with `wcPaired`. The credit lasts exactly as long as that session: it moves when
|
|
84252
|
+
* another proven session replaces it and ends when the wallet disconnects. */
|
|
84253
|
+
wcCreditedSession = null;
|
|
83941
84254
|
keystoreUnlock;
|
|
83942
84255
|
unlockToken = null;
|
|
83943
84256
|
unlockSession = null;
|
|
83944
84257
|
constructor(opts) {
|
|
83945
84258
|
this.clock = opts?.clock ?? Date.now;
|
|
84259
|
+
this.sweepIntervalMs = opts?.sweepIntervalMs ?? 1e3;
|
|
84260
|
+
if (!Number.isInteger(this.sweepIntervalMs) || this.sweepIntervalMs < 0) {
|
|
84261
|
+
throw new Error(`bridge sweepIntervalMs must be a non-negative integer (got ${String(opts?.sweepIntervalMs)})`);
|
|
84262
|
+
}
|
|
83946
84263
|
this.boundAccount = opts?.boundAccount?.toLowerCase();
|
|
83947
84264
|
this.expiryMs = opts?.expiryMs ?? DEFAULT_EXPIRY_MS;
|
|
83948
84265
|
this.maxPending = opts?.maxPending ?? null;
|
|
@@ -83978,8 +84295,10 @@ var SignatureBridge = class {
|
|
|
83978
84295
|
this.server = server;
|
|
83979
84296
|
}
|
|
83980
84297
|
this.started = true;
|
|
83981
|
-
this.
|
|
83982
|
-
|
|
84298
|
+
if (this.sweepIntervalMs > 0) {
|
|
84299
|
+
this.sweepTimer = setInterval(() => this.sweep(), this.sweepIntervalMs);
|
|
84300
|
+
this.sweepTimer.unref();
|
|
84301
|
+
}
|
|
83983
84302
|
if (this.urlFile) fs4.writeFileSync(this.urlFile, this.url());
|
|
83984
84303
|
}
|
|
83985
84304
|
/** Plan 12 C1: the outer server's dispatch entry for a MOUNTED bridge — `req.url`
|
|
@@ -84039,6 +84358,16 @@ var SignatureBridge = class {
|
|
|
84039
84358
|
pendingCount() {
|
|
84040
84359
|
return this.pending.size;
|
|
84041
84360
|
}
|
|
84361
|
+
/** A request lives for the bridge's expiry OR until its payload dies, whichever is first.
|
|
84362
|
+
* The BTC-withdraw execute leg's payload dies inside a sub-minute quantum window; holding
|
|
84363
|
+
* the ceremony open for the full five minutes kept a dead card on screen and let the phone
|
|
84364
|
+
* be asked to sign something the protocol would refuse. */
|
|
84365
|
+
deadlineFor(request, nowMs) {
|
|
84366
|
+
const bridgeDeadline = nowMs + this.expiryMs;
|
|
84367
|
+
if (request.expiresAtSec === void 0) return bridgeDeadline;
|
|
84368
|
+
if (!Number.isFinite(request.expiresAtSec)) throw new Error(`request ${request.id} carries a non-finite expiresAtSec`);
|
|
84369
|
+
return Math.min(bridgeDeadline, request.expiresAtSec * 1e3);
|
|
84370
|
+
}
|
|
84042
84371
|
/**
|
|
84043
84372
|
* Enqueue a request and resolve on the human's decision (or expiry/invalidation).
|
|
84044
84373
|
* Chain-id mismatch with an already-connected wallet refuses BEFORE the wallet is asked.
|
|
@@ -84061,7 +84390,7 @@ var SignatureBridge = class {
|
|
|
84061
84390
|
const now = this.clock();
|
|
84062
84391
|
const entry = {
|
|
84063
84392
|
request,
|
|
84064
|
-
deadlineMs:
|
|
84393
|
+
deadlineMs: this.deadlineFor(request, now),
|
|
84065
84394
|
enqueuedMs: now,
|
|
84066
84395
|
resolve,
|
|
84067
84396
|
settled: false,
|
|
@@ -84092,7 +84421,7 @@ var SignatureBridge = class {
|
|
|
84092
84421
|
const now = this.clock();
|
|
84093
84422
|
const entry = {
|
|
84094
84423
|
request,
|
|
84095
|
-
deadlineMs:
|
|
84424
|
+
deadlineMs: this.deadlineFor(request, now),
|
|
84096
84425
|
enqueuedMs: now,
|
|
84097
84426
|
resolve,
|
|
84098
84427
|
settled: false,
|
|
@@ -84144,6 +84473,7 @@ var SignatureBridge = class {
|
|
|
84144
84473
|
return;
|
|
84145
84474
|
}
|
|
84146
84475
|
try {
|
|
84476
|
+
if (this.expireIfOverdue(entry)) return;
|
|
84147
84477
|
if (req.kind === "transaction") {
|
|
84148
84478
|
this.pushEntry(entry);
|
|
84149
84479
|
const tx2 = req.tx;
|
|
@@ -84155,15 +84485,23 @@ var SignatureBridge = class {
|
|
|
84155
84485
|
} else if (req.kind === "personal-sign") {
|
|
84156
84486
|
if (entry.finalize) {
|
|
84157
84487
|
const fresh = await entry.finalize();
|
|
84488
|
+
if (entry.settled) return;
|
|
84489
|
+
if (entry.owner !== "wc") return;
|
|
84490
|
+
const live = transport.active();
|
|
84491
|
+
if (!this.wcActive || !live || live.account.toLowerCase() !== account.toLowerCase()) {
|
|
84492
|
+
this.settle(entry, {
|
|
84493
|
+
status: "invalidated",
|
|
84494
|
+
reason: "the WalletConnect wallet changed while this payload was being prepared \u2014 the phone was not asked. Reconnect your wallet and retry the operation."
|
|
84495
|
+
});
|
|
84496
|
+
return;
|
|
84497
|
+
}
|
|
84158
84498
|
req.personalSign = fresh.personalSign;
|
|
84159
84499
|
req.card = fresh.card;
|
|
84160
84500
|
}
|
|
84501
|
+
if (this.expireIfOverdue(entry)) return;
|
|
84161
84502
|
const ps = req.personalSign;
|
|
84162
|
-
if (
|
|
84163
|
-
this.settle(entry, {
|
|
84164
|
-
status: "invalidated",
|
|
84165
|
-
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)`
|
|
84166
|
-
});
|
|
84503
|
+
if (!this.pageAttached()) {
|
|
84504
|
+
this.settle(entry, { status: "invalidated", reason: this.noPageReason(ps.layout === RAW_HASH_LAYOUT) });
|
|
84167
84505
|
return;
|
|
84168
84506
|
}
|
|
84169
84507
|
this.pushEntry(entry);
|
|
@@ -84188,6 +84526,16 @@ var SignatureBridge = class {
|
|
|
84188
84526
|
}
|
|
84189
84527
|
}
|
|
84190
84528
|
}
|
|
84529
|
+
/** Refusal for a WalletConnect personal_sign with no proven approval page attached.
|
|
84530
|
+
*
|
|
84531
|
+
* The remedy names BOTH halves, because opening the link alone does not fix it: a freshly
|
|
84532
|
+
* opened page is a stranger until a phone answers a pairing it showed (or its wallet signs
|
|
84533
|
+
* the presence statement), so it receives no card. Following "just reopen the URL" looped
|
|
84534
|
+
* (Sentinel 2 PoC-C). */
|
|
84535
|
+
noPageReason(blindHash) {
|
|
84536
|
+
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";
|
|
84537
|
+
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)`;
|
|
84538
|
+
}
|
|
84191
84539
|
/** A live attachment that could still decide a request: an open approval-page SSE
|
|
84192
84540
|
* stream (real page or headless driver) or an active WalletConnect session. PUBLIC
|
|
84193
84541
|
* (plan 17 E1): the connector's idle-eviction predicate reads it — a tenant world
|
|
@@ -84271,6 +84619,7 @@ var SignatureBridge = class {
|
|
|
84271
84619
|
void this.wcTransport?.close().catch(() => void 0);
|
|
84272
84620
|
this.wcTransport = null;
|
|
84273
84621
|
this.wcActive = false;
|
|
84622
|
+
this.pairingOwners.clear();
|
|
84274
84623
|
}
|
|
84275
84624
|
// ---- HTTP plumbing ----
|
|
84276
84625
|
route(req, res) {
|
|
@@ -84278,6 +84627,7 @@ var SignatureBridge = class {
|
|
|
84278
84627
|
const url2 = new URL(req.url ?? "/", this.mount ? this.mount.origin : `http://127.0.0.1:${this.port}`);
|
|
84279
84628
|
if (req.method === "GET" && url2.pathname === "/") return this.servePage(url2, res);
|
|
84280
84629
|
if (req.method === "GET" && url2.pathname === "/config") return this.serveConfig(url2, res);
|
|
84630
|
+
if (req.method === "GET" && url2.pathname === "/challenge") return this.serveChallenge(url2, res);
|
|
84281
84631
|
if (req.method === "GET" && url2.pathname === "/wc-pairing") return void this.serveWcPairing(url2, res);
|
|
84282
84632
|
if (req.method === "GET" && url2.pathname === "/unlock") return this.serveUnlockPage(url2, res);
|
|
84283
84633
|
if (req.method === "POST" && url2.pathname === "/unlock-submit")
|
|
@@ -84337,8 +84687,16 @@ var SignatureBridge = class {
|
|
|
84337
84687
|
return;
|
|
84338
84688
|
}
|
|
84339
84689
|
const sessionId = (0, import_node_crypto7.randomBytes)(24).toString("hex");
|
|
84340
|
-
this.sessions.set(sessionId, {
|
|
84341
|
-
|
|
84690
|
+
this.sessions.set(sessionId, {
|
|
84691
|
+
wallet: null,
|
|
84692
|
+
sse: null,
|
|
84693
|
+
refused: null,
|
|
84694
|
+
lastSeenMs: this.clock(),
|
|
84695
|
+
wcPaired: false,
|
|
84696
|
+
presenceNonce: (0, import_node_crypto7.randomBytes)(16).toString("hex"),
|
|
84697
|
+
provenAccount: null
|
|
84698
|
+
});
|
|
84699
|
+
const page = htmlPageSecurityHeaders(HOUSE_CSP_EXTRA);
|
|
84342
84700
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store", ...page.headers });
|
|
84343
84701
|
res.end(renderApprovalPage(sessionId, page.nonce));
|
|
84344
84702
|
}
|
|
@@ -84348,11 +84706,29 @@ var SignatureBridge = class {
|
|
|
84348
84706
|
res.writeHead(200, { "Content-Type": "application/json", "Cache-Control": "no-store" });
|
|
84349
84707
|
res.end(JSON.stringify({ network: this.network ?? null }));
|
|
84350
84708
|
}
|
|
84709
|
+
/** The origin this bridge is served from — what a presence statement names. */
|
|
84710
|
+
publicOrigin() {
|
|
84711
|
+
return this.mount ? this.mount.origin : `http://127.0.0.1:${this.port}`;
|
|
84712
|
+
}
|
|
84713
|
+
/** The presence statement for this session + chain (session-gated). The page signs exactly
|
|
84714
|
+
* this text in its wallet; the bridge rebuilds it on `hello` rather than trusting any text
|
|
84715
|
+
* the client sends back. */
|
|
84716
|
+
serveChallenge(url2, res) {
|
|
84717
|
+
const session = this.sessionOf(url2.searchParams.get("s"), res);
|
|
84718
|
+
if (!session) return;
|
|
84719
|
+
const chainId = Number(url2.searchParams.get("chainId"));
|
|
84720
|
+
if (!Number.isInteger(chainId)) {
|
|
84721
|
+
this.deny(res, 400, "challenge requires an integer chainId");
|
|
84722
|
+
return;
|
|
84723
|
+
}
|
|
84724
|
+
res.writeHead(200, { "Content-Type": "application/json", "Cache-Control": "no-store" });
|
|
84725
|
+
res.end(JSON.stringify({ statement: presenceStatement(this.publicOrigin(), chainId, session.presenceNonce) }));
|
|
84726
|
+
}
|
|
84351
84727
|
/** WalletConnect pairing (D2, session-gated): lazily boots the WC transport and serves a
|
|
84352
84728
|
* fresh pairing URI. A wallet approving the pairing becomes THE wallet. */
|
|
84353
84729
|
async serveWcPairing(url2, res) {
|
|
84354
84730
|
if (!this.checkSession(url2.searchParams.get("s"), res)) return;
|
|
84355
|
-
|
|
84731
|
+
const askingSession = url2.searchParams.get("s");
|
|
84356
84732
|
if (!this.wcConfig) {
|
|
84357
84733
|
this.deny(res, 404, "WalletConnect is not configured (set DH_WC_PROJECT_ID)");
|
|
84358
84734
|
return;
|
|
@@ -84363,36 +84739,17 @@ var SignatureBridge = class {
|
|
|
84363
84739
|
const { WcTransport: WcTransport2 } = await Promise.resolve().then(() => (init_wc_transport(), wc_transport_exports));
|
|
84364
84740
|
return WcTransport2.create(cfg);
|
|
84365
84741
|
});
|
|
84366
|
-
|
|
84367
|
-
this.wcTransport
|
|
84368
|
-
|
|
84369
|
-
|
|
84370
|
-
|
|
84371
|
-
|
|
84372
|
-
|
|
84373
|
-
|
|
84374
|
-
|
|
84375
|
-
|
|
84376
|
-
}
|
|
84377
|
-
this.wcActive = info !== null;
|
|
84378
|
-
this.wallet = info ? { account: info.account, chainId: info.chainId } : null;
|
|
84379
|
-
if (info && this.pairingSessionId) {
|
|
84380
|
-
const paired = this.sessions.get(this.pairingSessionId);
|
|
84381
|
-
if (paired) paired.wcPaired = true;
|
|
84382
|
-
}
|
|
84383
|
-
if (info === null) {
|
|
84384
|
-
for (const entry of this.pending.values()) {
|
|
84385
|
-
if (!entry.settled && !entry.collect) {
|
|
84386
|
-
this.settle(entry, {
|
|
84387
|
-
status: "invalidated",
|
|
84388
|
-
reason: entry.dispatched && entry.request.kind === "transaction" ? "the WalletConnect session disconnected after being asked to send this transaction \u2014 it may have broadcast. Check the chain (or your wallet's activity) before retrying, or you may pay twice." : "the WalletConnect session disconnected"
|
|
84389
|
-
});
|
|
84390
|
-
}
|
|
84391
|
-
}
|
|
84392
|
-
}
|
|
84393
|
-
});
|
|
84742
|
+
const transport = await factory2(this.wcConfig);
|
|
84743
|
+
this.wcTransport = transport;
|
|
84744
|
+
transport.onSession((info) => info === null ? this.onWcDisconnect() : this.admitWcSession(info, transport));
|
|
84745
|
+
}
|
|
84746
|
+
const { uri, pairingId } = await this.wcTransport.createPairing();
|
|
84747
|
+
if (pairingId) {
|
|
84748
|
+
for (const [pending, owner] of this.pairingOwners) {
|
|
84749
|
+
if (owner === askingSession || !this.sessions.has(owner)) this.pairingOwners.delete(pending);
|
|
84750
|
+
}
|
|
84751
|
+
this.pairingOwners.set(pairingId, askingSession);
|
|
84394
84752
|
}
|
|
84395
|
-
const { uri } = await this.wcTransport.createPairing();
|
|
84396
84753
|
const { default: qrcode } = await import("qrcode-generator");
|
|
84397
84754
|
const qr = qrcode(0, "M");
|
|
84398
84755
|
qr.addData(uri);
|
|
@@ -84480,6 +84837,29 @@ var SignatureBridge = class {
|
|
|
84480
84837
|
this.deny(res, 403, refusal);
|
|
84481
84838
|
return;
|
|
84482
84839
|
}
|
|
84840
|
+
const alreadyProven = session.provenAccount !== null && session.provenAccount.toLowerCase() === account.toLowerCase();
|
|
84841
|
+
if (!alreadyProven) {
|
|
84842
|
+
const signature = body["signature"];
|
|
84843
|
+
if (typeof signature !== "string" || signature === "") {
|
|
84844
|
+
this.deny(
|
|
84845
|
+
res,
|
|
84846
|
+
403,
|
|
84847
|
+
`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.`
|
|
84848
|
+
);
|
|
84849
|
+
return;
|
|
84850
|
+
}
|
|
84851
|
+
const statement = presenceStatement(this.publicOrigin(), chainId, session.presenceNonce);
|
|
84852
|
+
const recovered = recoverPresenceSigner(statement, signature);
|
|
84853
|
+
if (recovered === null || recovered.toLowerCase() !== account.toLowerCase()) {
|
|
84854
|
+
this.deny(
|
|
84855
|
+
res,
|
|
84856
|
+
403,
|
|
84857
|
+
`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).`
|
|
84858
|
+
);
|
|
84859
|
+
return;
|
|
84860
|
+
}
|
|
84861
|
+
session.provenAccount = account;
|
|
84862
|
+
}
|
|
84483
84863
|
session.wallet = { account, chainId };
|
|
84484
84864
|
this.wallet = { account, chainId };
|
|
84485
84865
|
this.replayPending(session);
|
|
@@ -84521,17 +84901,21 @@ var SignatureBridge = class {
|
|
|
84521
84901
|
if (refusedSwitch) {
|
|
84522
84902
|
this.quarantine(session, switchRefusal);
|
|
84523
84903
|
} else {
|
|
84524
|
-
session.
|
|
84904
|
+
const sameProven = offered !== null && session.provenAccount !== null && offered.account.toLowerCase() === session.provenAccount.toLowerCase();
|
|
84905
|
+
session.wallet = sameProven ? offered : null;
|
|
84525
84906
|
if (this.wallet !== null && prev !== null && this.wallet.account.toLowerCase() === prev.account.toLowerCase()) {
|
|
84526
84907
|
this.wallet = session.wallet;
|
|
84908
|
+
} else if (this.wallet === null && prev === null && session.wallet !== null) {
|
|
84909
|
+
this.wallet = session.wallet;
|
|
84527
84910
|
}
|
|
84528
84911
|
}
|
|
84529
|
-
const
|
|
84530
|
-
|
|
84912
|
+
const reported = refusedSwitch ? null : offered;
|
|
84913
|
+
const unchanged = prev !== null && reported !== null && prev.account.toLowerCase() === reported.account.toLowerCase() && prev.chainId === reported.chainId;
|
|
84914
|
+
if (unchanged || prev === null) {
|
|
84531
84915
|
this.ok(res);
|
|
84532
84916
|
return;
|
|
84533
84917
|
}
|
|
84534
|
-
const reason = refusedSwitch ? "the wallet switched to an account this session is not signed in as" : prev &&
|
|
84918
|
+
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";
|
|
84535
84919
|
for (const entry of this.pending.values()) {
|
|
84536
84920
|
if (entry.settled || entry.collect) continue;
|
|
84537
84921
|
if (this.ownedByWc(entry)) continue;
|
|
@@ -84556,6 +84940,100 @@ var SignatureBridge = class {
|
|
|
84556
84940
|
* Those entries instead fail fast at the per-entry grace, since `attachedFor` now reads
|
|
84557
84941
|
* false for them, and `unattendedReason` says plainly that the phone may already have
|
|
84558
84942
|
* acted. */
|
|
84943
|
+
/**
|
|
84944
|
+
* C-47, the THIRD door: a wallet announced a WalletConnect session. `requestSignature`
|
|
84945
|
+
* PREFERS the WalletConnect wallet over the approval page (see the `wcActive` branch there),
|
|
84946
|
+
* so an account admitted here does not merely become the candidate — it becomes the SIGNER,
|
|
84947
|
+
* and the page that showed its QR becomes the page that sees every card.
|
|
84948
|
+
*
|
|
84949
|
+
* The account a WalletConnect session carries is the wallet's own UNSIGNED claim — the
|
|
84950
|
+
* protocol validates its format, never its ownership. Admitting on that claim let anyone
|
|
84951
|
+
* holding the approval link answer their own QR with a scripted wallet claiming the user's
|
|
84952
|
+
* public address: it took the signer seat, its page saw every card, and an extension-only
|
|
84953
|
+
* user's ceremonies were routed to it (Sentinel 2 PoC-D). So this door now asks for the same
|
|
84954
|
+
* proof `hello` does: the wallet signs the presence statement of the page whose QR it
|
|
84955
|
+
* answered, and the signature must recover to the account it claims.
|
|
84956
|
+
*
|
|
84957
|
+
* Resolves `false` to refuse — the transport then keeps what it held and drops the wallet. If
|
|
84958
|
+
* the wallet declines the proof (or the request fails) the promise rejects and the transport
|
|
84959
|
+
* ends the session unadopted; nothing here is adopted before the proof checks out.
|
|
84960
|
+
*/
|
|
84961
|
+
async admitWcSession(info, transport) {
|
|
84962
|
+
const refusal = this.accountRefusal(info.account);
|
|
84963
|
+
if (refusal) return this.refuseWcSession(refusal);
|
|
84964
|
+
const ownerId = info.pairingId ? this.pairingOwners.get(info.pairingId) : void 0;
|
|
84965
|
+
if (info.pairingId) this.pairingOwners.delete(info.pairingId);
|
|
84966
|
+
const owner = ownerId ? this.sessions.get(ownerId) : void 0;
|
|
84967
|
+
if (!ownerId || !owner) {
|
|
84968
|
+
return this.refuseWcSession(
|
|
84969
|
+
"the wallet answered no QR code that an open approval page of this bridge showed \u2014 open the approval page and scan the QR code it shows"
|
|
84970
|
+
);
|
|
84971
|
+
}
|
|
84972
|
+
if (!info.prove || !info.live) {
|
|
84973
|
+
return this.refuseWcSession(
|
|
84974
|
+
"this WalletConnect transport cannot ask the wallet to prove its account (or report whether its session is still live), so no session can be admitted"
|
|
84975
|
+
);
|
|
84976
|
+
}
|
|
84977
|
+
const statement = presenceStatement(this.publicOrigin(), info.chainId, owner.presenceNonce);
|
|
84978
|
+
const signature = await info.prove(statement);
|
|
84979
|
+
const recovered = recoverPresenceSigner(statement, signature);
|
|
84980
|
+
if (recovered === null || recovered.toLowerCase() !== info.account.toLowerCase()) {
|
|
84981
|
+
return this.refuseWcSession(
|
|
84982
|
+
`the wallet claimed ${info.account} but ${recovered === null ? "returned no valid signature" : `signed with ${recovered}`} for the approval page's presence statement \u2014 an address alone proves nothing`
|
|
84983
|
+
);
|
|
84984
|
+
}
|
|
84985
|
+
if (this.wcTransport !== transport) {
|
|
84986
|
+
return this.refuseWcSession("the bridge's WalletConnect connection was replaced while the wallet was proving its account");
|
|
84987
|
+
}
|
|
84988
|
+
if (!info.live()) {
|
|
84989
|
+
return this.refuseWcSession("the wallet's WalletConnect session ended (or the relay failed) while it was proving its account \u2014 scan the QR again");
|
|
84990
|
+
}
|
|
84991
|
+
const lateRefusal = this.accountRefusal(info.account);
|
|
84992
|
+
if (lateRefusal) return this.refuseWcSession(lateRefusal);
|
|
84993
|
+
const page = this.sessions.get(ownerId);
|
|
84994
|
+
if (!page || page.refused) {
|
|
84995
|
+
return this.refuseWcSession("the approval page that showed this QR code closed while the wallet was proving its account \u2014 reopen it and scan again");
|
|
84996
|
+
}
|
|
84997
|
+
if (this.wcCreditedSession !== null && this.wcCreditedSession !== ownerId) {
|
|
84998
|
+
const previous = this.sessions.get(this.wcCreditedSession);
|
|
84999
|
+
if (previous) previous.wcPaired = false;
|
|
85000
|
+
}
|
|
85001
|
+
this.wcActive = true;
|
|
85002
|
+
this.wallet = { account: info.account, chainId: info.chainId };
|
|
85003
|
+
page.wcPaired = true;
|
|
85004
|
+
page.provenAccount = info.account;
|
|
85005
|
+
this.wcCreditedSession = ownerId;
|
|
85006
|
+
this.replayPending(page);
|
|
85007
|
+
return true;
|
|
85008
|
+
}
|
|
85009
|
+
/** Refuse a WalletConnect session — see `admitWcSession`. */
|
|
85010
|
+
refuseWcSession(reason) {
|
|
85011
|
+
if (!this.wcActive) {
|
|
85012
|
+
this.rebuildSharedWallet();
|
|
85013
|
+
this.demoteWcEntries();
|
|
85014
|
+
}
|
|
85015
|
+
process.stderr.write(`[bridge] WalletConnect session refused \u2014 ${reason}
|
|
85016
|
+
`);
|
|
85017
|
+
return false;
|
|
85018
|
+
}
|
|
85019
|
+
/** The admitted WalletConnect wallet went away. */
|
|
85020
|
+
onWcDisconnect() {
|
|
85021
|
+
this.wcActive = false;
|
|
85022
|
+
this.wallet = null;
|
|
85023
|
+
for (const entry of this.pending.values()) {
|
|
85024
|
+
if (!entry.settled && !entry.collect) {
|
|
85025
|
+
this.settle(entry, {
|
|
85026
|
+
status: "invalidated",
|
|
85027
|
+
reason: entry.dispatched && entry.request.kind === "transaction" ? "the WalletConnect session disconnected after being asked to send this transaction \u2014 it may have broadcast. Check the chain (or your wallet's activity) before retrying, or you may pay twice." : "the WalletConnect session disconnected"
|
|
85028
|
+
});
|
|
85029
|
+
}
|
|
85030
|
+
}
|
|
85031
|
+
if (this.wcCreditedSession !== null) {
|
|
85032
|
+
const credited = this.sessions.get(this.wcCreditedSession);
|
|
85033
|
+
if (credited) credited.wcPaired = false;
|
|
85034
|
+
this.wcCreditedSession = null;
|
|
85035
|
+
}
|
|
85036
|
+
}
|
|
84559
85037
|
demoteWcEntries() {
|
|
84560
85038
|
for (const entry of this.pending.values()) {
|
|
84561
85039
|
if (entry.settled || entry.owner !== "wc" || entry.dispatched) continue;
|
|
@@ -84574,6 +85052,10 @@ var SignatureBridge = class {
|
|
|
84574
85052
|
this.deny(res, 404, "unknown or already-settled requestId");
|
|
84575
85053
|
return;
|
|
84576
85054
|
}
|
|
85055
|
+
if (this.expireIfOverdue(entry)) {
|
|
85056
|
+
this.deny(res, 410, "this request has expired \u2014 retry the operation");
|
|
85057
|
+
return;
|
|
85058
|
+
}
|
|
84577
85059
|
if (entry.request.kind !== "personal-sign") {
|
|
84578
85060
|
this.deny(res, 400, "finalize applies only to personal-sign requests");
|
|
84579
85061
|
return;
|
|
@@ -84600,6 +85082,10 @@ var SignatureBridge = class {
|
|
|
84600
85082
|
this.deny(res, 404, "request settled while finalizing");
|
|
84601
85083
|
return;
|
|
84602
85084
|
}
|
|
85085
|
+
if (this.expireIfOverdue(entry)) {
|
|
85086
|
+
this.deny(res, 410, "this request expired while its payload was being prepared \u2014 retry the operation");
|
|
85087
|
+
return;
|
|
85088
|
+
}
|
|
84603
85089
|
entry.request.personalSign = fresh.personalSign;
|
|
84604
85090
|
entry.request.card = fresh.card;
|
|
84605
85091
|
}
|
|
@@ -84613,6 +85099,10 @@ var SignatureBridge = class {
|
|
|
84613
85099
|
this.deny(res, 404, "unknown or already-settled requestId");
|
|
84614
85100
|
return;
|
|
84615
85101
|
}
|
|
85102
|
+
if (this.expireIfOverdue(entry)) {
|
|
85103
|
+
this.deny(res, 410, "this request has expired \u2014 retry the operation");
|
|
85104
|
+
return;
|
|
85105
|
+
}
|
|
84616
85106
|
if (body["approved"] !== true) {
|
|
84617
85107
|
if (this.ownedByWc(entry) && entry.request.kind === "transaction") {
|
|
84618
85108
|
this.settle(entry, {
|
|
@@ -84661,6 +85151,16 @@ var SignatureBridge = class {
|
|
|
84661
85151
|
this.ok(res);
|
|
84662
85152
|
}
|
|
84663
85153
|
// ---- helpers ----
|
|
85154
|
+
/** Accept-time deadline check. The 1 s sweep is only the backstop: between the deadline and
|
|
85155
|
+
* the next tick a late click on /finalize or /result — or a WalletConnect dispatch — would
|
|
85156
|
+
* otherwise still ask for or accept a signature over a payload the protocol will refuse.
|
|
85157
|
+
* Settles the entry `expired` (the same outcome the sweep gives) and reports it. */
|
|
85158
|
+
expireIfOverdue(entry) {
|
|
85159
|
+
if (entry.settled) return true;
|
|
85160
|
+
if (this.clock() < entry.deadlineMs) return false;
|
|
85161
|
+
this.settle(entry, { status: "expired" });
|
|
85162
|
+
return true;
|
|
85163
|
+
}
|
|
84664
85164
|
settle(entry, outcome) {
|
|
84665
85165
|
entry.settled = true;
|
|
84666
85166
|
this.pending.delete(entry.request.id);
|
|
@@ -85042,6 +85542,7 @@ async function createRealBoundary(config, wallet, overrides) {
|
|
|
85042
85542
|
const manager = new SignerManager({
|
|
85043
85543
|
persistence: overrides?.signerPersistence?.(config.network) ?? fileSignerPersistence(stateFile),
|
|
85044
85544
|
initialMode,
|
|
85545
|
+
...overrides?.boundBorrower ? { authenticatedBorrower: import_ethers52.ethers.getAddress(overrides.boundBorrower) } : {},
|
|
85045
85546
|
candidate: () => bridge.walletState()?.account ?? null,
|
|
85046
85547
|
pendingCeremonies: () => bridge.pendingCount(),
|
|
85047
85548
|
keystore
|
|
@@ -85137,8 +85638,8 @@ async function buildBoundary(configResult, overrides) {
|
|
|
85137
85638
|
);
|
|
85138
85639
|
}
|
|
85139
85640
|
try {
|
|
85140
|
-
const decrypted = await
|
|
85141
|
-
if (!(decrypted instanceof
|
|
85641
|
+
const decrypted = await import_ethers53.ethers.Wallet.fromEncryptedJson(keystoreJson, config.keystorePassword);
|
|
85642
|
+
if (!(decrypted instanceof import_ethers53.ethers.Wallet)) {
|
|
85142
85643
|
return bootError("DH_KEYSTORE_PATH did not decrypt to an EOA wallet keystore.", ["DH_KEYSTORE_PATH"]);
|
|
85143
85644
|
}
|
|
85144
85645
|
wallet = decrypted;
|
|
@@ -85618,7 +86119,7 @@ on the real adapter and the mock.
|
|
|
85618
86119
|
**The walkthrough:**
|
|
85619
86120
|
1. \`signer_setup\` action \`use\`, mode \`external\`. The approval page auto-opens in the
|
|
85620
86121
|
desktop browser; ${approvalPageLocation(d)}
|
|
85621
|
-
2. On the page: connect the browser extension${d.walletConnect ? ", or \u2014 for a mobile wallet \u2014 scan the\n WalletConnect QR code or paste the pairing code. KEEP
|
|
86122
|
+
2. On the page: connect the browser extension${d.walletConnect ? ", or \u2014 for a mobile wallet \u2014 scan the\n WalletConnect QR code or paste the pairing code, then sign the short statement the wallet\n shows: it proves the wallet holds the address it reports, approves nothing and moves no\n funds, and without it the phone is not accepted. The proof needs an ordinary wallet account\n (EOA): a smart-contract or smart-account wallet cannot produce it, so it cannot connect\n here. KEEP THAT APPROVAL PAGE OPEN \u2014 the one\n whose QR you scanned: while a phone wallet is connected it is the READ-ONLY reader for\n every ceremony \u2014 it shows the full card, the phone shows only what a wallet can render,\n and you approve or decline in the phone. (Cancel still works from the page.) With no\n such page open, the phone is NOT asked to sign the opaque 32-byte hashes (loan and withdrawal\n envelopes) \u2014 those refuse, because a wallet shows them as a bare hash. Plain transactions and\n typed-data are not gated: the wallet decodes those itself." : ". " + phoneWalletOffer(d) + "."}
|
|
85622
86123
|
3. For authenticated reads before any write: \`signer_setup\` action \`connect\` runs the
|
|
85623
86124
|
login ceremony explicitly (one typed-data signature in the wallet).
|
|
85624
86125
|
4. The FIRST verified signature binds that wallet address as the borrower \u2014 it persists
|
|
@@ -86006,7 +86507,9 @@ plus one lit-ops login signature (read access). After that, every operation that
|
|
|
86006
86507
|
funds asks for its OWN approval in the user's wallet, every time \u2014 and reads never pop
|
|
86007
86508
|
the wallet. The login session lives ONLY in the server's memory: a server restart, or
|
|
86008
86509
|
an idle spell long enough that the tenant's world is evicted, means signing in again.
|
|
86009
|
-
That is the flip side of
|
|
86510
|
+
That is the flip side of never storing a login session at rest \u2014 a re-login is normal,
|
|
86511
|
+
not a fault. (The connector's own sign-in is a separate grant; /auth.md states whether
|
|
86512
|
+
this deployment keeps it across restarts.)
|
|
86010
86513
|
|
|
86011
86514
|
**What the hosted server IS trusted with** (the six residual trusts \u2014 state them
|
|
86012
86515
|
honestly when asked "is this safe"):
|
|
@@ -86275,7 +86778,7 @@ var import_mcp2 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
|
86275
86778
|
|
|
86276
86779
|
// src/tools/loan.ts
|
|
86277
86780
|
var import_zod = require("zod");
|
|
86278
|
-
var
|
|
86781
|
+
var import_ethers54 = require("ethers");
|
|
86279
86782
|
|
|
86280
86783
|
// src/util/format.ts
|
|
86281
86784
|
function bigintReplacer(_key, value) {
|
|
@@ -86463,7 +86966,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
86463
86966
|
const b = getB();
|
|
86464
86967
|
if (!b.ok) return renderError(b.error);
|
|
86465
86968
|
return renderEnvelope(
|
|
86466
|
-
await b.boundary.mintUcd({ positionId, amountUcdWei: (0,
|
|
86969
|
+
await b.boundary.mintUcd({ positionId, amountUcdWei: (0, import_ethers54.parseEther)(amountUcd.toString()).toString() })
|
|
86467
86970
|
);
|
|
86468
86971
|
})
|
|
86469
86972
|
);
|
|
@@ -86501,7 +87004,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
86501
87004
|
if (BigInt(detail.data.debtUcdWei) === 0n) return validationFailed("the position has no outstanding debt");
|
|
86502
87005
|
amountUcdWei = detail.data.debtUcdWei;
|
|
86503
87006
|
} else {
|
|
86504
|
-
amountUcdWei = (0,
|
|
87007
|
+
amountUcdWei = (0, import_ethers54.parseEther)(amountUcd.toString()).toString();
|
|
86505
87008
|
}
|
|
86506
87009
|
return renderEnvelope(await b.boundary.repayUcd({ positionId, amountUcdWei }));
|
|
86507
87010
|
})
|
|
@@ -87104,7 +87607,7 @@ function registerMockControlTool(server, control, chainId = 1337) {
|
|
|
87104
87607
|
|
|
87105
87608
|
// src/tools/signer.ts
|
|
87106
87609
|
var import_zod6 = require("zod");
|
|
87107
|
-
var
|
|
87610
|
+
var import_ethers55 = require("ethers");
|
|
87108
87611
|
var MODES = ["external", "keystore", "safe", "safe-module", "mock-simulated"];
|
|
87109
87612
|
var ACTIONS2 = ["status", "use", "reset-borrower", "unlock-keystore", "connect", "disconnect"];
|
|
87110
87613
|
var EXTERNAL_ONLY_MODES = ["external"];
|
|
@@ -87146,7 +87649,7 @@ function registerSignerTool(server, getRuntime, opts) {
|
|
|
87146
87649
|
if (mode !== void 0 && !offeredModes.includes(mode)) {
|
|
87147
87650
|
return validationFailed(looksSecretShaped(mode) ? SECRET_REFUSAL : `mode '${mode}' is not one of: ${offeredModes.join(" | ")}`);
|
|
87148
87651
|
}
|
|
87149
|
-
if (safeAddress !== void 0 && !
|
|
87652
|
+
if (safeAddress !== void 0 && !import_ethers55.ethers.isAddress(safeAddress)) {
|
|
87150
87653
|
return validationFailed(looksSecretShaped(safeAddress) ? SECRET_REFUSAL : `'${safeAddress}' is not a valid Safe address`);
|
|
87151
87654
|
}
|
|
87152
87655
|
if (action === "status") {
|
|
@@ -87157,9 +87660,9 @@ function registerSignerTool(server, getRuntime, opts) {
|
|
|
87157
87660
|
// Plan 16 A3 — provenance honesty: the assistant must never guess HOW an
|
|
87158
87661
|
// identity is known. borrower = a persisted binding; candidate = a live
|
|
87159
87662
|
// wallet connection in THIS process only.
|
|
87160
|
-
identityProvenance: s.borrower !== null ? `borrower ${s.borrower} is a PERSISTED binding (survives restarts until 'disconnect' or 'reset-borrower')` + (s.candidate !== null ? `; candidate ${s.candidate} is a LIVE wallet connection (approval page / WalletConnect, this process only)` : "") : s.candidate !== null ? `no borrower is bound; candidate ${s.candidate} is a LIVE wallet connection (approval page / WalletConnect, this process only) \u2014 the first verified signature binds it` : "no borrower is bound and no wallet is connected",
|
|
87663
|
+
identityProvenance: manager.identityPinned() ? `borrower ${s.borrower} is the wallet that signed this connector's login \u2014 it is your borrowing identity for this session and cannot be swapped, and only this wallet can approve writes` + (s.candidate !== null ? `; candidate ${s.candidate} is a LIVE wallet connection (approval page / WalletConnect, this process only)` : "") : s.borrower !== null ? `borrower ${s.borrower} is a PERSISTED binding (survives restarts until 'disconnect' or 'reset-borrower')` + (s.candidate !== null ? `; candidate ${s.candidate} is a LIVE wallet connection (approval page / WalletConnect, this process only)` : "") : s.candidate !== null ? `no borrower is bound; candidate ${s.candidate} is a LIVE wallet connection (approval page / WalletConnect, this process only) \u2014 the first verified signature binds it` : "no borrower is bound and no wallet is connected",
|
|
87161
87664
|
approvalPageUrl: bridge.url(),
|
|
87162
|
-
hint: s.mode === "none" ? manager.invitation() + (s.keystoreConfigured ? " Note: keystore material IS already configured \u2014 choosing 'keystore' (or 'safe') unlocks it automatically; the unlock page is only for NEW material." : "") : s.mode === "external" && !s.borrower && !s.candidate ? "External mode: open the approval page URL above and connect your wallet \u2014 it becomes your borrowing identity." : !s.keystoreUnlocked && s.keystoreConfigured ? `Active mode: ${s.mode}. Keystore material is configured \u2014 'use keystore' unlocks it automatically; the unlock page is only for NEW material.` : `Active mode: ${s.mode}. Writes still require confirmed:true, always.`
|
|
87665
|
+
hint: s.mode === "none" ? manager.invitation() + (s.keystoreConfigured ? " Note: keystore material IS already configured \u2014 choosing 'keystore' (or 'safe') unlocks it automatically; the unlock page is only for NEW material." : "") : s.mode === "external" && !s.borrower && !s.candidate ? "External mode: open the approval page URL above and connect your wallet \u2014 it becomes your borrowing identity." : s.mode === "external" && manager.identityPinned() && !s.candidate ? `Signed in as ${s.borrower}. Chain reads work now (position_status by id, protocol_status, btc_price). Listing positions (position_list borrower=${s.borrower}) goes through the authenticated indexer proxy and needs a lit-ops login: open the approval page URL above, connect THIS wallet (any other is refused), then run signer_setup 'connect' \u2014 one login signature that moves nothing. The same connected wallet approves writes.` : !s.keystoreUnlocked && s.keystoreConfigured ? `Active mode: ${s.mode}. Keystore material is configured \u2014 'use keystore' unlocks it automatically; the unlock page is only for NEW material.` : `Active mode: ${s.mode}. Writes still require confirmed:true, always.`
|
|
87163
87666
|
});
|
|
87164
87667
|
}
|
|
87165
87668
|
if (action === "use") {
|
|
@@ -87236,6 +87739,11 @@ function registerSignerTool(server, getRuntime, opts) {
|
|
|
87236
87739
|
});
|
|
87237
87740
|
}
|
|
87238
87741
|
if (action === "reset-borrower") {
|
|
87742
|
+
if (manager.identityPinned()) {
|
|
87743
|
+
return validationFailed(
|
|
87744
|
+
`the borrowing identity is ${manager.boundBorrower()} \u2014 the wallet that signed this connector's login \u2014 and cannot be swapped here. To act as a different wallet, sign in to the connector again with that wallet.`
|
|
87745
|
+
);
|
|
87746
|
+
}
|
|
87239
87747
|
manager.resetBorrower();
|
|
87240
87748
|
return ok({
|
|
87241
87749
|
reset: true,
|
|
@@ -87557,7 +88065,7 @@ function registerBoundaryInfoResource(server, getB) {
|
|
|
87557
88065
|
}
|
|
87558
88066
|
|
|
87559
88067
|
// src/version.ts
|
|
87560
|
-
var SERVER_VERSION = "0.5.
|
|
88068
|
+
var SERVER_VERSION = "0.5.22";
|
|
87561
88069
|
|
|
87562
88070
|
// src/server.ts
|
|
87563
88071
|
var SERVER_INSTRUCTIONS = "Diamond Hands MCP \u2014 Bitcoin-collateralized borrowing. Before promising ANY flow, read the boundary://info resource and honor its `capabilities` block: it states which network this server is on, whether money is real (practiceWorld), whether writes are enabled (and the true reason when they are not), and which signer modes this build actually offers \u2014 never describe a flow outside it. State the network and whether funds are real when the user first acts. Authorization is chosen by conversation via the signer_setup tool (when listed); writes always require confirmed:true after showing the human-readable card. For walkthroughs consult the guide tool / guide:// resources instead of inventing steps; when a tool refuses, relay its stated reason and remedy \u2014 do not improvise alternatives. When a network_switch tool is listed, the network can change mid-session \u2014 after ANY switch, re-read boundary://info and state the new network and money reality to the user before doing anything else. When the user asks to disconnect / log out / sign out / forget or remove their wallet, call signer_setup action 'disconnect' (the full flush) \u2014 never treat 'reset-borrower' as a disconnect; it only swaps identity. READING DATA: a payload's fields and notes are authoritative \u2014 state what they say, never speculate past them, and when the data does not carry something, say 'the data does not carry X'. Field meanings live in guide topic 'reading-data'; `reading` notes inside a result are interpretation instructions for that exact payload \u2014 follow them over any prior assumption.";
|