mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-12 12:10:44 +08:00
Add definition for "email-templates".
Update definition for "helmet".
This commit is contained in:
+14
-11
@@ -1,59 +1,62 @@
|
||||
/// <reference path="helmet.d.ts" />
|
||||
|
||||
import express = require("express")
|
||||
import helmet = require("helmet");
|
||||
|
||||
var app = express();
|
||||
|
||||
/**
|
||||
* @summary Test for {@see helmet}.
|
||||
*/
|
||||
function helmetTest() {
|
||||
helmet();
|
||||
app.use(helmet());
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Test for {@see helmet#xssFilter} function.
|
||||
*/
|
||||
function contentSecurityPolicyTest() {
|
||||
helmet.xssFilter();
|
||||
helmet.xssFilter({ setOnOldIE: true });
|
||||
app.use(helmet.xssFilter());
|
||||
app.use(helmet.xssFilter({ setOnOldIE: true }));
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Test for {@see helmet#frameguard} function.
|
||||
*/
|
||||
function frameguardTest() {
|
||||
helmet.frameguard();
|
||||
helmet.frameguard("sameorigin");
|
||||
app.use(helmet.frameguard());
|
||||
app.use(helmet.frameguard("sameorigin"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Test for {@see helmet#hsts} function.
|
||||
*/
|
||||
function hstsTest() {
|
||||
helmet.hsts();
|
||||
helmet.hsts({ maxAge: 7776000000 });
|
||||
app.use(helmet.hsts());
|
||||
app.use(helmet.hsts({ maxAge: 7776000000 }));
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Test for {@see helmet#ieNoOpen} function.
|
||||
*/
|
||||
function ieNoOpenTest() {
|
||||
helmet.ieNoOpen();
|
||||
app.use(helmet.ieNoOpen());
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Test for {@see helmet#noSniff} function.
|
||||
*/
|
||||
function noSniffTest() {
|
||||
helmet.noSniff();
|
||||
app.use(helmet.noSniff());
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Test for {@see helmet#publicKeyPins} function.
|
||||
*/
|
||||
function publicKeyPinsTest() {
|
||||
helmet.publicKeyPins({
|
||||
app.use(helmet.publicKeyPins({
|
||||
sha256s: ["AbCdEf123=", "ZyXwVu456="],
|
||||
includeSubdomains: true,
|
||||
reportUri: "http://example.com"
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
Vendored
+67
-47
@@ -3,55 +3,75 @@
|
||||
// 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;
|
||||
}
|
||||
/// <reference path="../express/express.d.ts" />
|
||||
|
||||
declare module "helmet" {
|
||||
import express = require("express");
|
||||
|
||||
/**
|
||||
* @summary Interface for helmet class.
|
||||
* @interface
|
||||
*/
|
||||
interface Helmet {
|
||||
/**
|
||||
* @summary Constructor.
|
||||
* @return {RequestHandler} The Request handler.
|
||||
*/
|
||||
():express.RequestHandler;
|
||||
|
||||
/**
|
||||
* @summary Prevent clickjacking.
|
||||
* @param {string} header The header.
|
||||
* @return {RequestHandler} The Request handler.
|
||||
*/
|
||||
frameguard(header ?: string):express.RequestHandler;
|
||||
|
||||
/**
|
||||
* @summary Hide "X-Powered-By" header.
|
||||
* @param {Object} options The options.
|
||||
* @return {RequestHandler} The Request handler.
|
||||
*/
|
||||
hidePoweredBy(options ?: Object):express.RequestHandler;
|
||||
|
||||
/**
|
||||
* @summary Adds the "Strict-Transport-Security" header.
|
||||
* @param {Object} options The options.
|
||||
* @return {RequestHandler} The Request handler.
|
||||
*/
|
||||
hsts(options ?: Object):express.RequestHandler;
|
||||
|
||||
/**
|
||||
* @summary Add the "X-Download-Options" header.
|
||||
* @return {RequestHandler} The Request handler.
|
||||
*/
|
||||
ieNoOpen():express.RequestHandler;
|
||||
|
||||
/**
|
||||
* @summary Add the "Cache-Control" and "Pragma" headers to stop caching.
|
||||
* @return {RequestHandler} The Request handler.
|
||||
*/
|
||||
noCache(options ?: Object):express.RequestHandler;
|
||||
|
||||
/**
|
||||
* @summary Adds the "X-Content-Type-Options" header.
|
||||
* @return {RequestHandler} The Request handler.
|
||||
*/
|
||||
noSniff():express.RequestHandler;
|
||||
|
||||
/**
|
||||
* @summary Adds the "Public-Key-Pins" header.
|
||||
* @return {RequestHandler} The Request handler.
|
||||
*/
|
||||
publicKeyPins(options ?: Object):express.RequestHandler;
|
||||
|
||||
/**
|
||||
* @summary Prevent Cross-site scripting attacks.
|
||||
* @return {RequestHandler} The Request handler.
|
||||
* @param {Object} options The options.
|
||||
*/
|
||||
xssFilter(options ?: Object):express.RequestHandler;
|
||||
}
|
||||
|
||||
var helmet: Helmet;
|
||||
export = helmet;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user