🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP →
Sign In

yaver-cli

Package Overview
Dependencies
Maintainers
1
Versions
292
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yaver-cli - npm Package Compare versions

Comparing version
1.99.304
to
1.99.305
+1
-1
package.json
{
"name": "yaver-cli",
"version": "1.99.304",
"version": "1.99.305",
"mcpName": "io.github.kivanccakmak/yaver",

@@ -5,0 +5,0 @@ "description": "Unified npm bootstrap for the Yaver agent, SDK injection, and local-first developer runtime",

@@ -6,3 +6,5 @@ const http = require('http');

const BEACON_PORT = 19837;
const DISCOVERY_TIMEOUT = 5000;
const DISCOVERY_TIMEOUT = 1500;
const HEALTH_TIMEOUT = 1200;
const LAN_SCAN_TIMEOUT = 350;

@@ -70,6 +72,6 @@ /**

/** Fetch /health from a device */
function fetchHealth(device) {
function fetchHealth(device, timeout = HEALTH_TIMEOUT) {
return new Promise((resolve, reject) => {
const url = `http://${device.ip}:${device.port || YAVER_PORT}/health`;
const req = http.get(url, { timeout: 5000 }, (res) => {
const req = http.get(url, { timeout }, (res) => {
let data = '';

@@ -98,2 +100,3 @@ res.on('data', chunk => data += chunk);

const found = [];
const seen = new Set();

@@ -105,13 +108,17 @@ for (const [, addrs] of Object.entries(interfaces)) {

const subnet = addr.address.split('.').slice(0, 3).join('.');
const promises = [];
const ips = [];
for (let i = 1; i <= 254; i++) {
const ip = `${subnet}.${i}`;
if (ip === addr.address) continue;
promises.push(
fetchHealth({ ip, port: YAVER_PORT })
.then(h => found.push({ ip, port: YAVER_PORT, name: h.deviceName, platform: h.platform }))
.catch(() => {})
);
ips.push(ip);
}
await Promise.all(promises);
await runLimited(ips, 48, async (ip) => {
try {
const h = await fetchHealth({ ip, port: YAVER_PORT }, LAN_SCAN_TIMEOUT);
const key = h.deviceId || `${ip}:${YAVER_PORT}`;
if (seen.has(key)) return;
seen.add(key);
found.push({ ip, port: YAVER_PORT, name: h.deviceName, platform: h.platform });
} catch {}
});
}

@@ -123,2 +130,14 @@ }

async function runLimited(items, limit, fn) {
let next = 0;
const workers = Array.from({ length: Math.min(limit, items.length) }, async () => {
for (;;) {
const idx = next++;
if (idx >= items.length) return;
await fn(items[idx]);
}
});
await Promise.all(workers);
}
module.exports = { discoverDevice, fetchHealth, scanLAN, YAVER_PORT };