For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
HUMAN DashboardHUMAN WebsiteRequest a Demo
Product GuidesEnforcer GuidesMobile SDKAPI ReferenceCustomer support
Product GuidesEnforcer GuidesMobile SDKAPI ReferenceCustomer support
  • General
    • About Enforcers
    • Support first-party HUMAN calls
    • Troubleshoot Enforcer configurations
  • Enforcer frameworks
    • Akamai ESI
    • Apache - C Module
    • ASP.NET
    • Callout Enforcer
      • Cloudflare Worker changelog
      • Installation
      • Installation with Terraform
      • Manual installation
      • Deploy the Cloudflare Enforcer for Shopify applications
      • API
      • Configuration
      • Configuration (v5 and Below)
      • Upgrading to Version 6
    • Envoy Proxy
    • F5 BIGIP
    • Fastly JavaScript Compute@Edge
    • Google Cloud Platform (GCP) Callout Enforcer
    • Kong Plugin
    • NGINX - C Module
    • NGINX - LUA Module
    • PHP
    • Python
    • Ruby
    • Salesforce Commerce Cloud Cartridge
LogoLogo
Login
Login
HUMAN DashboardHUMAN WebsiteRequest a Demo
On this page
  • HumanSecurityEnforcer
  • HumanSecurityEnforcer.initialize()
  • Service Worker Syntax
  • ES Modules Syntax
  • enforce()
  • Service Worker Syntax
  • ES Modules Syntax
  • postEnforce()
  • Service Worker Syntax
  • ES Modules Syntax
Enforcer frameworksCloudflare Worker

API

Was this page helpful?
Previous

Cloudflare configuration options

Next
Built with

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

1HumanSecurityEnforcer.initialize(config: HumanSecurityConfiguration) => Promise<HumanSecurityEnforcer>
  • Parameters
    • params: HumanSecurityConfiguration
  • Returns a Promise resolving to a new instance of the HumanSecurityEnforcer class

ES Modules Syntax

1HumanSecurityEnforcer.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…

  1. The request should not be blocked.
  2. The request should be blocked, but the enforcer has been configured to let these requests pass.

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…

  1. The request should be blocked, and the response is a block page generated by the enforcer.
  2. 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.

Service Worker Syntax

1enforce(event: FetchEvent) => Promise<Request | Response>
  • Parameters
    • event: FetchEvent
  • Returns a Promise resolving to a Request or Response

ES Modules Syntax

1enforce(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

1postEnforce(event: FetchEvent, response: Response) => Promise<Response>
  • Parameters
    • event: FetchEvent
    • response: Response
  • Returns a Promise resolving to a Response.

ES Modules Syntax

1postEnforce(executionContext: ExecutionContext, response: Response) => Promise<Response>
  • Parameters
    • executionContext: ExecutionContext
    • response: Response
  • Returns a Promise resolving to a Response.