> 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

## Config

An object representing the HUMAN configuration that will be provided to the enforcer. A new instance of this class must be constructed and provided to the Enforcer.

### constructor

Creates a new instance of the `Config` class from an `HSConfig` object. The `Config` constructor validates the provided `HSConfig` object. It is unnecessary to validate this configuration object for every Lambda invocation, so recommended usage is to initialize the `Config` instance outside of the Lambda request handler and provide it to the `Enforcer` within the handler.

```ts
constructor(config: HSConfig) => Config
```

* Parameters
  * config: HSConfig
* Returns a new instance of `Config`

> **Note**
>
> For more information on possible enforcer configurations, see the [configuration documentation](/applications/aws-lambda-authorizer/configuration).

## Enforcer

The entity responsible for performing HUMAN enforcement.

### constructor

Creates a new instance of the `Enforcer` class.

```ts
constructor(config: Config) => Enforcer
```

* Parameters
  * config: Config
* Returns a new instance of the Enforcer class

### enforce

Executes the enforcement functionality, returning either `null` when the request should be passed to the origin, or an `APIGatewayAuthorizerWithContextResult<{pxResponseBody?: string;}>` in the case of a block response.

```ts
enforce(event: APIGatewayRequestAuthorizerEvent) => Promise<null | APIGatewayAuthorizerWithContextResult<{pxResponseBody?: string;}>
```

* Parameters
  * event: [APIGatewayRequestAuthorizerEvent](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-input.html#w38aac15b9c11c26c29b5)
* Returns a Promise resolving to null or an [APIGatewayAuthorizerWithContextResult](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-output.html)

#### postEnforce

Performs any post-enforcement processing actions required.

```ts
postEnforce(event: APIGatewayAuthorizerWithContextResult, response: APIGatewayAuthorizerWithContextResult) => Promise<void>
```

* Parameters
  * event: [APIGatewayRequestAuthorizerEvent](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-input.html#w38aac15b9c11c26c29b5)
  * response: [APIGatewayAuthorizerWithContextResult](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-output.html)
* Returns a Promise that resolves to void