{"_id":"@chen.zimmer.perimeterx/internal-human-security-netlify-enforcer","_rev":"2-97dc1163533d72df2ddfc57c4e719183","name":"@chen.zimmer.perimeterx/internal-human-security-netlify-enforcer","dist-tags":{"latest":"1.0.24-internal"},"versions":{"1.0.23-test":{"name":"@chen.zimmer.perimeterx/internal-human-security-netlify-enforcer","version":"1.0.23-test","keywords":[],"author":"","license":"MIT","_id":"@chen.zimmer.perimeterx/internal-human-security-netlify-enforcer@1.0.23-test","maintainers":[{"name":"chen.zimmer.perimeterx","email":"chen.zimmer@perimeterx.com"}],"dist":{"shasum":"996f1d6023aa1e32e962fe09692a24462c4b0f1f","tarball":"https://registry.npmjs.org/@chen.zimmer.perimeterx/internal-human-security-netlify-enforcer/-/internal-human-security-netlify-enforcer-1.0.23-test.tgz","fileCount":141,"integrity":"sha512-xJXG9YkuhFIGgelrvh7/d8IJGF9v0rNXbQ/VsOrs1giwDi0X3hHge6YLBxFyg8ZL+2qCT++i3tsr6Ly/Svr+RQ==","signatures":[{"sig":"MEUCIDPpz4X0+0kTpT8aEz8O1Q2bWGJXvq5RK5jd+4rQdW8mAiEAoch7xMQmq6b8IGxIOzsgUCgebmK3Nb9HJg+aXhjHplI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":268609},"main":"./dist/cjs/index.js","types":"./dist/types/index.d.ts","module":"./dist/esm/index.mjs","exports":{".":{"import":"./dist/esm/index.mjs","require":"./dist/cjs/index.js"}},"gitHead":"95913db796ea04a1fc4db03c8d155c8addcfd96e","scripts":{"lint":"eslint 'src/**/*.ts' --fix","test":"NODE_OPTIONS=--openssl-legacy-provider jest --config jestconfig.json","build":"yarn build:cjs && yarn build:esm","clean":"rimraf dist","format":"prettier --write \"src/**/*.ts\" ","prepack":"yarn clean && yarn build","prepare":"yarn build","version":"yarn format && git add -A src","build:cjs":"tsc -p tsconfig.cjs.json","build:esm":"tsc -p tsconfig.esm.json && yarn rename:esm","preversion":"yarn lint","rename:esm":"/bin/zsh ./scripts/fix-mjs.sh","postversion":"git push && git push --tags","prepublishOnly":"yarn lint"},"_npmUser":{"name":"chen.zimmer.perimeterx","email":"chen.zimmer@perimeterx.com"},"_npmVersion":"8.19.3","description":"If your organization uses **Netlify**, you can use HUMAN's **Netlify Edge Function Enforcer** to protect against malicious behavior. The Netlify Edge Function is deployed to your content delivery network (CDN) and dictates how traffic should be handled pe","directories":{},"_nodeVersion":"16.19.1","dependencies":{"uuid":"^9.0.1","ip-range-check":"^0.2.0"},"_hasShrinkwrap":false,"packageManager":"yarn@4.2.2","devDependencies":{"eslint":"^9.8.0","rimraf":"^6.0.1","ts-node":"^10.9.2","prettier":"^3.3.3","@eslint/js":"^9.8.0","typescript":"^5.4.5","@types/node":"^20.12.7","@types/uuid":"^9.0.8","@types/eslint":"^9","@eslint/eslintrc":"^3.1.0","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.2.1","@typescript-eslint/parser":"^8.0.1","@typescript-eslint/eslint-plugin":"^8.0.1"},"_npmOperationalInternal":{"tmp":"tmp/internal-human-security-netlify-enforcer_1.0.23-test_1748260701467_0.12378985284317778","host":"s3://npm-registry-packages-npm-production"}},"1.0.24-internal":{"name":"@chen.zimmer.perimeterx/internal-human-security-netlify-enforcer","version":"1.0.24-internal","description":"If your organization uses **Netlify**, you can use HUMAN's **Netlify Edge Function Enforcer** to protect against malicious behavior. The Netlify Edge Function is deployed to your content delivery network (CDN) and dictates how traffic should be handled pe","main":"./dist/cjs/index.js","module":"./dist/esm/index.mjs","types":"./dist/types/index.d.ts","exports":{".":{"require":"./dist/cjs/index.js","import":"./dist/esm/index.mjs"}},"scripts":{"build:cjs":"tsc -p tsconfig.cjs.json","build:esm":"tsc -p tsconfig.esm.json && yarn rename:esm","build":"yarn build:cjs && yarn build:esm","clean":"rimraf dist","rename:esm":"/bin/zsh ./scripts/fix-mjs.sh","prepack":"yarn clean && yarn build","format":"prettier --write \"src/**/*.ts\" ","lint":"eslint 'src/**/*.ts' --fix","test":"NODE_OPTIONS=--openssl-legacy-provider jest --config jestconfig.json","prepare":"yarn build","prepublishOnly":"yarn lint","preversion":"yarn lint","version":"yarn format && git add -A src","postversion":"git push && git push --tags"},"keywords":[],"author":"","license":"MIT","packageManager":"yarn@4.2.2","devDependencies":{"@eslint/eslintrc":"^3.1.0","@eslint/js":"^9.8.0","@types/eslint":"^9","@types/node":"^20.12.7","@types/uuid":"^9.0.8","@typescript-eslint/eslint-plugin":"^8.0.1","@typescript-eslint/parser":"^8.0.1","eslint":"^9.8.0","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.2.1","prettier":"^3.3.3","rimraf":"^6.0.1","ts-node":"^10.9.2","typescript":"^5.4.5"},"dependencies":{"ip-range-check":"^0.2.0","uuid":"^9.0.1"},"gitHead":"95913db796ea04a1fc4db03c8d155c8addcfd96e","_id":"@chen.zimmer.perimeterx/internal-human-security-netlify-enforcer@1.0.24-internal","_nodeVersion":"16.19.1","_npmVersion":"8.19.3","dist":{"integrity":"sha512-5S/a+5vhaQ7sIzaMsMlfZ8QoBjY6twhH5XWHlFdCgQEQKt+K+DfbADQXmGjeR73+nugMaj8WIfOi8Kp7UKJuxw==","shasum":"354e9fb03d75df1480b399158e696347e6d50a1b","tarball":"https://registry.npmjs.org/@chen.zimmer.perimeterx/internal-human-security-netlify-enforcer/-/internal-human-security-netlify-enforcer-1.0.24-internal.tgz","fileCount":141,"unpackedSize":269183,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDKbt14YB2LJxxTycveHFuDZpJUhSrYunhg0SCdRtCGDAIgPZVumhGAtvQ+gif4LRGBE8vVp8SzemomViJAMdyxSzs="}]},"_npmUser":{"name":"chen.zimmer.perimeterx","email":"chen.zimmer@perimeterx.com"},"directories":{},"maintainers":[{"name":"chen.zimmer.perimeterx","email":"chen.zimmer@perimeterx.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/internal-human-security-netlify-enforcer_1.0.24-internal_1748332574374_0.5910446837516727"},"_hasShrinkwrap":false}},"time":{"created":"2025-05-26T11:58:21.370Z","modified":"2025-05-27T07:56:14.741Z","1.0.23-test":"2025-05-26T11:58:21.666Z","1.0.24-internal":"2025-05-27T07:56:14.545Z"},"license":"MIT","keywords":[],"description":"If your organization uses **Netlify**, you can use HUMAN's **Netlify Edge Function Enforcer** to protect against malicious behavior. The Netlify Edge Function is deployed to your content delivery network (CDN) and dictates how traffic should be handled pe","maintainers":[{"name":"chen.zimmer.perimeterx","email":"chen.zimmer@perimeterx.com"}],"readme":"# human-security-netlify-enforcer\n\nIf your organization uses **Netlify**, you can use HUMAN's **Netlify Edge Function Enforcer** to protect against malicious behavior. The Netlify Edge Function is deployed to your content delivery network (CDN) and dictates how traffic should be handled per your organization's standards.\n\nYou can learn how to install the Netlify Edge Function Enforcer with this article.\n\n## Prerequisites\n\n- A **Netlify account** with permissions to edit an existing **Edge Function** and **function file.** Learn more with Netlify's article [Get started with Edge Functions.](https://docs.netlify.com/edge-functions/get-started/)\n- A **command-line interface (CLI).**\n- A **text editor.**\n- **Node Version Manager (nvm)** installed on your device. See [nvm's GitHub repository](https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-and-updating) to learn how to install it.\n- The latest version of **Node.js**. After installing nvm, enter `nvm install stable` in your CLI to install it.\n- Your unique HUMAN information:\n    - Your **Application ID.** You can find this under **Platform Settings > Applications > Select an application > Application Settings > Application ID** in the HUMAN console. If you have multiple environments, you will also have multiple Application IDs, so be sure to choose the correct ID for the environment you want to install on.\n    - Your **Server Token.** You can find this under **Platform Settings > Applications > Status & Settings > Server Token.**\n    - Your **Risk Cookie Key.** You can find this under **Bot Defender > Policies > Policy Settings > Policy Information.**\n\n## Install the Enforcer\n\nThere are two parts to the integration. Be sure to complete each part in order.\n\n1. [Install dependencies:](https://edocs.humansecurity.com/docs/install-the-netlify-edge-function-enforcer#install-dependencies) Install the Enforcer package from HUMAN.\n2. [Use the package:](https://edocs.humansecurity.com/docs/install-the-netlify-edge-function-enforcer#use-the-package) Import the package into your Edge Function and deploy.\n\n### Install dependencies\n\n1. Navigate to your directory that has the Edge Function project you want to integrate the Enforcer on.\n2. Enter `npm install perimeterx-node-core-ts` to install the Enforcer package.\n\n> 🚧 Note\n>\n> **Do not** import the package using the `npm:` prefix in an `import` statement. Netlify does not support this syntax, and it will not install the package properly if you use it.\n\nYour Netlify Edge Function project directory should now have the package installed. Next, move on to [Use the package](https://edocs.humansecurity.com/docs/install-the-netlify-edge-function-enforcer#use-the-package) to complete your integration.\n\n### Use the package\n\n1. Open the project's **function file.**\n2. At the top of your function file, add the following import statements:\n\n```javascript\nimport { PXEnforcer, PXRawConfig } from \"perimeterx-node-core-ts\";\nimport type { Config, Context } from \"@netlify/edge-functions\";\n```\n\n3. At the beginning of your function, add the HUMAN configurations using the `PXRawConfig` object as shown.\n\n    - `PX_APP_ID` corresponds to your **Application ID.**\n    - `PX_COOKIE_SECRET` corresponds to your **Risk Cookie Key.**\n    - `PX_AUTH_TOKEN` corresponds to your **Server Token.**\n\n> 📘 Note\n>\n> While you can add `PX_APP_ID`, `PX_COOKIE_SECRET`, and `PX_AUTH_TOKEN` directly, we recommend using **Netlify environment variables** so your configuration is more flexible and secure. See [Netlify's help documentation](https://docs.netlify.com/environment-variables/get-started/) for more information.\n\n```javascript\nconst config: PXRawConfig = {\n        px_app_id: Netlify.env.get(\"PX_APP_ID\"),\n        px_cookie_secret: Netlify.env.get(\"PX_COOKIE_SECRET\"),\n        px_auth_token: Netlify.env.get(\"PX_AUTH_TOKEN\"),\n        px_extract_user_ip: (request) => {\n            return context.ip;\n        },\n    };\n```\n\n4. Add any additional custom configurations your organization wants to include in the `PXRawConfig` object. You can find all available configurations in our [help article.](https://edocs.humansecurity.com/v1/docs/netlify-edge-function-enforcer-configurations)\n\n> 🚧 Note\n>\n> While all other custom configurations are optional, you **must include** the `px_extract_user_ip` property as shown in **Step 3.** This lets HUMAN extract the correct end user IP.\n\n5. After the `PXRawConfig` object, add the following lines of code. These let HUMAN evaluate the request as soon as it hits the function.\n\n```javascript\nconst config: PXRawConfig = {\n   // HUMAN configurations\n   ...\n   };\nconst px = new PXEnforcer(config);\nconst resp = await px.enforce(request); // verifies the response from HUMAN\nif (resp.pxResponse) { // if the request is suspicious, return the Challenge page\n    return new Response(resp.pxResponse.body, {\n        headers: resp.pxResponse.headers as HeadersInit,\n        status: resp.pxResponse.status,\n    });\n} else { // if the request is valid, continue the execution flow\n    return await context.next();\n}\n```\n\n<br />\n\n6. If you would like to exclude Enforcer monitoring on specific paths, then you must configure the function to do so using either the TOML file or Netlify's `Config` object. Otherwise, move on to **Step 7.** By default, the Enforcer will run on **all requests.**\n\n```ini\n[[edge_functions]]\npattern = \"/(.*)\"\nexcludedPattern = [\n  \"/api/(.*)\",\n  \"/fapi/(.*)\",\n  \"(.*).(png|svg|map|woff2|ico|css)\"\n]\nfunction = \"human-enforcer\"\n```\n\n<br />\n\n7. Save your changes and deploy the function to Netlify.\n\nYour Netlify Edge Function has now been integrated with the HUMAN Enforcer. Once you complete your installation, be sure to contact HUMAN to complete your Tuning process.","readmeFilename":"README.md"}