diff --git a/src/directives/types.ts b/src/directives/types.ts index 08e752d1..62f117f6 100644 --- a/src/directives/types.ts +++ b/src/directives/types.ts @@ -1,7 +1,7 @@ /** * Represents the configuration for the validation module */ -export interface ValidationSettings { +export type ValidationSettings = { /** * An array of the allowed kebab-cased directives for a header */ @@ -10,7 +10,7 @@ export interface ValidationSettings { * An object literal of the parameters that have special formatting. Separators defines the character delineating the directiveKey from the directiveValue: e.g. max-age=12345. Defaults to ' '. */ separators?: { [key: string]: string }; -} +}; /** * Determines whether the header allows multiple directives or only one diff --git a/src/directives/validation.ts b/src/directives/validation.ts index 4ae49bf2..b19c46b2 100644 --- a/src/directives/validation.ts +++ b/src/directives/validation.ts @@ -146,7 +146,11 @@ export function directiveValidation( ); } - return format(directiveKey, specificationName, directiveToken); + return format( + directiveKey, + specificationName, + directiveToken as string, + ); }, ); diff --git a/src/fortifyHeaders.ts b/src/fortifyHeaders.ts index a6f70997..2b35dee5 100644 --- a/src/fortifyHeaders.ts +++ b/src/fortifyHeaders.ts @@ -1,7 +1,7 @@ import { FortifyHeaders, FortifySettings, GenerationOptions } from './types'; import { toHeaderCasing } from './directives/normalize'; import { getAllHeaders } from './headers'; -import { HeaderFunction } from './headers/types'; +import { FortifyHeader, HeaderFunction } from './headers/types'; /** * Builds out a configuration that will generate the defaults. Defaults are generated @@ -50,7 +50,7 @@ export function fortifyHeaders( if (!headerFactory) { throw new Error(`${cur} is not a supported header`); } - const headerResult = headerFactory(directiveValues); + const headerResult = headerFactory(directiveValues as FortifyHeader); acc[headerName] = headerResult[headerName]; return acc; }, diff --git a/src/headers/content-security-policy/types.ts b/src/headers/content-security-policy/types.ts index 4ea15cdd..f40a6ad9 100644 --- a/src/headers/content-security-policy/types.ts +++ b/src/headers/content-security-policy/types.ts @@ -6,7 +6,7 @@ type SandboxDirective = boolean | string; * Represents the user-specified header configuration for Content-Security-Policy * see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy */ -export interface ContentSecurityPolicy extends FortifyHeader { +export type ContentSecurityPolicy = FortifyHeader & { /** * Fires a SecurityPolicyViolationEvent. */ @@ -103,4 +103,4 @@ export interface ContentSecurityPolicy extends FortifyHeader { * Enables a sandbox for the requested resource similar to the