Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@ts-stack/cors
Advanced tools
Is a node.js package writen in TypeScript, fork of express cors module.
CORS is a node.js package writen in TypeScript for providing a sync middleware that can be used to enable CORS with various options.
This package is a fork of express/cors module from this state.
npm install @ts-stack/cors
import http from 'http';
import { cors, mergeOptions } from '@ts-stack/cors';
const hostname = '127.0.0.1';
const port = 3000;
const corsOptions = mergeOptions({ origin: 'https://example.com' });
const server = http.createServer((req, res) => {
res.statusCode = 200;
const headersSent = cors(req, res, corsOptions);
if (headersSent) {
return;
}
res.setHeader('Content-Type', 'text/plain');
res.end('This is CORS-enabled for https://example.com!');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
Certain CORS requests are considered 'complex' and require an initial OPTIONS
request (called the preflight request). An example of a 'complex' CORS request is one that uses an HTTP verb other than GET/HEAD/POST (such as DELETE) or that uses custom headers. To enable preflighting, you must add a new OPTIONS handler for the route you want to support.
The default configuration is the equivalent of:
{
"origin": "*",
"allowedMethods": "GET,HEAD,PUT,PATCH,POST,DELETE",
"preflightContinue": false,
"optionsSuccessStatus": 204
}
For details on the effect of each CORS header, read this article on web.dev.
FAQs
Is a node.js package writen in TypeScript, fork of express cors module.
We found that @ts-stack/cors demonstrated a healthy version release cadence and project activity because the last version was released less than 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.