Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
node-workman-worker
Advanced tools
Worker library for node-workman.
Written in TypeScript and the definitions (.d.ts
-files) are published in NPM
with the rest of the files.
Add the library with yarn
yarn add node-workman-worker
Or with NPM
npm install node-workman-worker
Then import the library in your code
import {worker} from "node-workman-worker"
Create your task handlers
interface Calculation {
a: number
b: number
}
async function work(data: Calculation): Promise<any> {
return data.a + data.b
}
async function waitAndWork(data: Calculation): Promise<any> {
return new Promise<any>(function(resolve: {(result: any): void}) {
setTimeout(function() {
resolve(data.a + data.b)
}, 1000)
})
}
And register them before running the core worker logic.
worker.registerTask("work", work)
worker.registerTask("wait", waitAndWork)
worker.run({
server: "ws://localhost:9999/worker"
})
That's it. Nothing more required. Simple, right?
You can check the full example src/test-worker.ts
Fine, this was written in TypeScript but nothing is stopping you from using plain JavaScript as long as you can live with the fact that I'm probably disgusted with you.
Here's a simple example:
const worker = require('node-workman-worker').worker;
async function work(options) {
return options.a + options.b
}
worker.registerTask("work", work)
worker.run({
server: "ws://localhost:9999/worker"
})
Pull requests and issues are open for any good ideas, but please keep in mind that this is supposed to stay fairly simple. If in doubt, open an issue to ask if your proposed idea would be accepted.
To run the typescript compiler and the test worker (src/test-worker.ts
) just
run:
yarn dev
MIT. Need a more open license? Just ask.
FAQs
Worker library for node-workman
The npm package node-workman-worker receives a total of 0 weekly downloads. As such, node-workman-worker popularity was classified as not popular.
We found that node-workman-worker 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.