mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Add definition for "Helmet".
This commit is contained in:
@@ -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"
|
||||
});
|
||||
}
|
||||
Vendored
+57
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user