https://github.com/louis3797/xss-shield
A powerful middleware for securing your express.js applications against cross-site scripting (XSS) attacks
https://github.com/louis3797/xss-shield
express-middleware middleware node security typescript xss xss-attacks xss-filter xss-sanitizer xss-shield
Last synced: about 1 year ago
JSON representation
A powerful middleware for securing your express.js applications against cross-site scripting (XSS) attacks
- Host: GitHub
- URL: https://github.com/louis3797/xss-shield
- Owner: Louis3797
- License: mit
- Created: 2023-03-20T22:30:13.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-19T04:06:41.000Z (almost 3 years ago)
- Last Synced: 2025-03-22T20:02:56.012Z (about 1 year ago)
- Topics: express-middleware, middleware, node, security, typescript, xss, xss-attacks, xss-filter, xss-sanitizer, xss-shield
- Language: TypeScript
- Homepage: https://louis3797.github.io/xss-shield/
- Size: 135 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
xss-shield
This package provides a middleware for Express.js that helps protect against cross-site scripting (XSS) attacks. It's built on top of the xss module and is written in TypeScript.
## Installation
To use this middleware, first install it using npm or yarn:
```bash
npm install xss-shield
```
or
```bash
yarn add xss-shield
```
## Usage
To use this middleware in your Express.js application, simply require or import it and add it to your middleware stack:
```ts
const express = require('express');
const xssShield = require('xss-shield');
const app = express();
// Add the middleware to the middleware stack
app.use(xssShield());
```
You can also pass options to the middleware to customize its behavior. See the [xss documentation](https://jsxss.com/en/options.html) for available options.
```ts
const express = require('express');
const xssShield = require('xss-shield');
const app = express();
// Add the middleware to the middleware stack with options
app.use(xssShield({
whiteList: {
a: ['href', 'title', 'target'],
img: ['src', 'alt'],
}
}));
```
## License
xss-shield is licensed under the MIT License. See LICENSE for more information.