Installation
Prerequisites
The HUMAN Fastly JavaScript Compute@Edge enforcer requires access to:
- Fastly Compute@Edge services
- Node.js v16.x or higher
Installation
- Get started by creating a Fastly C@E Service and downloading the Fastly CLI (if you haven’t already).
- Use the HUMAN Fastly JavaScript Compute@Edge starter kit or install the HUMAN Enforcer NPM package into your existing Fastly project.
- Integrate the HUMAN Enforcer into your project.
For an out-of-the box request handler with the HUMAN Enforcer integrated into it already, simply import and use the createEnforcedRequestHandler
function.
The example below shows what the createEnforcedRequestHandler()
function does behind the scenes. For a more customized solution, create a new HumanSecurityEnforcer
instance and use it in your request handler as desired.
The recommended usage is to:
- initialize the
HumanSecurityEnforcer
, call theenforce()
function, and return any resulting response as early as possible in the request flow to minimize invocation of unnecessary logic. - call the
postEnforce()
right before returning the response from the request handler to ensure any necessary response modifications are performed and HUMAN data is sent to the collector.
- Add or modify the required HUMAN backends in your
fastly.toml
file (see here for more info) and/or directly to your Fastly service, replacing the application ID placholder with your application ID.
Backend Names
The default names of these backends are human_sapi
, human_collector
, human_client
, and human_captcha
. If the default human_*
backend names are changed, the new backend names must be explicitly indicated in the Enforcer configuration using the px_backend_score_name
, px_backend_collector_name
, px_backend_client_name
, and px_backend_captcha_name
configurations, respectively.
- Build, test, and deploy the worker using the Fastly CLI.