createDefaultEnforcedRouter

Creates a Router that has the HUMAN enforcer integrated into it already.

createDefaultEnforcedRouter(params: ConfigurationParams, originName: string) => Router
  • Parameters
    • params: ConfigurationParams
    • originName: string
  • Returns a Router

HumanSecurity

constructor

Creates a new instance of the HumanSecurity class from a ConfigurationParams object (see the configuration section for more information).

constructor(params: ConfigurationParams) => HumanSecurity
  • Parameters
    • params: ConfigurationParams
  • Returns a new instance of the HumanSecurity class

matchFirstParty

Provides the required first party path and handler parameters for the Router.match() function.

matchFirstParty() => [string, RouteHandler]
  • Returns an array whose elements are
    • a string for matching HUMAN first party requests ('/<FIRST_PARTY_PREFIXES>/:path*')
    • a RouteHandler for first party requests

Note: Caching settings are controlled by the Cache-Control response header.

matchFilteredExtensions

Provides the filtered extension path and handler parameters for the Router.match() function.

matchFilteredExtensions(originName: string) => [string, RouteHandler]
  • Parameters
    • originName: string
  • Returns an array whose elements are
    • a string for matching HUMAN requests with filtered extensions
    • a RouteHandler for requests that should be filtered based on their file extensions

The path match will be a string like '/:path*/:file.:ext(jpg|css|png|...)*' where the extensions are based px_filter_by_extension configuration value. This function requires the originName so that requests can be proxied to the origin if they are not found in the cache.

📘

Note

Caching settings are controlled by the Cache-Control response header.

createEnforcer

Creates a new Enforcer instance. For use inside the compute function.

createEnforcer() => Enforcer
  • Returns a new Enforcer instance with the configurations provided to the HumanSecurity instance

Enforcer

The entity responsible for performing HUMAN enforcement. A new Enforcer should be created using createEnforcer() inside the function passed to the compute() function.

enforce

Executes the enforcement functionality, returning either a response or null depending on which action should be taken.

enforce(request: Request, response: Response) => Promise<Response | null>

postEnforce

Performs any post-enforcement processing actions and final modifications to (i.e., setting cookies or headers on) the response if needed.

postEnforce(response: Response) => Promise<void>
  • Parameters
  • Returns a Promise resolving to void

📘

Note

The postEnforce function adds a Set-Cookie header to the response, so these responses will not be cached.