mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-30 23:30:06 +00:00
Improve Helmet publicKeyPins definitions (#9017)
`helmet.publicKeyPins` takes an object of a certain shape instead of any Object.
This commit is contained in:
committed by
Masahiro Wakame
parent
b20485f598
commit
db57ec3afd
@@ -110,10 +110,39 @@ function noSniffTest() {
|
||||
*/
|
||||
function publicKeyPinsTest() {
|
||||
app.use(helmet.publicKeyPins({
|
||||
maxAge: 7776000000,
|
||||
sha256s: ["AbCdEf123=", "ZyXwVu456="],
|
||||
}));
|
||||
|
||||
app.use(helmet.publicKeyPins({
|
||||
maxAge: 7776000000,
|
||||
sha256s: ["AbCdEf123=", "ZyXwVu456="],
|
||||
includeSubdomains: false
|
||||
}));
|
||||
|
||||
app.use(helmet.publicKeyPins({
|
||||
maxAge: 7776000000,
|
||||
sha256s: ["AbCdEf123=", "ZyXwVu456="],
|
||||
includeSubdomains: true
|
||||
}));
|
||||
|
||||
app.use(helmet.publicKeyPins({
|
||||
maxAge: 7776000000,
|
||||
sha256s: ["AbCdEf123=", "ZyXwVu456="],
|
||||
includeSubdomains: true,
|
||||
reportUri: "http://example.com"
|
||||
}));
|
||||
|
||||
app.use(helmet.publicKeyPins({
|
||||
maxAge: 7776000000,
|
||||
sha256s: ["AbCdEf123=", "ZyXwVu456="],
|
||||
reportOnly: true
|
||||
}));
|
||||
|
||||
app.use(helmet.publicKeyPins({
|
||||
maxAge: 7776000000,
|
||||
sha256s: ["AbCdEf123=", "ZyXwVu456="],
|
||||
setIf: function (req, res) { return true; }
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
15
helmet/helmet.d.ts
vendored
15
helmet/helmet.d.ts
vendored
@@ -40,6 +40,19 @@ declare module "helmet" {
|
||||
directives? : IHelmetCspDirectives
|
||||
}
|
||||
|
||||
interface IHelmetPublicKeyPinsSetIfFunction {
|
||||
(req: express.Request, res: express.Response): boolean;
|
||||
}
|
||||
|
||||
interface IHelmetPublicKeyPinsConfiguration {
|
||||
maxAge : number;
|
||||
sha256s : string[];
|
||||
includeSubdomains? : boolean;
|
||||
reportUri? : string;
|
||||
reportOnly? : boolean;
|
||||
setIf?: IHelmetPublicKeyPinsSetIfFunction
|
||||
}
|
||||
|
||||
interface IHelmetXssFilterConfiguration {
|
||||
setOnOldIE? : boolean;
|
||||
}
|
||||
@@ -107,7 +120,7 @@ declare module "helmet" {
|
||||
* @summary Adds the "Public-Key-Pins" header.
|
||||
* @return {RequestHandler} The Request handler.
|
||||
*/
|
||||
publicKeyPins(options ?: Object):express.RequestHandler;
|
||||
publicKeyPins(options ?: IHelmetPublicKeyPinsConfiguration):express.RequestHandler;
|
||||
|
||||
/**
|
||||
* @summary Mitigate cross-site scripting attacks with the "X-XSS-Protection" header.
|
||||
|
||||
Reference in New Issue
Block a user