Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@mellkam/middleware
Advanced tools
This library provides a simple implementation of a middleware pattern that can be used to wrap or extend functions with additional functionality without changing their original implementation.
npm install @mellkam/middleware
import { type Middleware, wrap } from "@mellkam/middleware";
const timer: Middleware = (args, next) => {
console.time("timer");
const result = next(...args);
console.timeEnd("timer");
return result;
};
console.log(wrap(fibonacci).use(timer).run(40));
// timer: 1.518s
// 102334155
Middlewares are executed in LIFO order ("Last In, First Out").
Everytime you push a new middleware to the stack, it is added as a new onion layer on top of all existing ones.
import { wrap } from "@mellkam/middleware";
const log = wrap(console.log)
.use((args, next) => {
console.log("Middleware 1: Before");
next(...args);
console.log("Middleware 1: After");
})
.use((args, next) => {
console.log("Middleware 2: Before");
next(...args);
console.log("Middleware 2: After");
}).run;
log("Actual func call");
Logs:
Middleware 2: Before
Middleware 1: Before
Actual func call
Middleware 1: After
Middleware 2: After
const mw: Middleware = (args, next) => {
//
// BEFORE
//
next(...args);
//
// AFTER
//
};
FAQs
Universal and lightweight middleware utility
The npm package @mellkam/middleware receives a total of 0 weekly downloads. As such, @mellkam/middleware popularity was classified as not popular.
We found that @mellkam/middleware 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.