@bulolo/hermes-link 0.2.7 → 0.2.9
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.
|
@@ -1462,29 +1462,20 @@ function normalizeLogLevel(level) {
|
|
|
1462
1462
|
return defaultLinkConfig.logLevel;
|
|
1463
1463
|
}
|
|
1464
1464
|
function normalizeLanHost(value) {
|
|
1465
|
-
if (value === null || value === void 0)
|
|
1466
|
-
|
|
1467
|
-
}
|
|
1468
|
-
if (typeof value !== "string") {
|
|
1469
|
-
return null;
|
|
1470
|
-
}
|
|
1465
|
+
if (value === null || value === void 0) return null;
|
|
1466
|
+
if (typeof value !== "string") return null;
|
|
1471
1467
|
const host = value.trim().replace(/^\[/u, "").replace(/\]$/u, "");
|
|
1472
|
-
if (!host)
|
|
1473
|
-
|
|
1474
|
-
}
|
|
1475
|
-
if (!isUsableLanIpv4(host)) {
|
|
1476
|
-
return null;
|
|
1477
|
-
}
|
|
1468
|
+
if (!host) return null;
|
|
1469
|
+
if (!isValidHostIpv4(host)) return null;
|
|
1478
1470
|
return host;
|
|
1479
1471
|
}
|
|
1480
|
-
function
|
|
1472
|
+
function isValidHostIpv4(value) {
|
|
1481
1473
|
const parts = value.split(".").map((part) => Number.parseInt(part, 10));
|
|
1482
1474
|
if (parts.length !== 4 || parts.some((part) => !Number.isInteger(part) || part < 0 || part > 255)) {
|
|
1483
1475
|
return false;
|
|
1484
1476
|
}
|
|
1485
|
-
const [
|
|
1486
|
-
|
|
1487
|
-
return privateRange && fourth !== 0 && fourth !== 255;
|
|
1477
|
+
const [, , , fourth] = parts;
|
|
1478
|
+
return fourth !== 0 && fourth !== 255;
|
|
1488
1479
|
}
|
|
1489
1480
|
|
|
1490
1481
|
// src/network/topology.ts
|
|
@@ -1517,7 +1508,7 @@ function discoverLanIpsFromInterfaces(interfaces) {
|
|
|
1517
1508
|
for (const [name, items] of Object.entries(interfaces)) {
|
|
1518
1509
|
if (shouldIgnoreInterface(name)) continue;
|
|
1519
1510
|
for (const item of items ?? []) {
|
|
1520
|
-
if (!item.internal && item.address && item.family === "IPv4" &&
|
|
1511
|
+
if (!item.internal && item.address && item.family === "IPv4" && isUsableLanIpv4(item.address, item.netmask)) {
|
|
1521
1512
|
candidates.push({ name, address: item.address });
|
|
1522
1513
|
}
|
|
1523
1514
|
}
|
|
@@ -1593,7 +1584,7 @@ function compareLanCandidate(left, right) {
|
|
|
1593
1584
|
function interfacePriority(name) {
|
|
1594
1585
|
return /^(en|eth|wlan|wi-fi|wifi)/iu.test(name) ? 0 : 1;
|
|
1595
1586
|
}
|
|
1596
|
-
function
|
|
1587
|
+
function isUsableLanIpv4(address, netmask) {
|
|
1597
1588
|
return isPrivateIpv4(address) && !isNetworkOrBroadcastIpv4Address(address, netmask);
|
|
1598
1589
|
}
|
|
1599
1590
|
function isUsablePublicIpv4(address) {
|
|
@@ -3594,14 +3585,36 @@ function buildPairingPage(options) {
|
|
|
3594
3585
|
</div>
|
|
3595
3586
|
<script>
|
|
3596
3587
|
async function pair() {
|
|
3597
|
-
const token = document.getElementById('token').textContent;
|
|
3588
|
+
const token = document.getElementById('token').textContent.trim();
|
|
3589
|
+
const btn = document.querySelector('button');
|
|
3590
|
+
btn.disabled = true;
|
|
3591
|
+
btn.textContent = 'Pairing...';
|
|
3598
3592
|
try {
|
|
3599
|
-
const res = await fetch('
|
|
3600
|
-
|
|
3593
|
+
const res = await fetch('/api/v1/auth/device-session', {
|
|
3594
|
+
method: 'POST',
|
|
3595
|
+
headers: {
|
|
3596
|
+
'Authorization': 'Bearer ' + token,
|
|
3597
|
+
'Content-Type': 'application/json'
|
|
3598
|
+
},
|
|
3599
|
+
body: JSON.stringify({
|
|
3600
|
+
device_label: navigator.userAgent.slice(0, 64),
|
|
3601
|
+
device_platform: 'web'
|
|
3602
|
+
})
|
|
3603
|
+
});
|
|
3604
|
+
const data = await res.json();
|
|
3605
|
+
if (res.ok && data.access_token) {
|
|
3601
3606
|
document.getElementById('status').style.display = 'block';
|
|
3607
|
+
document.getElementById('status').innerHTML =
|
|
3608
|
+
'Paired! Access token:<br><code style="font-size:0.75rem;word-break:break-all">' +
|
|
3609
|
+
data.access_token.token + '</code>';
|
|
3610
|
+
btn.textContent = 'Paired';
|
|
3611
|
+
} else {
|
|
3612
|
+
throw new Error(data.error?.message || JSON.stringify(data));
|
|
3602
3613
|
}
|
|
3603
3614
|
} catch (e) {
|
|
3604
|
-
|
|
3615
|
+
btn.disabled = false;
|
|
3616
|
+
btn.textContent = 'Pair This Device';
|
|
3617
|
+
alert('Pairing failed: ' + e.message);
|
|
3605
3618
|
}
|
|
3606
3619
|
}
|
|
3607
3620
|
</script>
|
package/dist/cli/index.js
CHANGED
package/dist/http/app.js
CHANGED