next-security
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -1,3 +0,3 @@ | ||
import { SecurityConfig, SecurityHeader, SecurityHeaders } from './types'; | ||
export declare const nextSecurity: (config: SecurityConfig) => { | ||
import { SecurityHeader, SecurityHeaders } from './types'; | ||
export declare const headers: (securityHeaders: SecurityHeaders) => { | ||
headers(): Promise<{ | ||
@@ -9,2 +9,2 @@ source: string; | ||
}; | ||
export declare const generateSecurityHeaders: (headers: SecurityHeaders) => SecurityHeader[]; | ||
export declare const createHeaders: (headers: SecurityHeaders) => SecurityHeader[]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.generateSecurityHeaders = exports.nextSecurity = void 0; | ||
const defaultConfig_1 = require("./defaultConfig"); | ||
exports.createHeaders = exports.headers = void 0; | ||
const headers_1 = require("./headers"); | ||
const types_1 = require("./types"); | ||
const utils_1 = require("./utils"); | ||
const nextSecurity = (config) => { | ||
const headers = (securityHeaders) => { | ||
return { | ||
@@ -13,14 +13,14 @@ async headers() { | ||
source: '/(.*)', | ||
headers: (0, exports.generateSecurityHeaders)(config === null || config === void 0 ? void 0 : config.headers), | ||
headers: (0, exports.createHeaders)(securityHeaders), | ||
}, | ||
]; | ||
}, | ||
poweredByHeader: defaultConfig_1.defaultConfig.headers.xPoweredBy, | ||
poweredByHeader: headers_1.defaultHeaders.xPoweredBy, | ||
}; | ||
}; | ||
exports.nextSecurity = nextSecurity; | ||
const generateSecurityHeaders = (headers) => { | ||
exports.headers = headers; | ||
const createHeaders = (headers) => { | ||
const localHeaders = !headers | ||
? defaultConfig_1.defaultConfig.headers | ||
: (0, utils_1.defuReplaceArray)(Object.assign({}, headers), Object.assign({}, defaultConfig_1.defaultConfig.headers)); | ||
? headers_1.defaultHeaders | ||
: (0, utils_1.defuReplaceArray)(Object.assign({}, headers), Object.assign({}, headers_1.defaultHeaders)); | ||
const headersArray = []; | ||
@@ -38,3 +38,3 @@ for (const header in localHeaders) { | ||
}; | ||
exports.generateSec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FTLHdCQUFjLEVBQUcsQ0FBQztJQUU1RCxNQUFNLFlBQVksR0FBcUIsRUFBRSxDQUFDO0lBQzFDLEtBQUssTUFBTSxNQUFNLElBQUksWUFBWSxFQUFFO1FBQ2pDLE1BQU0sYUFBYSxHQUFHLFlBQVksQ0FBQyxNQUFNLENBQUMsQ0FBQztRQUMzQyxJQUFJLGFBQWEsRUFBRTtZQUNqQixZQUFZLENBQUMsSUFBSSxDQUFDO2dCQUNoQixHQUFHLEVBQUUsNkJBQXFCLENBQUMsTUFBTSxDQUFDO2dCQUNsQyxLQUFLLEVBQUUsSUFBQSxpQ0FBeUIsRUFDOUIsTUFBK0IsRUFDL0IsYUFBYSxDQUNkO2FBQ0YsQ0FBQyxDQUFDO1NBQ0o7S0FDRjtJQUVELE9BQU8sWUFBWSxDQUFDO0FBQ3RCLENBQUMsQ0FBQztBQXBCVyxRQUFBLGFBQWEsaUJBb0J4QiJ9 |
@@ -1,4 +0,1 @@ | ||
export type SecurityConfig = { | ||
headers: SecurityHeaders; | ||
}; | ||
export type SecurityHeaders = { | ||
@@ -5,0 +2,0 @@ crossOriginResourcePolicy?: CrossOriginResourcePolicyValue | false; |
@@ -20,2 +20,2 @@ "use strict"; | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBd0thLFFBQUEscUJBQXFCLEdBQXdCO0lBQ3hELHFCQUFxQixFQUFFLHlCQUF5QjtJQUNoRCx5QkFBeUIsRUFBRSw4QkFBOEI7SUFDekQsdUJBQXVCLEVBQUUsNEJBQTRCO0lBQ3JELHlCQUF5QixFQUFFLDhCQUE4QjtJQUN6RCxrQkFBa0IsRUFBRSxzQkFBc0I7SUFDMUMsY0FBYyxFQUFFLGlCQUFpQjtJQUNqQyx1QkFBdUIsRUFBRSwyQkFBMkI7SUFDcEQsbUJBQW1CLEVBQUUsd0JBQXdCO0lBQzdDLG1CQUFtQixFQUFFLHdCQUF3QjtJQUM3QyxnQkFBZ0IsRUFBRSxvQkFBb0I7SUFDdEMsYUFBYSxFQUFFLGlCQUFpQjtJQUNoQyw2QkFBNkIsRUFBRSxtQ0FBbUM7SUFDbEUsY0FBYyxFQUFFLGtCQUFrQjtJQUNsQyxpQkFBaUIsRUFBRSxvQkFBb0I7Q0FDeEMsQ0FBQyJ9 | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBb0thLFFBQUEscUJBQXFCLEdBQXdCO0lBQ3hELHFCQUFxQixFQUFFLHlCQUF5QjtJQUNoRCx5QkFBeUIsRUFBRSw4QkFBOEI7SUFDekQsdUJBQXVCLEVBQUUsNEJBQTRCO0lBQ3JELHlCQUF5QixFQUFFLDhCQUE4QjtJQUN6RCxrQkFBa0IsRUFBRSxzQkFBc0I7SUFDMUMsY0FBYyxFQUFFLGlCQUFpQjtJQUNqQyx1QkFBdUIsRUFBRSwyQkFBMkI7SUFDcEQsbUJBQW1CLEVBQUUsd0JBQXdCO0lBQzdDLG1CQUFtQixFQUFFLHdCQUF3QjtJQUM3QyxnQkFBZ0IsRUFBRSxvQkFBb0I7SUFDdEMsYUFBYSxFQUFFLGlCQUFpQjtJQUNoQyw2QkFBNkIsRUFBRSxtQ0FBbUM7SUFDbEUsY0FBYyxFQUFFLGtCQUFrQjtJQUNsQyxpQkFBaUIsRUFBRSxvQkFBb0I7Q0FDeEMsQ0FBQyJ9 |
@@ -1,3 +0,3 @@ | ||
import { SecurityConfig, SecurityHeader, SecurityHeaders } from './types'; | ||
export declare const nextSecurity: (config: SecurityConfig) => { | ||
import { SecurityHeader, SecurityHeaders } from './types'; | ||
export declare const headers: (securityHeaders: SecurityHeaders) => { | ||
headers(): Promise<{ | ||
@@ -9,2 +9,2 @@ source: string; | ||
}; | ||
export declare const generateSecurityHeaders: (headers: SecurityHeaders) => SecurityHeader[]; | ||
export declare const createHeaders: (headers: SecurityHeaders) => SecurityHeader[]; |
@@ -1,5 +0,5 @@ | ||
import { defaultConfig } from './defaultConfig'; | ||
import { defaultHeaders } from './headers'; | ||
import { SECURITY_HEADER_NAMES, } from './types'; | ||
import { defuReplaceArray, getHeaderValueFromOptions } from './utils'; | ||
export const nextSecurity = (config) => { | ||
export const headers = (securityHeaders) => { | ||
return { | ||
@@ -10,13 +10,13 @@ async headers() { | ||
source: '/(.*)', | ||
headers: generateSecurityHeaders(config?.headers), | ||
headers: createHeaders(securityHeaders), | ||
}, | ||
]; | ||
}, | ||
poweredByHeader: defaultConfig.headers.xPoweredBy, | ||
poweredByHeader: defaultHeaders.xPoweredBy, | ||
}; | ||
}; | ||
export const generateSecurityHeaders = (headers) => { | ||
export const createHeaders = (headers) => { | ||
const localHeaders = !headers | ||
? defaultConfig.headers | ||
: defuReplaceArray({ ...headers }, { ...defaultConfig.headers }); | ||
? defaultHeaders | ||
: defuReplaceArray({ ...headers }, { ...defaultHeaders }); | ||
const headersArray = []; | ||
@@ -34,2 +34,2 @@ for (const header in localHeaders) { | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBQ2hELE9BQU8sRUFDTCxxQkFBcUIsR0FJdEIsTUFBTSxTQUFTLENBQUM7QUFDakIsT0FBTyxFQUFFLGdCQUFnQixFQUFFLHlCQUF5QixFQU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QU0sYUFBYSxHQUFHLFlBQVksQ0FBQyxNQUFNLENBQUMsQ0FBQztRQUMzQyxJQUFJLGFBQWEsRUFBRTtZQUNqQixZQUFZLENBQUMsSUFBSSxDQUFDO2dCQUNoQixHQUFHLEVBQUUscUJBQXFCLENBQUMsTUFBTSxDQUFDO2dCQUNsQyxLQUFLLEVBQUUseUJBQXlCLENBQzlCLE1BQStCLEVBQy9CLGFBQWEsQ0FDZDthQUNGLENBQUMsQ0FBQztTQUNKO0tBQ0Y7SUFFRCxPQUFPLFlBQVksQ0FBQztBQUN0QixDQUFDLENBQUMifQ== |
@@ -1,4 +0,1 @@ | ||
export type SecurityConfig = { | ||
headers: SecurityHeaders; | ||
}; | ||
export type SecurityHeaders = { | ||
@@ -5,0 +2,0 @@ crossOriginResourcePolicy?: CrossOriginResourcePolicyValue | false; |
@@ -17,2 +17,2 @@ export const SECURITY_HEADER_NAMES = { | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBd0tBLE1BQU0sQ0FBQyxNQUFNLHFCQUFxQixHQUF3QjtJQUN4RCxxQkFBcUIsRUFBRSx5QkFBeUI7SUFDaEQseUJBQXlCLEVBQUUsOEJBQThCO0lBQ3pELHVCQUF1QixFQUFFLDRCQUE0QjtJQUNyRCx5QkFBeUIsRUFBRSw4QkFBOEI7SUFDekQsa0JBQWtCLEVBQUUsc0JBQXNCO0lBQzFDLGNBQWMsRUFBRSxpQkFBaUI7SUFDakMsdUJBQXVCLEVBQUUsMkJBQTJCO0lBQ3BELG1CQUFtQixFQUFFLHdCQUF3QjtJQUM3QyxtQkFBbUIsRUFBRSx3QkFBd0I7SUFDN0MsZ0JBQWdCLEVBQUUsb0JBQW9CO0lBQ3RDLGFBQWEsRUFBRSxpQkFBaUI7SUFDaEMsNkJBQTZCLEVBQUUsbUNBQW1DO0lBQ2xFLGNBQWMsRUFBRSxrQkFBa0I7SUFDbEMsaUJBQWlCLEVBQUUsb0JBQW9CO0NBQ3hDLENBQUMifQ== | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBb0tBLE1BQU0sQ0FBQyxNQUFNLHFCQUFxQixHQUF3QjtJQUN4RCxxQkFBcUIsRUFBRSx5QkFBeUI7SUFDaEQseUJBQXlCLEVBQUUsOEJBQThCO0lBQ3pELHVCQUF1QixFQUFFLDRCQUE0QjtJQUNyRCx5QkFBeUIsRUFBRSw4QkFBOEI7SUFDekQsa0JBQWtCLEVBQUUsc0JBQXNCO0lBQzFDLGNBQWMsRUFBRSxpQkFBaUI7SUFDakMsdUJBQXVCLEVBQUUsMkJBQTJCO0lBQ3BELG1CQUFtQixFQUFFLHdCQUF3QjtJQUM3QyxtQkFBbUIsRUFBRSx3QkFBd0I7SUFDN0MsZ0JBQWdCLEVBQUUsb0JBQW9CO0lBQ3RDLGFBQWEsRUFBRSxpQkFBaUI7SUFDaEMsNkJBQTZCLEVBQUUsbUNBQW1DO0lBQ2xFLGNBQWMsRUFBRSxrQkFBa0I7SUFDbEMsaUJBQWlCLEVBQUUsb0JBQW9CO0NBQ3hDLENBQUMifQ== |
{ | ||
"name": "next-security", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Security plugin for Next.js based on OWASP and Helmet", | ||
@@ -40,3 +40,4 @@ "main": "build/main/index.js", | ||
"reset-hard": "git clean -dfx && git reset --hard && yarn", | ||
"prepare-release": "run-s reset-hard test cov:check doc:html version doc:publish" | ||
"prepare-release": "run-s reset-hard test cov:check doc:html version doc:publish", | ||
"stackblitz": "cd .stackblitz && npm install && npm run dev" | ||
}, | ||
@@ -43,0 +44,0 @@ "engines": { |
@@ -8,4 +8,6 @@ # next-security | ||
Security plugin for Next.js based on OWASP and Helmet. | ||
> Security plugin for Next.js based on [OWASP Top 10](https://cheatsheetseries.owasp.org/cheatsheets/Nodejs_Security_Cheat_Sheet.html#nodejs-security-cheat-sheet) and [helmet](https://helmetjs.github.io/) that adds security response headers. | ||
- [👾 Playground](https://stackblitz.com/github/baroshem/next-security?file=.stackblitz%2Fnext.config.js) | ||
## Features | ||
@@ -16,5 +18,5 @@ | ||
- `[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]` 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 | ||
@@ -36,5 +38,5 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const { nextSecurity } = require('next-security'); | ||
const { headers } = require('next-security'); | ||
const nextConfig = { | ||
...nextSecurity(), // with this approach you will also hide the `X-Powered-By` header that is a good pattern | ||
...headers(), // with this approach you will also hide the `X-Powered-By` header that is a good pattern | ||
}; | ||
@@ -49,3 +51,3 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const { generateSecurityHeaders } = require('next-security'); | ||
const { createHeaders } = require('next-security'); | ||
const nextConfig = { | ||
@@ -56,3 +58,3 @@ async headers() { | ||
source: '/(.*)', | ||
headers: generateSecurityHeaders(), | ||
headers: createHeaders(), | ||
}, | ||
@@ -94,10 +96,8 @@ ]; | ||
/** @type {import('next').NextConfig} */ | ||
const { nextSecurity } = require('next-security'); | ||
const { headers } = require('next-security'); | ||
const nextConfig = { | ||
...nextSecurity({ | ||
headers: { | ||
xXSSProtection: '1', | ||
crossOriginResourcePolicy: 'cross-origin', | ||
contentSecurityPolicy: false, | ||
}, | ||
...headers({ | ||
xXSSProtection: '1', | ||
crossOriginResourcePolicy: 'cross-origin', | ||
contentSecurityPolicy: false, | ||
}), | ||
@@ -104,0 +104,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50172
23
719