@middy/http-security-headers
Advanced tools
Comparing version 2.0.0-alpha.6 to 2.0.0-beta.0
import middy from '@middy/core' | ||
interface IHTTPSecurityHeadersOptions { | ||
interface Options { | ||
dnsPrefetchControl?: { | ||
allow?: Boolean | ||
}, | ||
allow?: boolean | ||
} | ||
expectCT?: { | ||
enforce?: Boolean, | ||
maxAge?: Number | ||
}, | ||
enforce?: boolean | ||
maxAge?: number | ||
reportUri?: string | ||
} | ||
frameguard?: { | ||
action?: String | ||
}, | ||
action?: string | ||
} | ||
hidePoweredBy?: { | ||
setTo: String | ||
}, | ||
setTo: string | ||
} | ||
hsts?: { | ||
maxAge?: Number, | ||
includeSubDomains?: Boolean, | ||
preload?: Boolean | ||
}, | ||
maxAge?: number | ||
includeSubDomains?: boolean | ||
preload?: boolean | ||
} | ||
ieNoOpen?: { | ||
action?: String | ||
}, | ||
action?: string | ||
} | ||
noSniff?: { | ||
action?: String | ||
}, | ||
action?: string | ||
} | ||
referrerPolicy?: { | ||
policy?: String | ||
}, | ||
xssFilter?: Object | ||
policy?: string | ||
} | ||
xssFilter?: { | ||
reportUri?: string | ||
} | ||
} | ||
declare const httpSecurityHeaders : middy.Middleware<IHTTPSecurityHeadersOptions, any, any> | ||
declare function httpSecurityHeaders (options?: Options): middy.MiddlewareObj | ||
export default httpSecurityHeaders |
17
index.js
@@ -14,4 +14,4 @@ "use strict"; | ||
enforce: true, | ||
maxAge: 30 // reportUri: '' | ||
maxAge: 30, | ||
reportUri: '' | ||
}, | ||
@@ -42,3 +42,4 @@ frameguard: { | ||
}, | ||
xssFilter: {// reportUri: '' | ||
xssFilter: { | ||
reportUri: '' | ||
} | ||
@@ -135,4 +136,4 @@ }; | ||
const httpSecurityHeadersMiddlewareAfter = async handler => { | ||
handler.response = normalizeHttpResponse(handler.response); | ||
const httpSecurityHeadersMiddlewareAfter = async request => { | ||
request.response = normalizeHttpResponse(request.response); | ||
Object.keys(helmet).forEach(key => { | ||
@@ -142,6 +143,6 @@ const config = { ...defaults[key], | ||
}; | ||
handler.response.headers = helmet[key](handler.response.headers, config); | ||
request.response.headers = helmet[key](request.response.headers, config); | ||
}); | ||
if (handler.response.headers['Content-Type'] && handler.response.headers['Content-Type'].indexOf('text/html') !== -1) { | ||
if (request.response.headers['Content-Type'] && request.response.headers['Content-Type'].indexOf('text/html') !== -1) { | ||
Object.keys(helmetHtmlOnly).forEach(key => { | ||
@@ -151,3 +152,3 @@ const config = { ...defaults[key], | ||
}; | ||
handler.response.headers = helmetHtmlOnly[key](handler.response.headers, config); | ||
request.response.headers = helmetHtmlOnly[key](request.response.headers, config); | ||
}); | ||
@@ -154,0 +155,0 @@ } |
{ | ||
"name": "@middy/http-security-headers", | ||
"version": "2.0.0-alpha.6", | ||
"version": "2.0.0-beta.0", | ||
"description": "Applies best practice security headers to responses. It's a simplified port of HelmetJS", | ||
@@ -20,4 +20,3 @@ "type": "commonjs", | ||
"test": "npm run test:typings && npm run test:unit", | ||
"test:unit": "ava", | ||
"test:typings": "typings-tester --config tsconfig.json index.d.ts" | ||
"test:unit": "ava" | ||
}, | ||
@@ -53,6 +52,9 @@ "license": "MIT", | ||
"homepage": "https://github.com/middyjs/middy#readme", | ||
"gitHead": "e6ab94a1f33ca215f63ee613bc9469ccd56caf21", | ||
"gitHead": "cf78e46ea77bf8feb3ae6061d8e8e9a02f8eeb2e", | ||
"dependencies": { | ||
"@middy/util": "^2.0.0-alpha.6" | ||
"@middy/util": "^2.0.0-beta.0" | ||
}, | ||
"devDependencies": { | ||
"@middy/core": "^2.0.0-beta.0" | ||
} | ||
} |
164
10264
1
Updated@middy/util@^2.0.0-beta.0