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.
@priestine/routing
Advanced tools
npm i --save @priestine/routing
or
yarn add @priestine/routing
import { withHttpRouter, HttpRouter } from '@priestine/routing';
import { createServer } from 'http';
/**
* Create an empty router
*/
const router = HttpRouter.empty();
/**
* Define a set of functions
*/
// Curried for creating header builders
// `ctx` has { request: IncomingMessage, response: ServerResponse, intermediate: {/* Your data */}, error? }
const setHeader = (name) => (value) => (ctx) => {
ctx.response.setHeader(name, value);
};
// Specifically, a Content-Type header builder (we could make it in one go tho)
const setContentTypeHeader = setHeader('Content-Type');
// Anything to be passed to the next middleware should be put to ctx.intermediate to keep request and response Node.js-ly pure
const buildHello = (ctx) => {
ctx.intermediate.helloWorld = {
id: 'hello-world',
message: 'Hello World!',
}
};
// You don't need to actually return the ctx. It's done for you automatically
// In case you run async code, you must create and return a Promise that will resolve when necessary
const sayHello = (ctx) => ctx.response.end(JSON.stringify(ctx.intermediate.helloWorld));
/**
* Register them in the router
*/
router
.get('/', [
setContentTypeHeader('application/json'),
buildHello,
sayHello,
])
.get(/^\/(\d+)\/?$/, [
setContentTypeHeader('text/html'),
buildHello,
sayHello,
])
;
/**
* Assign the router to serve Node.js HTTP server.
*/
createServer(withHttpRouter(router)).listen(3000);
// Go get http://localhost:3000
FAQs
Simple, declarative and dependency-free routing for Node.js
The npm package @priestine/routing receives a total of 3 weekly downloads. As such, @priestine/routing popularity was classified as not popular.
We found that @priestine/routing 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.