/
koa-helmet.d.ts
67 lines (59 loc) · 2.96 KB
/
koa-helmet.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Type definitions for koa-helmet 6.0
// Project: https://github.com/venables/koa-helmet#readme
// Definitions by: Nick Simmons <https://github.com/nsimmons>
// Jan Dolezel <https://github.com/dolezel>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import helmet from 'helmet';
import { Middleware, Context } from 'koa';
type HelmetOptions = Required<Parameters<typeof helmet>>[0];
declare namespace koaHelmet {
type KoaHelmetContentSecurityPolicyDirectiveFunction = (ctx: Context) => string;
type KoaHelmetCspDirectiveValue = string | KoaHelmetContentSecurityPolicyDirectiveFunction;
interface KoaHelmetContentSecurityPolicyDirectives {
baseUri?: KoaHelmetCspDirectiveValue[];
childSrc?: KoaHelmetCspDirectiveValue[];
connectSrc?: KoaHelmetCspDirectiveValue[];
defaultSrc?: KoaHelmetCspDirectiveValue[];
fontSrc?: KoaHelmetCspDirectiveValue[];
formAction?: KoaHelmetCspDirectiveValue[];
frameAncestors?: KoaHelmetCspDirectiveValue[];
frameSrc?: KoaHelmetCspDirectiveValue[];
imgSrc?: KoaHelmetCspDirectiveValue[];
mediaSrc?: KoaHelmetCspDirectiveValue[];
objectSrc?: KoaHelmetCspDirectiveValue[];
pluginTypes?: KoaHelmetCspDirectiveValue[];
prefetchSrc?: KoaHelmetCspDirectiveValue[];
reportTo?: string;
reportUri?: string;
sandbox?: KoaHelmetCspDirectiveValue[];
scriptSrc?: KoaHelmetCspDirectiveValue[];
scriptSrcAttr?: KoaHelmetCspDirectiveValue[];
scriptSrcElem?: KoaHelmetCspDirectiveValue[];
styleSrc?: KoaHelmetCspDirectiveValue[];
styleSrcAttr?: KoaHelmetCspDirectiveValue[];
styleSrcElem?: KoaHelmetCspDirectiveValue[];
workerSrc?: KoaHelmetCspDirectiveValue[];
}
interface KoaHelmetContentSecurityPolicyConfiguration {
reportOnly?: boolean;
useDefaults?: boolean;
directives?: KoaHelmetContentSecurityPolicyDirectives;
}
interface KoaHelmet {
(options?: HelmetOptions): Middleware;
contentSecurityPolicy(options?: KoaHelmetContentSecurityPolicyConfiguration): Middleware;
dnsPrefetchControl(options?: HelmetOptions['dnsPrefetchControl']): Middleware;
expectCt(options?: HelmetOptions['expectCt']): Middleware;
frameguard(options?: HelmetOptions['frameguard']): Middleware;
hidePoweredBy(options?: HelmetOptions['hidePoweredBy']): Middleware;
hsts(options?: HelmetOptions['hsts']): Middleware;
ieNoOpen(options?: HelmetOptions['ieNoOpen']): Middleware;
noSniff(options?: HelmetOptions['noSniff']): Middleware;
permittedCrossDomainPolicies(options?: HelmetOptions['permittedCrossDomainPolicies']): Middleware;
referrerPolicy(options?: HelmetOptions['referrerPolicy']): Middleware;
xssFilter(options?: HelmetOptions['xssFilter']): Middleware;
}
}
declare const koaHelmet: koaHelmet.KoaHelmet;
export = koaHelmet;