hd-wallet-ui 1.4.3 → 1.5.0
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/package.json +2 -2
- package/src/app.js +38 -52
- package/src/template.js +5 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hd-wallet-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "HD Wallet modal UI — login, keys, identity, trust map, and security bond. Attach to any button in your app.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/app.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"buffer": "^6.0.3",
|
|
41
41
|
"flatbuffers": "^25.9.23",
|
|
42
42
|
"flatc-wasm": "^26.1.15",
|
|
43
|
-
"hd-wallet-wasm": "^1.
|
|
43
|
+
"hd-wallet-wasm": "^1.5.0",
|
|
44
44
|
"qrcode": "^1.5.3",
|
|
45
45
|
"spacedatastandards.org": "^23.3.3-0.3.4",
|
|
46
46
|
"vcard-cryptoperson": "^1.1.11"
|
package/src/app.js
CHANGED
|
@@ -497,26 +497,12 @@ function deriveHDKey(path) {
|
|
|
497
497
|
}
|
|
498
498
|
}
|
|
499
499
|
|
|
500
|
-
function
|
|
501
|
-
if (!state.hdRoot
|
|
500
|
+
function deriveAccountPeerId() {
|
|
501
|
+
if (!state.hdRoot) return null;
|
|
502
502
|
try {
|
|
503
|
-
|
|
504
|
-
const derived = state.hdRoot.derivePath(path);
|
|
505
|
-
let pubKey, curve;
|
|
506
|
-
if (acct.coinType === 501) {
|
|
507
|
-
pubKey = ed25519.getPublicKey(derived.privateKey());
|
|
508
|
-
curve = Curve.ED25519;
|
|
509
|
-
} else {
|
|
510
|
-
pubKey = derived.publicKey();
|
|
511
|
-
curve = Curve.SECP256K1;
|
|
512
|
-
}
|
|
513
|
-
const peerIdBytes = state.hdWalletModule.libp2p.peerIdFromPublicKey(pubKey, curve);
|
|
514
|
-
return {
|
|
515
|
-
peerIdStr: state.hdWalletModule.libp2p.peerIdToString(peerIdBytes),
|
|
516
|
-
ipnsHash: state.hdWalletModule.libp2p.ipnsHash(peerIdBytes),
|
|
517
|
-
};
|
|
503
|
+
return state.hdRoot.peerIdString();
|
|
518
504
|
} catch (e) {
|
|
519
|
-
console.warn('Failed to derive
|
|
505
|
+
console.warn('Failed to derive account PeerID:', e);
|
|
520
506
|
return null;
|
|
521
507
|
}
|
|
522
508
|
}
|
|
@@ -1629,18 +1615,6 @@ async function showReceiveModal(acct) {
|
|
|
1629
1615
|
<h4 id="wallet-receive-title" class="section-label"></h4>
|
|
1630
1616
|
<canvas id="wallet-receive-qr"></canvas>
|
|
1631
1617
|
<code id="wallet-receive-address" class="wallet-receive-address"></code>
|
|
1632
|
-
<div id="wallet-receive-peer-section" class="wallet-receive-peer-section" style="display:none">
|
|
1633
|
-
<div class="wallet-receive-field">
|
|
1634
|
-
<span class="wallet-receive-field-label">PeerID</span>
|
|
1635
|
-
<code id="wallet-receive-peerid" class="wallet-receive-field-value"></code>
|
|
1636
|
-
<button id="wallet-receive-copy-peerid" class="glass-btn small">Copy</button>
|
|
1637
|
-
</div>
|
|
1638
|
-
<div class="wallet-receive-field">
|
|
1639
|
-
<span class="wallet-receive-field-label">IPNS</span>
|
|
1640
|
-
<code id="wallet-receive-ipns" class="wallet-receive-field-value"></code>
|
|
1641
|
-
<button id="wallet-receive-copy-ipns" class="glass-btn small">Copy</button>
|
|
1642
|
-
</div>
|
|
1643
|
-
</div>
|
|
1644
1618
|
<div class="wallet-receive-actions">
|
|
1645
1619
|
<button id="wallet-receive-copy" class="glass-btn small">Copy Address</button>
|
|
1646
1620
|
<button id="wallet-receive-close" class="glass-btn small">Close</button>
|
|
@@ -1655,18 +1629,6 @@ async function showReceiveModal(acct) {
|
|
|
1655
1629
|
if (titleEl) titleEl.textContent = `Receive ${acct.name}`;
|
|
1656
1630
|
if (addrEl) addrEl.textContent = acct.address;
|
|
1657
1631
|
|
|
1658
|
-
const peerSection = overlay.querySelector('#wallet-receive-peer-section');
|
|
1659
|
-
const peerIdEl = overlay.querySelector('#wallet-receive-peerid');
|
|
1660
|
-
const ipnsEl = overlay.querySelector('#wallet-receive-ipns');
|
|
1661
|
-
const peerInfo = derivePeerInfo(acct);
|
|
1662
|
-
if (peerInfo && peerSection) {
|
|
1663
|
-
peerSection.style.display = '';
|
|
1664
|
-
if (peerIdEl) peerIdEl.textContent = peerInfo.peerIdStr;
|
|
1665
|
-
if (ipnsEl) ipnsEl.textContent = peerInfo.ipnsHash;
|
|
1666
|
-
} else if (peerSection) {
|
|
1667
|
-
peerSection.style.display = 'none';
|
|
1668
|
-
}
|
|
1669
|
-
|
|
1670
1632
|
try {
|
|
1671
1633
|
const qrCanvas = overlay.querySelector('#wallet-receive-qr');
|
|
1672
1634
|
if (qrCanvas) {
|
|
@@ -1689,16 +1651,6 @@ async function showReceiveModal(acct) {
|
|
|
1689
1651
|
overlay.querySelector('#wallet-receive-close')?.addEventListener('click', () => {
|
|
1690
1652
|
overlay.style.display = 'none';
|
|
1691
1653
|
}, { once: true });
|
|
1692
|
-
|
|
1693
|
-
overlay.querySelector('#wallet-receive-copy-peerid')?.addEventListener('click', () => {
|
|
1694
|
-
const val = overlay.querySelector('#wallet-receive-peerid')?.textContent;
|
|
1695
|
-
if (val) navigator.clipboard.writeText(val).catch(() => {});
|
|
1696
|
-
}, { once: true });
|
|
1697
|
-
|
|
1698
|
-
overlay.querySelector('#wallet-receive-copy-ipns')?.addEventListener('click', () => {
|
|
1699
|
-
const val = overlay.querySelector('#wallet-receive-ipns')?.textContent;
|
|
1700
|
-
if (val) navigator.clipboard.writeText(val).catch(() => {});
|
|
1701
|
-
}, { once: true });
|
|
1702
1654
|
}
|
|
1703
1655
|
|
|
1704
1656
|
// =============================================================================
|
|
@@ -2537,6 +2489,7 @@ function login(keys) {
|
|
|
2537
2489
|
const xpub = state.hdRoot.toXpub();
|
|
2538
2490
|
_onLoginCallback({
|
|
2539
2491
|
xpub,
|
|
2492
|
+
peerId: deriveAccountPeerId(),
|
|
2540
2493
|
signingPublicKey: sdnPubKey,
|
|
2541
2494
|
async sign(message) {
|
|
2542
2495
|
const msgBytes = typeof message === 'string'
|
|
@@ -2594,6 +2547,16 @@ function login(keys) {
|
|
|
2594
2547
|
if (walletTabXpubEl) {
|
|
2595
2548
|
setTruncatedValue(walletTabXpubEl, state.hdRoot.toXpub() || 'N/A');
|
|
2596
2549
|
}
|
|
2550
|
+
// Populate wallet tab PeerID display
|
|
2551
|
+
const walletTabPeerIdEl = $('wallet-tab-peerid');
|
|
2552
|
+
const peerIdRow = $('ph-portfolio-peerid-row');
|
|
2553
|
+
if (walletTabPeerIdEl && peerIdRow) {
|
|
2554
|
+
const peerIdStr = deriveAccountPeerId();
|
|
2555
|
+
if (peerIdStr) {
|
|
2556
|
+
setTruncatedValue(walletTabPeerIdEl, peerIdStr);
|
|
2557
|
+
peerIdRow.style.display = '';
|
|
2558
|
+
}
|
|
2559
|
+
}
|
|
2597
2560
|
populateAccountAddressDropdown();
|
|
2598
2561
|
if (xprvEl) {
|
|
2599
2562
|
xprvEl.textContent = 'Hidden (click reveal)';
|
|
@@ -2857,6 +2820,27 @@ function populateAccountAddressDropdown() {
|
|
|
2857
2820
|
}
|
|
2858
2821
|
};
|
|
2859
2822
|
}
|
|
2823
|
+
|
|
2824
|
+
// Populate PeerID row (derived from account-level secp256k1 key)
|
|
2825
|
+
const peerIdStr = deriveAccountPeerId();
|
|
2826
|
+
const peerIdRow = $('account-peerid-row');
|
|
2827
|
+
const peerIdEl = $('account-peerid-display');
|
|
2828
|
+
if (peerIdStr && peerIdRow && peerIdEl) {
|
|
2829
|
+
peerIdRow.style.display = '';
|
|
2830
|
+
peerIdEl.textContent = `${peerIdStr.slice(0,8)}...${peerIdStr.slice(-8)}`;
|
|
2831
|
+
peerIdEl.title = peerIdStr;
|
|
2832
|
+
}
|
|
2833
|
+
const peerCopyBtn = $('account-peerid-copy');
|
|
2834
|
+
if (peerCopyBtn) {
|
|
2835
|
+
peerCopyBtn.onclick = () => {
|
|
2836
|
+
if (peerIdStr) {
|
|
2837
|
+
navigator.clipboard.writeText(peerIdStr).then(() => {
|
|
2838
|
+
peerCopyBtn.title = 'Copied!';
|
|
2839
|
+
setTimeout(() => { peerCopyBtn.title = 'Copy PeerID'; }, 1500);
|
|
2840
|
+
});
|
|
2841
|
+
}
|
|
2842
|
+
};
|
|
2843
|
+
}
|
|
2860
2844
|
}
|
|
2861
2845
|
|
|
2862
2846
|
function populateWalletAddresses() {
|
|
@@ -4581,6 +4565,8 @@ function setupMainAppHandlers() {
|
|
|
4581
4565
|
let value = '';
|
|
4582
4566
|
if (targetId === 'wallet-xpub' || targetId === 'wallet-tab-xpub') {
|
|
4583
4567
|
value = state.hdRoot?.toXpub?.() || '';
|
|
4568
|
+
} else if (targetId === 'wallet-tab-peerid') {
|
|
4569
|
+
value = deriveAccountPeerId() || '';
|
|
4584
4570
|
} else if (targetId === 'wallet-xprv') {
|
|
4585
4571
|
if (targetEl.dataset.revealed !== 'true') {
|
|
4586
4572
|
alert('Reveal the xprv first to copy it.');
|
package/src/template.js
CHANGED
|
@@ -3,7 +3,7 @@ export function getModalHTML() {
|
|
|
3
3
|
<!-- Keys Modal -->
|
|
4
4
|
<div id="keys-modal" class="modal">
|
|
5
5
|
<div class="modal-glass modal-wide">
|
|
6
|
-
<div class="modal-header"><div class="account-header-info"><div class="account-header-top"><h3>Account</h3><h3 class="account-total-value" id="account-total-value"></h3></div><div class="account-address-row"><span class="account-address-label">xpub</span><code class="account-address-display" id="account-address-display"></code><button class="account-address-copy" id="account-address-copy" title="Copy xpub"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg></button></div></div><button class="modal-close">×</button></div>
|
|
6
|
+
<div class="modal-header"><div class="account-header-info"><div class="account-header-top"><h3>Account</h3><h3 class="account-total-value" id="account-total-value"></h3></div><div class="account-address-row"><span class="account-address-label">xpub</span><code class="account-address-display" id="account-address-display"></code><button class="account-address-copy" id="account-address-copy" title="Copy xpub"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg></button></div><div class="account-address-row" id="account-peerid-row" style="display:none"><span class="account-address-label">PeerID</span><code class="account-address-display" id="account-peerid-display"></code><button class="account-address-copy" id="account-peerid-copy" title="Copy PeerID"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg></button></div></div><button class="modal-close">×</button></div>
|
|
7
7
|
<div class="modal-tabs">
|
|
8
8
|
<button class="modal-tab active" data-modal-tab="vcard-tab-content">Identity</button>
|
|
9
9
|
<button class="modal-tab" data-modal-tab="trust-tab-content">Trust Map</button>
|
|
@@ -23,6 +23,10 @@ export function getModalHTML() {
|
|
|
23
23
|
<code id="wallet-tab-xpub" class="ph-xpub-text truncate"></code>
|
|
24
24
|
<button class="ph-xpub-copy copy-key-btn" data-copy="wallet-tab-xpub" title="Copy xPub"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg></button>
|
|
25
25
|
</div>
|
|
26
|
+
<div class="ph-portfolio-xpub" id="ph-portfolio-peerid-row" style="display:none">
|
|
27
|
+
<code id="wallet-tab-peerid" class="ph-xpub-text truncate"></code>
|
|
28
|
+
<button class="ph-xpub-copy copy-key-btn" data-copy="wallet-tab-peerid" title="Copy PeerID"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg></button>
|
|
29
|
+
</div>
|
|
26
30
|
</div>
|
|
27
31
|
|
|
28
32
|
<div class="wallet-selector-row">
|