Research
Recent Trends in Malicious Packages Targeting Discord
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
comlink-everywhere
Advanced tools
Readme
comlink-everywhere
This is a workaround to help patch inconsistent environments until module workers (and eventually module block workers) are available everywhere. Module workers are:
node
(with an API significantly differing from all other environments), and deno
.It also helps test bundler compat issues like snowpackjs/snowpack#3476
// index.js
import { workerFileConstructor, wrap } from "comlink-everywhere/outside";
(async () => {
const Worker = await workerFileConstructor();
const api = wrap(
new Worker(new URL("./worker.js", import.meta.url), { type: "module" })
);
console.log(await api.add(3, 4));
})();
// worker.js
import { expose } from "comlink-everywhere/inside";
expose({
add: (x, y) => x + y,
});
import { constructWorkerFromString } from "comlink-everywhere/outside";
(async () => {
const worker = await constructWorkerFromString(
// Note: this example only works in browsers.
`self.postMessage("from worker");`
);
worker.addEventListener("message", (message) => console.log(message.data));
})();
For maximum compatibility in the short term, the best option is to compile the worker into a source string that does not use any imports, and does not use any syntax or functions specific to CommonJS (e.g. require()
), ESM (e.g. import
), or the web (e.g. importScripts()
)
node
, the type
option will be ignored and the worker will be instantiated as a classic/module worker matching the calling code. See https://github.com/nodejs/node/issues/30682Worker
constructor cannot be retrieved synchronously.
node
constructor for better compatibility (by not importing node
modules unless necessary), which means it is not available synchronously..terminate()
is not currently available on node
workers. Please file an issue if you want to use this library and be able to call .terminate()
.
.unref()
for node
workers, which means they will not hold up program exit.FAQs
This is a workaround to help patch inconsistent environments until module workers (and eventually [module block](https://github.com/tc39/proposal-js-module-blocks) workers) are available everywhere. Module workers are:
We found that comlink-everywhere 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
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
Security News
Socket CEO Feross Aboukhadijeh joins a16z partners to discuss how modern, sophisticated supply chain attacks require AI-driven defenses and explore the challenges and solutions in leveraging AI for threat detection early in the development life cycle.
Security News
NIST's new AI Risk Management Framework aims to enhance the security and reliability of generative AI systems and address the unique challenges of malicious AI exploits.