hd-wallet-ui 1.2.2 → 1.2.4
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 +34 -7
- package/src/template.js +3 -4
- package/styles/main.css +13 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hd-wallet-ui",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
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",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"buffer": "^6.0.3",
|
|
36
36
|
"flatbuffers": "^25.9.23",
|
|
37
37
|
"flatc-wasm": "^25.12.19-wasm.43",
|
|
38
|
-
"hd-wallet-wasm": "^1.2.
|
|
38
|
+
"hd-wallet-wasm": "^1.2.4",
|
|
39
39
|
"qrcode": "^1.5.3",
|
|
40
40
|
"spacedatastandards.org": "^23.3.3-0.3.4",
|
|
41
41
|
"vcard-cryptoperson": "^1.1.11"
|
package/src/app.js
CHANGED
|
@@ -204,6 +204,9 @@ async function p384GenerateKeyPairAsync() {
|
|
|
204
204
|
// State
|
|
205
205
|
// =============================================================================
|
|
206
206
|
|
|
207
|
+
// Integration callback — set via options.onLogin in createWalletUI / init
|
|
208
|
+
let _onLoginCallback = null;
|
|
209
|
+
|
|
207
210
|
const state = {
|
|
208
211
|
initialized: false,
|
|
209
212
|
loggedIn: false,
|
|
@@ -1297,9 +1300,10 @@ async function scanActiveAccounts() {
|
|
|
1297
1300
|
updateWalletBondTotal();
|
|
1298
1301
|
|
|
1299
1302
|
const statusEl = $('wallet-scan-status');
|
|
1300
|
-
const
|
|
1303
|
+
const barEl = $('wallet-scan-bar');
|
|
1301
1304
|
const scanBtn = $('wallet-scan-btn');
|
|
1302
|
-
if (statusEl) statusEl.style.display = '
|
|
1305
|
+
if (statusEl) statusEl.style.display = 'block';
|
|
1306
|
+
if (barEl) barEl.style.width = '0%';
|
|
1303
1307
|
if (scanBtn) scanBtn.disabled = true;
|
|
1304
1308
|
|
|
1305
1309
|
try {
|
|
@@ -1329,10 +1333,9 @@ async function scanActiveAccounts() {
|
|
|
1329
1333
|
});
|
|
1330
1334
|
});
|
|
1331
1335
|
|
|
1332
|
-
for (
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
}
|
|
1336
|
+
for (let ti = 0; ti < targets.length; ti++) {
|
|
1337
|
+
const target = targets[ti];
|
|
1338
|
+
if (barEl) barEl.style.width = Math.round(((ti + 1) / targets.length) * 100) + '%';
|
|
1336
1339
|
|
|
1337
1340
|
let derived;
|
|
1338
1341
|
try {
|
|
@@ -2375,6 +2378,27 @@ function login(keys) {
|
|
|
2375
2378
|
state.addresses = deriveAllAddressesFromHD();
|
|
2376
2379
|
state.selectedCrypto = 'btc';
|
|
2377
2380
|
|
|
2381
|
+
// Fire onLogin callback with SDN identity (coin type 9999)
|
|
2382
|
+
if (_onLoginCallback && state.hdRoot) {
|
|
2383
|
+
try {
|
|
2384
|
+
const sdnSigning = getSigningKey(state.hdRoot, 9999, 0, 0);
|
|
2385
|
+
const sdnPubKey = ed25519.getPublicKey(sdnSigning.privateKey);
|
|
2386
|
+
const xpub = state.hdRoot.toXpub();
|
|
2387
|
+
_onLoginCallback({
|
|
2388
|
+
xpub,
|
|
2389
|
+
signingPublicKey: sdnPubKey,
|
|
2390
|
+
async sign(message) {
|
|
2391
|
+
const msgBytes = typeof message === 'string'
|
|
2392
|
+
? new TextEncoder().encode(message)
|
|
2393
|
+
: message;
|
|
2394
|
+
return ed25519.sign(msgBytes, sdnSigning.privateKey);
|
|
2395
|
+
},
|
|
2396
|
+
});
|
|
2397
|
+
} catch (err) {
|
|
2398
|
+
console.error('onLogin callback error:', err);
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
|
|
2378
2402
|
// Close login modal if open
|
|
2379
2403
|
$('login-modal')?.classList.remove('active');
|
|
2380
2404
|
|
|
@@ -5224,9 +5248,10 @@ function setupHomepageHandlers() {
|
|
|
5224
5248
|
// =============================================================================
|
|
5225
5249
|
|
|
5226
5250
|
export async function init(rootElement, options = {}) {
|
|
5227
|
-
const { autoOpenWallet = false } = typeof rootElement === 'object' && !(rootElement instanceof Node)
|
|
5251
|
+
const { autoOpenWallet = false, onLogin = null } = typeof rootElement === 'object' && !(rootElement instanceof Node)
|
|
5228
5252
|
? (options = rootElement, {}) : options;
|
|
5229
5253
|
if (rootElement && rootElement instanceof Node) _root = rootElement;
|
|
5254
|
+
if (typeof onLogin === 'function') _onLoginCallback = onLogin;
|
|
5230
5255
|
|
|
5231
5256
|
// Inject modal HTML if not already present in the DOM
|
|
5232
5257
|
if (!document.getElementById('keys-modal')) {
|
|
@@ -5337,6 +5362,8 @@ export async function init(rootElement, options = {}) {
|
|
|
5337
5362
|
*
|
|
5338
5363
|
* @param {Node} [rootElement] - Optional root element for DOM queries
|
|
5339
5364
|
* @param {Object} [options] - Options passed to init()
|
|
5365
|
+
* @param {Function} [options.onLogin] - Callback fired after successful login with
|
|
5366
|
+
* `{ xpub, signingPublicKey, sign(message) }` for SDN identity (coin type 9999)
|
|
5340
5367
|
* @returns {Promise<{openLogin: Function, openAccount: Function, destroy: Function}>}
|
|
5341
5368
|
*/
|
|
5342
5369
|
export async function createWalletUI(rootElement, options = {}) {
|
package/src/template.js
CHANGED
|
@@ -70,10 +70,9 @@ export function getModalHTML() {
|
|
|
70
70
|
</button>
|
|
71
71
|
</div>
|
|
72
72
|
|
|
73
|
-
<!-- Scan
|
|
74
|
-
<div id="wallet-scan-status" class="
|
|
75
|
-
<div class="wallet-scan-
|
|
76
|
-
<span id="wallet-scan-label">Scanning derivation paths...</span>
|
|
73
|
+
<!-- Scan Progress Bar -->
|
|
74
|
+
<div id="wallet-scan-status" class="wallet-scan-progress" style="display:none;">
|
|
75
|
+
<div id="wallet-scan-bar" class="wallet-scan-bar"></div>
|
|
77
76
|
</div>
|
|
78
77
|
|
|
79
78
|
<!-- Token List -->
|
package/styles/main.css
CHANGED
|
@@ -2081,30 +2081,21 @@ body:has(.modal.active) .nav-bar {
|
|
|
2081
2081
|
cursor: not-allowed;
|
|
2082
2082
|
}
|
|
2083
2083
|
|
|
2084
|
-
/* Scan
|
|
2085
|
-
.
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
margin-bottom:
|
|
2091
|
-
font-size: 12px;
|
|
2092
|
-
color: var(--muted);
|
|
2093
|
-
background: var(--white-05);
|
|
2094
|
-
border-radius: 12px;
|
|
2095
|
-
}
|
|
2096
|
-
|
|
2097
|
-
.wallet-scan-spinner {
|
|
2098
|
-
width: 14px;
|
|
2099
|
-
height: 14px;
|
|
2100
|
-
border: 2px solid var(--glass-border);
|
|
2101
|
-
border-top-color: #AB82FF;
|
|
2102
|
-
border-radius: 50%;
|
|
2103
|
-
animation: spin 0.8s linear infinite;
|
|
2084
|
+
/* Scan Progress Bar */
|
|
2085
|
+
.wallet-scan-progress {
|
|
2086
|
+
height: 2px;
|
|
2087
|
+
background: var(--glass-border);
|
|
2088
|
+
border-radius: 1px;
|
|
2089
|
+
overflow: hidden;
|
|
2090
|
+
margin-bottom: 4px;
|
|
2104
2091
|
}
|
|
2105
2092
|
|
|
2106
|
-
|
|
2107
|
-
|
|
2093
|
+
.wallet-scan-bar {
|
|
2094
|
+
height: 100%;
|
|
2095
|
+
width: 0%;
|
|
2096
|
+
background: #22c55e;
|
|
2097
|
+
border-radius: 1px;
|
|
2098
|
+
transition: width 0.3s ease;
|
|
2108
2099
|
}
|
|
2109
2100
|
|
|
2110
2101
|
/* Token List */
|