
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
@prsm/duplex
Advanced tools
[](https://www.npmjs.com/package/@prsm/duplex)
An optionally-secure, full-duplex TCP command server and client built on top of node:tls
and node:net
. Provides reliable, Promise-based communication with automatic reconnection and command queueing.
import { CommandServer } from "@prsm/duplex";
import fs from "node:fs";
// Create a server instance
const server = new CommandServer({
host: "localhost",
port: 3351,
secure: false, // For TLS, set to true and provide certificates
});
// Connect the server (returns a Promise)
await server.connect();
// Register command handlers
server.command(0, async (payload, connection) => {
console.log("Received:", payload);
return { status: "success", data: "Command processed" };
});
// For secure connections (TLS)
const secureServer = new CommandServer({
host: "localhost",
port: 3352,
secure: true,
key: fs.readFileSync("certs/server/server.key"),
cert: fs.readFileSync("certs/server/server.crt"),
ca: fs.readFileSync("certs/server/ca.crt"),
requestCert: true,
});
await secureServer.connect();
import { CommandClient } from "@prsm/duplex";
import fs from "node:fs";
// Create a client instance
const client = new CommandClient({
host: "localhost",
port: 3351,
secure: false, // For TLS, set to true and provide certificates
});
// Connect to the server (returns a Promise)
await client.connect();
// Using Promise-based API
try {
const response = await client.command(0, { action: "getData" }, 5000);
console.log("Response:", response.result);
} catch (error) {
console.error("Error:", error);
}
// Using callback API
client.command(0, { action: "getData" }, 5000, (result, error) => {
if (error) {
console.error("Error:", error);
return;
}
console.log("Response:", result);
});
// For secure connections (TLS)
const secureClient = new CommandClient({
host: "localhost",
port: 3352,
secure: true,
key: fs.readFileSync("certs/client/client.key"),
cert: fs.readFileSync("certs/client/client.crt"),
ca: fs.readFileSync("certs/ca/ca.crt"),
});
await secureClient.connect();
The library provides detailed error information with error codes:
try {
await client.command(0, payload, 1000);
} catch (error) {
if (error.code === 'ETIMEOUT') {
console.log('Command timed out');
} else if (error.code === 'ENOTFOUND') {
console.log('Command not found on server');
} else {
console.error('Other error:', error.message);
}
}
// Close client connection
await client.close();
// Close server
await server.close();
FAQs
[](https://www.npmjs.com/package/@prsm/duplex)
We found that @prsm/duplex demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.