
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
A web hook for a web socket broadcast server.
npm install sock-hook
var sockhook = require('sock-hook')
var sockhook = require('<path_to_file>/sock-hook.js')
Currently only http or https is supported, not both at once.
var sock = require('sock-hook');
// first object is api config, second is socket server config
sock.createServer({port: 80}, {port:8080});
An options object is used to store all options for the sock-hook server.
NOTE: The "api-server" port may not be the same as the "socket-server" port.
{
"api-server": {
"port": 80,
"ssl": {
"cert": "<path_to_cert>",
"key": "<path_to_key>",
"ca": "<path_to_ca>",
"<express SSL options>..."
}
},
"socket-server": {
"port": 8080,
"cors": ["*"],
"ssl": {
"cert": "<path_to_cert>",
"key": "<path_to_key>",
"ca": "<path_to_ca>"
}
}
}
Both the API and Socket Server have the ability to use https, the same or different ssl credentials can be used for both.
NOTE:* You may pass in a file path to the certs or the 'utf-8' contents of the cert/key files.
var sock = require('sock-hook');
// to read ssl files
var fs = require('fs');
// ssl file options
var options = {
cert: <path_to_cert>,
key: <path_to_key>
}
// first object is api config, second is socket server config
sock.createServer({port: 80, ssl: options}, {port: 8080, ssl: options});
For the "api-server" configuration you may setup CORS to restrict the API relay access. This is set up by passing an array of allowed URLs in the "api-server" options.
...
"cors": ["*"],
...
sock-hook uses express for the api routing.
Access the router and add a custom express route.
Then access the socket server and forward the data.
var sock = require('sock-hook');
var server = sock.createServer({port: 80}, {port:8080});
// router object
var router = server.router;
// socket server object
var socketServer = server.socketServer.wicker;
// route
router.post('/send',function(req,res) {
// send to all connections
socketServer.sendToAll(req.body);
res.sendStatus(200);
});
To see more socket functions, refer to https://github.com/ianfoose/wicker
FAQs
An API hook to send data from an endpoint to a socket server.
The npm package sock-hook receives a total of 11 weekly downloads. As such, sock-hook popularity was classified as not popular.
We found that sock-hook demonstrated a not healthy version release cadence and project activity because the last version was released 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
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.