API
createEnforcedRequestHandler
A function that creates a default request handler with built-in HUMAN enforcement. Useful if there is little request/response manipulation in your Fastly JS service.
- Parameters
- config: HumanSecurityConfiguration
- onPass: (event: FetchEvent) => Response | Promise[[Response](https://js-compute-reference-docs.edgecompute.app/docs/globals/Response/)\](Response)
- onResponse?: (response: Response) => Response | Promise[[Response](https://js-compute-reference-docs.edgecompute.app/docs/globals/Response/)\](Response)
- Returns a handler function that accepts a FetchEvent and returns a Promise resolving to a Response.
Sample usage:
HumanSecurityEnforcer
The entity responsible for performing HUMAN enforcement.
HumanSecurityEnforcer.initialize()
A static function that creates a new instance of the HumanSecurityEnforcer class from a HumanSecurityConfiguration object.
- Parameters
- params: HumanSecurityConfiguration
- Returns a Promise resolving to a new instance of the HumanSecurityEnforcer class
enforce()
Executes the enforcement functionality, returning a request or response depending on which action should be taken by the worker.
- Parameters
- event: FetchEvent
- Returns a Promise resolving to a Response or null
The function returns null when…
- The request should not be blocked.
- The request should be blocked, but the enforcer has been configured to let these requests pass.
The function may add headers to the original Request object present on the incoming FetchEvent.
The function returns a Response when…
- The request should be blocked, and the response is a block page generated by the enforcer.
- The request was a first-party request, and the response is the first-party resource requested.
Modifications can be made to this response as needed prior to returning it from the main function.
postEnforce()
Performs any post-enforcement processing actions and final modifications to (i.e., setting cookies or headers on) the response if needed.