strict-transport-security

0.3.0 • Public • Published

Build Status Coverage Status

strict-transport-security

Node.js middleware to add Strict-Transport-Security header according to RFC6797

Install

$ npm install strict-transport-security --save

Tests

$ npm install --dev
$ npm test

Usage

const sts = require('strict-transport-security');
const express = require('express');
const app = express();
 
const globalSTS = sts.getSTS({'max-age':{'days': 30}});
const localSTS = sts.getSTS({'max-age':{'days': 10}, 'includeSubDomains': true});
 
// This will apply this policy to all requests
app.use(globalSTS);
 
app.get('/', (req, res) => {
  res.send('Using global strict transport security policy!');
});
 
// This will apply the local policy just to this path, overriding the globla policy
app.get('/local', localSTS, (req, res) => {
  res.send('Using path local strict transport security policy!');
});
 
app.listen(3000, () => {
  console.log('Example app listening on port 3000!');
});

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.3.0
    9,207
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.3.0
    9,207
  • 0.2.2
    905
  • 0.2.1
    413
  • 0.2.0
    29
  • 0.1.0
    1

Package Sidebar

Install

npm i strict-transport-security

Weekly Downloads

10,555

Version

0.3.0

License

none

Unpacked Size

6.06 kB

Total Files

6

Last publish

Collaborators

  • samuelerdtman