@hivescale/connect-node
v0.0.2
Published
HiveScale application-scoped network client for Node.js
Readme
HiveScale Node.js Connect SDK
@hivescale/connect-node provides application-scoped access to a HiveScale
network. It does not install a system VPN or change system DNS. Only requests
created by the SDK use the connected network.
The first version exposes:
connect()andstatus()for lifecycle state.fetch()for HTTP/HTTPS through MagicDNS.dialTCP()for Nodenet.Socketstreams.dialUDP()for connected UDP datagrams.close()for stopping the local helper.
Helper
Node.js cannot link the Go userspace core directly. The package starts the
hivescale-connectd binary and uses its loopback SOCKS5 boundary. A packaged
platform binary is preferred automatically; otherwise build the helper and
make it available in PATH, or pass its path explicitly with helperPath.
Build all release targets from the monorepo:
cd libs/node-connect
./scripts/build-helper.shThe output is written under libs/node-connect/bin using the names
hivescale-connectd-<platform>-<arch>. The release job must run this step
before npm publish.
cd libs/go-connect
GOWORK=off go build -o /tmp/hivescale-connectd ./cmd/hivescale-connectdExample
import { createClient } from '@hivescale/connect-node';
const client = createClient({
helperPath: '/tmp/hivescale-connectd',
authKey: shortLivedAuthKey,
hostname: 'node-service',
ephemeral: true,
});
await client.connect();
const response = await client.fetch('http://fileserver:8080/health');
console.log(await response.text());
const tcp = await client.dialTCP('dbserver', 5432);
tcp.write('ping');
const udp = await client.dialUDP('metrics', 8125);
udp.on('message', (data) => console.log(data));
await udp.send(Buffer.from('metric'));
await client.close();Use a short-lived AuthKey for application instances. The helper returns loopback-only, runtime-generated proxy credentials and does not expose them to remote clients.
