|
5 | 5 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
6 | 6 | // TypeScript Version: 2.3
|
7 | 7 |
|
8 |
| -import helmet from 'helmet'; |
9 |
| -import { Middleware, Context } from 'koa'; |
| 8 | +import helmet from "helmet"; |
| 9 | +import { Middleware, Context } from "koa"; |
10 | 10 |
|
11 | 11 | type HelmetOptions = helmet.HelmetOptions;
|
12 | 12 |
|
13 | 13 | declare namespace koaHelmet {
|
14 |
| - type KoaHelmetContentSecurityPolicyDirectiveFunction = (req?: Context["req"], res?: Context["res"]) => string; |
| 14 | + type KoaHelmetContentSecurityPolicyDirectiveFunction = ( |
| 15 | + req?: Context["req"], |
| 16 | + res?: Context["res"], |
| 17 | + ) => string; |
15 | 18 |
|
16 |
| - type KoaHelmetCspDirectiveValue = string | KoaHelmetContentSecurityPolicyDirectiveFunction; |
| 19 | + type KoaHelmetCspDirectiveValue = |
| 20 | + | string |
| 21 | + | KoaHelmetContentSecurityPolicyDirectiveFunction; |
17 | 22 |
|
18 |
| - interface KoaHelmetContentSecurityPolicyDirectives { |
19 |
| - baseUri?: KoaHelmetCspDirectiveValue[]; |
20 |
| - childSrc?: KoaHelmetCspDirectiveValue[]; |
21 |
| - connectSrc?: KoaHelmetCspDirectiveValue[]; |
22 |
| - defaultSrc?: KoaHelmetCspDirectiveValue[]; |
23 |
| - fontSrc?: KoaHelmetCspDirectiveValue[]; |
24 |
| - formAction?: KoaHelmetCspDirectiveValue[]; |
25 |
| - frameAncestors?: KoaHelmetCspDirectiveValue[]; |
26 |
| - frameSrc?: KoaHelmetCspDirectiveValue[]; |
27 |
| - imgSrc?: KoaHelmetCspDirectiveValue[]; |
28 |
| - mediaSrc?: KoaHelmetCspDirectiveValue[]; |
29 |
| - objectSrc?: KoaHelmetCspDirectiveValue[]; |
30 |
| - pluginTypes?: KoaHelmetCspDirectiveValue[]; |
31 |
| - prefetchSrc?: KoaHelmetCspDirectiveValue[]; |
32 |
| - reportTo?: string; |
33 |
| - reportUri?: string; |
34 |
| - sandbox?: KoaHelmetCspDirectiveValue[]; |
35 |
| - scriptSrc?: KoaHelmetCspDirectiveValue[]; |
36 |
| - scriptSrcAttr?: KoaHelmetCspDirectiveValue[]; |
37 |
| - scriptSrcElem?: KoaHelmetCspDirectiveValue[]; |
38 |
| - styleSrc?: KoaHelmetCspDirectiveValue[]; |
39 |
| - styleSrcAttr?: KoaHelmetCspDirectiveValue[]; |
40 |
| - styleSrcElem?: KoaHelmetCspDirectiveValue[]; |
41 |
| - workerSrc?: KoaHelmetCspDirectiveValue[]; |
42 |
| - } |
| 23 | + interface KoaHelmetContentSecurityPolicyDirectives { |
| 24 | + baseUri?: KoaHelmetCspDirectiveValue[]; |
| 25 | + childSrc?: KoaHelmetCspDirectiveValue[]; |
| 26 | + connectSrc?: KoaHelmetCspDirectiveValue[]; |
| 27 | + defaultSrc?: KoaHelmetCspDirectiveValue[]; |
| 28 | + fontSrc?: KoaHelmetCspDirectiveValue[]; |
| 29 | + formAction?: KoaHelmetCspDirectiveValue[]; |
| 30 | + frameAncestors?: KoaHelmetCspDirectiveValue[]; |
| 31 | + frameSrc?: KoaHelmetCspDirectiveValue[]; |
| 32 | + imgSrc?: KoaHelmetCspDirectiveValue[]; |
| 33 | + mediaSrc?: KoaHelmetCspDirectiveValue[]; |
| 34 | + objectSrc?: KoaHelmetCspDirectiveValue[]; |
| 35 | + pluginTypes?: KoaHelmetCspDirectiveValue[]; |
| 36 | + prefetchSrc?: KoaHelmetCspDirectiveValue[]; |
| 37 | + reportTo?: string; |
| 38 | + reportUri?: string; |
| 39 | + sandbox?: KoaHelmetCspDirectiveValue[]; |
| 40 | + scriptSrc?: KoaHelmetCspDirectiveValue[]; |
| 41 | + scriptSrcAttr?: KoaHelmetCspDirectiveValue[]; |
| 42 | + scriptSrcElem?: KoaHelmetCspDirectiveValue[]; |
| 43 | + styleSrc?: KoaHelmetCspDirectiveValue[]; |
| 44 | + styleSrcAttr?: KoaHelmetCspDirectiveValue[]; |
| 45 | + styleSrcElem?: KoaHelmetCspDirectiveValue[]; |
| 46 | + workerSrc?: KoaHelmetCspDirectiveValue[]; |
| 47 | + } |
43 | 48 |
|
44 |
| - interface KoaHelmetContentSecurityPolicyConfiguration { |
45 |
| - reportOnly?: boolean; |
46 |
| - useDefaults?: boolean; |
47 |
| - directives?: KoaHelmetContentSecurityPolicyDirectives; |
48 |
| - } |
| 49 | + interface KoaHelmetContentSecurityPolicyConfiguration { |
| 50 | + reportOnly?: boolean; |
| 51 | + useDefaults?: boolean; |
| 52 | + directives?: KoaHelmetContentSecurityPolicyDirectives; |
| 53 | + } |
49 | 54 |
|
50 |
| - interface KoaHelmet { |
51 |
| - (options?: HelmetOptions): Middleware; |
52 |
| - contentSecurityPolicy(options?: KoaHelmetContentSecurityPolicyConfiguration): Middleware; |
53 |
| - crossOriginEmbedderPolicy(options?: HelmetOptions['crossOriginEmbedderPolicy']): Middleware; |
54 |
| - crossOriginOpenerPolicy(options?: HelmetOptions['crossOriginOpenerPolicy']): Middleware; |
55 |
| - crossOriginResourcePolicy(options?: HelmetOptions['crossOriginResourcePolicy']): Middleware; |
56 |
| - dnsPrefetchControl(options?: HelmetOptions['dnsPrefetchControl']): Middleware; |
57 |
| - expectCt(options?: HelmetOptions['expectCt']): Middleware; |
58 |
| - frameguard(options?: HelmetOptions['frameguard']): Middleware; |
59 |
| - hidePoweredBy(options?: HelmetOptions['hidePoweredBy']): Middleware; |
60 |
| - hsts(options?: HelmetOptions['hsts']): Middleware; |
61 |
| - ieNoOpen(options?: HelmetOptions['ieNoOpen']): Middleware; |
62 |
| - noSniff(options?: HelmetOptions['noSniff']): Middleware; |
63 |
| - permittedCrossDomainPolicies(options?: HelmetOptions['permittedCrossDomainPolicies']): Middleware; |
64 |
| - referrerPolicy(options?: HelmetOptions['referrerPolicy']): Middleware; |
65 |
| - xssFilter(options?: HelmetOptions['xssFilter']): Middleware; |
66 |
| - } |
| 55 | + interface KoaHelmet { |
| 56 | + (options?: HelmetOptions): Middleware; |
| 57 | + contentSecurityPolicy( |
| 58 | + options?: KoaHelmetContentSecurityPolicyConfiguration, |
| 59 | + ): Middleware; |
| 60 | + crossOriginEmbedderPolicy( |
| 61 | + options?: HelmetOptions["crossOriginEmbedderPolicy"], |
| 62 | + ): Middleware; |
| 63 | + crossOriginOpenerPolicy( |
| 64 | + options?: HelmetOptions["crossOriginOpenerPolicy"], |
| 65 | + ): Middleware; |
| 66 | + crossOriginResourcePolicy( |
| 67 | + options?: HelmetOptions["crossOriginResourcePolicy"], |
| 68 | + ): Middleware; |
| 69 | + dnsPrefetchControl( |
| 70 | + options?: HelmetOptions["dnsPrefetchControl"], |
| 71 | + ): Middleware; |
| 72 | + expectCt(options?: HelmetOptions["expectCt"]): Middleware; |
| 73 | + frameguard(options?: HelmetOptions["frameguard"]): Middleware; |
| 74 | + hidePoweredBy(options?: HelmetOptions["hidePoweredBy"]): Middleware; |
| 75 | + hsts(options?: HelmetOptions["hsts"]): Middleware; |
| 76 | + ieNoOpen(options?: HelmetOptions["ieNoOpen"]): Middleware; |
| 77 | + noSniff(options?: HelmetOptions["noSniff"]): Middleware; |
| 78 | + permittedCrossDomainPolicies( |
| 79 | + options?: HelmetOptions["permittedCrossDomainPolicies"], |
| 80 | + ): Middleware; |
| 81 | + referrerPolicy(options?: HelmetOptions["referrerPolicy"]): Middleware; |
| 82 | + xssFilter(options?: HelmetOptions["xssFilter"]): Middleware; |
| 83 | + } |
67 | 84 | }
|
68 | 85 |
|
69 | 86 | declare const koaHelmet: koaHelmet.KoaHelmet;
|
|
0 commit comments