> This page is for Applications Protection.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.humansecurity.com/llms.txt.

# API

## createEnforcedRequestHandler()

A function that returns a default request handler with built-in HUMAN enforcement. Useful if there is little request/response manipulation in your Edgio Edge Function.

```ts
createEnforcedRequestHandler(
    config: HumanSecurityConfiguration,
    onPass: (request: Request) => Response | Promise<Response>,
    onResponse?: (response: Response) => Response | Promise<Response>,
) => ((request: Request, context: Context) => Promise<Response>)
```

* Parameters
  * config: HumanSecurityConfiguration
  * onPass: (request: [Request](https://docs.edg.io/guides/v7/edge-functions#request-class)) => [Response](https://docs.edg.io/guides/v7/edge-functions#response-class) | Promise\[\[Response]\([https://docs.edg.io/guides/v7/edge-functions#response-class)\\\](](https://docs.edg.io/guides/v7/edge-functions#response-class\)\\]\()[Response](https://docs.edg.io/guides/v7/edge-functions#response-class))
  * onResponse?: (response: [Response](https://docs.edg.io/guides/v7/edge-functions#response-class)) => [Response](https://docs.edg.io/guides/v7/edge-functions#response-class) | Promise\[\[Response]\([https://docs.edg.io/guides/v7/edge-functions#response-class)\\\](](https://docs.edg.io/guides/v7/edge-functions#response-class\)\\]\()[Response](https://docs.edg.io/guides/v7/edge-functions#response-class))
* Returns a default HTTP request handler function in the form of (request: [Request](https://docs.edg.io/guides/v7/edge-functions#request-class), context: [Context](https://docs.edg.io/guides/v7/edge-functions#edge-function-parameters)) => Promise\[\[Response]\([https://docs.edg.io/guides/v7/edge-functions#response-class)\\\](](https://docs.edg.io/guides/v7/edge-functions#response-class\)\\]\()[Response](https://docs.edg.io/guides/v7/edge-functions#response-class))

## HumanSecurity

### constructor

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

```ts
constructor(params: HumanSecurityConfiguration) => HumanSecurity
```

* Parameters
  * params: ConfigurationParams
* Returns a new instance of the HumanSecurity class

### createEnforcer()

Creates a new Enforcer instance.

```ts
createEnforcer() => Enforcer
```

* Returns a new Enforcer instance with the configurations provided to the HumanSecurity instance

## Enforcer

The entity responsible for performing HUMAN enforcement.

### enforce()

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

```ts
enforce(request: Request, context: Context) => Promise<Response | null>
```

* Parameters
  * request: [Request](https://docs.edg.io/guides/v7/edge-functions#request-class)
  * context: [Context](https://docs.edg.io/guides/v7/edge-functions#edge-function-parameters)
* Returns a Promise resolving to a [Response](https://docs.edg.io/guides/v7/edge-functions#response-class) or null

### postEnforce()

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

```ts
postEnforce(response: Response) => Promise<void>
```

* Parameters
  * response: [Response](https://docs.edg.io/guides/v7/edge-functions#response-class)
* Returns a Promise resolving to void