Add definition for "Helmet".

This commit is contained in:
Cyril Schumacher
2015-11-20 10:52:31 +01:00
parent 62ccac5a62
commit 4f1210ffbf
2 changed files with 116 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
/// <reference path="helmet.d.ts" />
import helmet = require("helmet");
/**
* @summary Test for {@see helmet}.
*/
function helmetTest() {
helmet();
}
/**
* @summary Test for {@see helmet#xssFilter} function.
*/
function contentSecurityPolicyTest() {
helmet.xssFilter();
helmet.xssFilter({ setOnOldIE: true });
}
/**
* @summary Test for {@see helmet#frameguard} function.
*/
function frameguardTest() {
helmet.frameguard();
helmet.frameguard("sameorigin");
}
/**
* @summary Test for {@see helmet#hsts} function.
*/
function hstsTest() {
helmet.hsts();
helmet.hsts({ maxAge: 7776000000 });
}
/**
* @summary Test for {@see helmet#ieNoOpen} function.
*/
function ieNoOpenTest() {
helmet.ieNoOpen();
}
/**
* @summary Test for {@see helmet#noSniff} function.
*/
function noSniffTest() {
helmet.noSniff();
}
/**
* @summary Test for {@see helmet#publicKeyPins} function.
*/
function publicKeyPinsTest() {
helmet.publicKeyPins({
sha256s: ["AbCdEf123=", "ZyXwVu456="],
includeSubdomains: true,
reportUri: "http://example.com"
});
}
+57
View File
@@ -0,0 +1,57 @@
// Type definitions for helmet
// Project: https://github.com/helmetjs/helmet
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface Helmet {
(): void;
/**
* @summary Prevent clickjacking.
* @param {string} header The header.
*/
frameguard(header ?: string): void;
/**
* @summary Hide "X-Powered-By" header.
* @param {Object} options The options.
*/
hidePoweredBy(options ?: Object): void;
/**
* @summary Adds the "Strict-Transport-Security" header.
* @param {Object} options The options.
*/
hsts(options ?: Object): void;
/**
* @summary Add the "X-Download-Options" header.
*/
ieNoOpen(): void;
/**
* @summary Add the "Cache-Control" and "Pragma" headers to stop caching.
*/
nocache(options ?: Object): void;
/**
* @summary Adds the "X-Content-Type-Options" header.
*/
noSniff(): void;
/**
* @summary Adds the "Public-Key-Pins" header.
*/
publicKeyPins(options ?: Object): void;
/**
* @summary Prevent Cross-site scripting attacks.
* @param {Object} options The options.
*/
xssFilter(options ?: Object): void;
}
declare module "helmet" {
var helmet: Helmet;
export = helmet;
}