API
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.
Service Worker Syntax
HumanSecurityEnforcer.initialize(config: HumanSecurityConfiguration) => Promise<HumanSecurityEnforcer>
- Parameters
- params: HumanSecurityConfiguration
- Returns a Promise resolving to a new instance of the HumanSecurityEnforcer class
ES Modules Syntax
HumanSecurityEnforcer.initialize(config: HumanSecurityConfiguration, env?: Environment) => Promise<HumanSecurityEnforcer>
- Parameters
- params: HumanSecurityConfiguration
- env?: Environment
- 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.
The function returns a Request when...
- The request should not be blocked.
- The request should be blocked, but the enforcer has been configured to let these requests pass.
Note: Depending on the products and features enabled in the enforcer, the
enforce()
function may return a Request with additional headers that were not present on the original Request!
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.
Note: Modifications can be made to this response as needed prior to returning it from the main function.
Service Worker Syntax
enforce(event: FetchEvent) => Promise<Request | Response>
- Parameters
- event: FetchEvent
- Returns a Promise resolving to a Request or Response
ES Modules Syntax
enforce(executionContext: ExecutionContext, request: Request) => Promise<Request | Response>
- Parameters
- executionContext: ExecutionContext
- request: Request
- Returns a Promise resolving to a Request or Response
postEnforce()
Performs any post-enforcement processing actions and final modifications to the response (i.e., setting cookies or headers) if needed.
Service Worker Syntax
postEnforce(event: FetchEvent, response: Response) => Promise<Response>
- Parameters
- event: FetchEvent
- response: Response
- Returns a Promise resolving to a Response.
ES Modules Syntax
postEnforce(executionContext: ExecutionContext, response: Response) => Promise<Response>
- Parameters
- executionContext: ExecutionContext
- response: Response
- Returns a Promise resolving to a Response.
Updated 12 days ago