Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

next-security

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-security - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

2

build/main/index.d.ts

@@ -10,2 +10,2 @@ import { SecurityConfig, SecurityHeader, SecurityHeaders } from './types';

};
export declare const withSecurity: (nextConfig: any, config?: SecurityConfig) => any;
export declare const generateSecurityHeaders: (headers?: SecurityHeaders) => SecurityHeader[];
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.withSecurity = exports.nextSecurity = exports.defaultConfig = exports.getHeaderValueFromOptions = void 0;
exports.generateSecurityHeaders = exports.nextSecurity = exports.defaultConfig = exports.getHeaderValueFromOptions = void 0;
const types_1 = require("./types");

@@ -79,3 +79,3 @@ const headerValueMappers = {

source: '/(.*)',
headers: generateSecurityHeaders(config.headers),
headers: (0, exports.generateSecurityHeaders)(config.headers),
},

@@ -87,8 +87,3 @@ ];

exports.nextSecurity = nextSecurity;
const withSecurity = (nextConfig, config = exports.defaultConfig) => {
// TODO: fix returning the whole nextConfig instead
return Object.assign(Object.assign({}, (0, exports.nextSecurity)(config)), nextConfig.headers());
};
exports.withSecurity = withSecurity;
const generateSecurityHeaders = (headers) => {
const generateSecurityHeaders = (headers = exports.defaultConfig.headers) => {
const headersArray = [];

@@ -106,2 +101,3 @@ for (const header in headers) {

};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsbUNBUWlCO0FBRWpCLE1BQU0sa0JBQWtCLEdBQUc7SUFDekIsdUJBQXVCLEVBQUUsQ0FBQyxLQUFtQyxFQUFFLEVBQUUsQ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0IsRUFDL0IsYUFBYSxDQUNkO2FBQ0YsQ0FBQyxDQUFDO1NBQ0o7S0FDRjtJQUVELE9BQU8sWUFBWSxDQUFDO0FBQ3RCLENBQUMsQ0FBQztBQWxCVyxRQUFBLHVCQUF1QiwyQkFrQmxDIn0=

@@ -10,2 +10,2 @@ import { SecurityConfig, SecurityHeader, SecurityHeaders } from './types';

};
export declare const withSecurity: (nextConfig: any, config?: SecurityConfig) => any;
export declare const generateSecurityHeaders: (headers?: SecurityHeaders) => SecurityHeader[];

@@ -80,10 +80,3 @@ import { SECURITY_HEADER_NAMES, } from './types';

};
export const withSecurity = (nextConfig, config = defaultConfig) => {
// TODO: fix returning the whole nextConfig instead
return {
...nextSecurity(config),
...nextConfig.headers(),
};
};
const generateSecurityHeaders = (headers) => {
export const generateSecurityHeaders = (headers = defaultConfig.headers) => {
const headersArray = [];

@@ -101,2 +94,2 @@ for (const header in headers) {

};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUdMLHFCQUFxQixHQUt0QixNQUFNLFNBQVMsQ0FBQztBQUVqQixNQUFNLGtCQUFrQixHQUFHO0lBQ3pCLHVCQUF1QixFQUFFLENBQUMsS0FBbUMsRUFBRSxFQUFFLENBQy9EO1FBQ0UsV0FBVyxLQUFLLENBQUMsTUFBTSxFQUFFO1FBQ3pCLEtBQUssQ0FBQyxpQkFBaUIsSUFBSSxtQkFBbUI7UUFDOUMsS0FBSyxDQUFDLE9BQU8sSUFBSSxTQUFTO0tBQzNCO1NBQ0UsTUFBTSxDQUFDLE9BQU8sQ0FBQztTQUNmLElBQUksQ0FBQyxJQUFJLENBQUM7SUFDZixxQkFBcUIsRUFBRSxDQUFDLEtBQWlDLEVBQUUsRUFBRTtRQUMzR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RQUNMLEtBQUssQ0FBQyxPQUFPO1lBQ1gsT0FBTztnQkFDTDtvQkFDRSxNQUFNLEVBQUUsT0FBTztvQkFDZixPQUFPLEVBQUUsdUJBQXVCLENBQUMsTUFBTSxDQUFDLE9BQU8sQ0FBQztpQkFDakQ7YUFDRixDQUFDO1FBQ0osQ0FBQztLQUNGLENBQUM7QUFDSixDQUFDLENBQUM7QUFFRixNQUFNLENBQUMsTUFBTSx1QkFBdUIsR0FBRyxDQUNyQyxVQUEyQixhQUFhLENBQUMsT0FBTyxFQUNoRCxFQUFFO0lBQ0YsTUFBTSxZQUFZLEdBQXFCLEVBQUUsQ0FBQztJQUMxQyxLQUFLLE1BQU0sTUFBTSxJQUFJLE9BQU8sRUFBRTtRQUM1QixNQUFNLGFBQWEsR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLENBQUM7UUFDdEMsSUFBSSxhQUFhLEVBQUU7WUFDakIsWUFBWSxDQUFDLElBQUksQ0FBQztnQkFDaEIsR0FBRyxFQUFFLHFCQUFxQixDQUFDLE1BQU0sQ0FBQztnQkFDbEMsS0FBSyxFQUFFLHlCQUF5QixDQUM5QixNQUErQixFQUMvQixhQUFhLENBQ2Q7YUFDRixDQUFDLENBQUM7U0FDSjtLQUNGO0lBRUQsT0FBTyxZQUFZLENBQUM7QUFDdEIsQ0FBQyxDQUFDIn0=
{
"name": "next-security",
"version": "1.0.1",
"version": "1.0.2",
"description": "Security plugin for Next.js based on OWASP and Helmet",

@@ -15,2 +15,3 @@ "main": "build/main/index.js",

"build:module": "tsc -p tsconfig.module.json",
"example": "run-p build && cd example && run-s dev",
"fix": "run-s fix:*",

@@ -17,0 +18,0 @@ "fix:prettier": "prettier \"src/**/*.ts\" --write",

# next-security
Security plugin for Next.js based on OWASP and Helmet
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![Github Actions CI][github-actions-ci-src]][github-actions-ci-href]
[![License][license-src]][license-href]
Security plugin for Next.js based on OWASP and Helmet.
## Features
- No configuration security headers similar to Helmet.js
- Customization of all header values
- `[Coming soon]` Content Security Policy (CSP) for SSG apps
- `[Coming soon]`Request Size limiter
- `[Coming soon]`Cross Site Scripting (XSS) Validation
- `[Coming soon]`Cross-Origin Resource Sharing (CORS) support
- `[Coming soon]` `[Optional]` Allowed HTTP Methods, Basic Auth, CSRF, Rate Limiter
## Usage
Install the plugin:
```sh
npm i next-security
yarn add next-security
pnpm add next-security
```
Add the plugin to the `next.config.js` like following:
```js
/** @type {import('next').NextConfig} */
const { nextSecurity } = require('next-security');
const nextConfig = {
...nextSecurity(),
};
module.exports = nextConfig;
```
Or, if you want to have more control over the source for the headers:
```js
/** @type {import('next').NextConfig} */
const { generateSecurityHeaders } = require('next-security');
const nextConfig = {
async headers() {
return [
{
source: '/(.*)',
headers: generateSecurityHeaders(),
},
];
},
};
module.exports = nextConfig;
```
And that's it! The plugin will now register security response headers so that your application will be more secure.
If you inspect the headers that are being returned by the Next application in the browser, you should see the following result:
```md
cross-origin-resource-policy: same-origin
cross-origin-opener-policy: same-origin
cross-origin-embedder-policy: require-corp
content-security-policy: base-uri 'self'; font-src 'self' https: data:; form-action 'self'; frame-ancestors 'self'; img-src 'self' data:; object-src 'none'; script-src-attr 'none'; style-src 'self' https: 'unsafe-inline'; upgrade-insecure-requests
origin-agent-cluster: ?1
referrer-policy: no-referrer
strict-transport-security: max-age=15552000; includeSubDomains
x-content-type-options: nosniff
x-dns-prefetch-control: off
x-download-options: noopen
x-frame-options: SAMEORIGIN
x-permitted-cross-domain-policies: none
x-xss-protection: 0
permissions-policy: camera=(), display-capture=(), fullscreen=(), geolocation=(), microphone=()
```
## Configuration
You can pass configuration to the plugin like following:
```js
/** @type {import('next').NextConfig} */
const { nextSecurity } = require('next-security');
const nextConfig = {
...nextSecurity({
headers: {
xXSSProtection: '1',
crossOriginResourcePolicy: 'cross-origin',
contentSecurityPolicy: false,
},
}),
};
module.exports = nextConfig;
```
[npm-version-src]: https://img.shields.io/npm/v/next-security/latest.svg
[npm-version-href]: https://npmjs.com/package/next-security
[npm-downloads-src]: https://img.shields.io/npm/dt/next-security.svg
[npm-downloads-href]: https://npmjs.com/package/next-security
[github-actions-ci-src]: https://github.com/baroshem/next-security/actions/workflows/ci.yml/badge.svg
[github-actions-ci-href]: https://github.com/baroshem/next-security/actions?query=workflow%3Aci
[license-src]: https://img.shields.io/npm/l/next-security.svg
[license-href]: https://npmjs.com/package/next-security
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc