{"id":30497632,"url":"https://github.com/humansecurity/perimeterx-node-core","last_synced_at":"2025-08-25T03:41:21.839Z","repository":{"id":27814483,"uuid":"102629785","full_name":"HumanSecurity/perimeterx-node-core","owner":"HumanSecurity","description":null,"archived":false,"fork":false,"pushed_at":"2024-01-31T13:32:51.000Z","size":916,"stargazers_count":6,"open_issues_count":8,"forks_count":8,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-08-09T13:16:19.127Z","etag":null,"topics":["enforcer","perimeterx"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HumanSecurity.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-06T16:03:33.000Z","updated_at":"2025-07-24T05:25:02.000Z","dependencies_parsed_at":"2023-12-02T21:26:30.439Z","dependency_job_id":"5593165d-c3a9-4c36-a8d8-f705be6e1b16","html_url":"https://github.com/HumanSecurity/perimeterx-node-core","commit_stats":{"total_commits":380,"total_committers":28,"mean_commits":"13.571428571428571","dds":0.7263157894736842,"last_synced_commit":"1f84b959f867df13f34ed2b2ac7c89ebdb53fb7c"},"previous_names":[],"tags_count":70,"template":false,"template_full_name":null,"purl":"pkg:github/HumanSecurity/perimeterx-node-core","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HumanSecurity%2Fperimeterx-node-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HumanSecurity%2Fperimeterx-node-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HumanSecurity%2Fperimeterx-node-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HumanSecurity%2Fperimeterx-node-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HumanSecurity","download_url":"https://codeload.github.com/HumanSecurity/perimeterx-node-core/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HumanSecurity%2Fperimeterx-node-core/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272004279,"owners_count":24856937,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-25T02:00:12.092Z","response_time":1107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["enforcer","perimeterx"],"created_at":"2025-08-25T03:41:18.365Z","updated_at":"2025-08-25T03:41:21.795Z","avatar_url":"https://github.com/HumanSecurity.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/PerimeterX/perimeterx-node-core.svg?branch=master)](https://travis-ci.org/PerimeterX/perimeterx-node-core)\n[![Known Vulnerabilities](https://snyk.io/test/github/PerimeterX/perimeterx-node-core/badge.svg?targetFile=package.json)](https://snyk.io/test/github/PerimeterX/perimeterx-node-core?targetFile=package.json)\n\n![image](https://storage.googleapis.com/perimeterx-logos/primary_logo_red_cropped.png)\n\n[PerimeterX](http://www.perimeterx.com) Shared base for NodeJS enforcers\n=============================================================\n\n\u003e Latest stable version: [v3.15.1](https://www.npmjs.com/package/perimeterx-node-core)\n\nThis is a shared base implementation for PerimeterX Express enforcer and future NodeJS enforcers. For a fully functioning implementation example, see the [Node-Express enforcer](https://github.com/PerimeterX/perimeterx-node-express/) implementation.\n\nTable of Contents\n-----------------\n\n- [Usage](#usage)\n    * [Installation](#installation)\n    *  [Basic Usage Example](#basic-usage)\n- [Contributing](#contributing)\n    *  [Tests](#tests)\n\n\u003ca name=\"Usage\"\u003e\u003c/a\u003e\n\n\u003ca name=\"installation\"\u003e\u003c/a\u003e Installation\n----------------------------------------\n\n`$ npm install --save perimeterx-node-core`\n\n### \u003ca name=\"basic-usage\"\u003e\u003c/a\u003e Basic Usage Example\nTo integrate this module into an enforcer, users should initialize the enforcer.\n```javascript\nfunction initPXModule(params, client) {\n    params.px_module_version = '\u003cyour module version\u003e';\n    enforcer = new PxEnforcer(params, client);\n    //if dynamic configurations is configured\n    if (enforcer.config.conf.DYNAMIC_CONFIGURATIONS) {\n        setInterval(enforcer.config.confManager.loadData.bind(enforcer.config.confManager), enforcer.config.conf.CONFIGURATION_LOAD_INTERVAL);\n    }\n}\n```\n\nOn every request, call `enforce`.\n```javascript\n/**\n * pxMiddleware - middleware wrapper to score verification.\n *\n * @param {Object} req - HTTP Request.\n * @param {Object} res - HTTP Response.\n * @param {Function} next - callback function.\n */\nfunction pxMiddleware(req, res, next) {\n    enforcer.enforce(req, res, (response) =\u003e {\n        if (response) { //block\n            res.status(response.status);\n            res.setHeader(response.header.key, response.header.value);\n            res.send(response.body);\n        } else { //pass\n            next();\n        }\n    });\n}\n```\n\nExtend the `PxClient` class to send activities to PerimeterX.\n```javascript\nconst { PxClient } = require('perimeterx-node-core');\n\nclass MyClient extends PxClient {\n    init(config) {\n        setInterval(() =\u003e {\n            this.submitActivities(config);\n        }, 1000);\n    }\n}\n\nmodule.exports = { MyClient };\n```\n\nMake sure to pass the client instance when initializing the enforcer.\n```javascript\nfunction initPXModule(params) {\n    params.px_module_version = '\u003cyour module version\u003e';\n    const pxClient = new MyClient();\n    enforcer = new PxEnforcer(params, pxClient);\n    //if dynamic configurations is configured\n    if (enforcer.config.conf.DYNAMIC_CONFIGURATIONS) {\n        setInterval(enforcer.config.confManager.loadData.bind(enforcer.config.confManager), enforcer.config.conf.CONFIGURATION_LOAD_INTERVAL);\n    }\n}\n```\n\n\u003ca name=\"contributing\"\u003e\u003c/a\u003e Contributing\n----------------------------------------\n\nThe following steps are welcome when contributing to our project:\n### Fork/Clone\nFirst and foremost, [Create a fork](https://guides.github.com/activities/forking/) of the repository, and clone it locally.\nCreate a branch on your fork, preferably using a self descriptive branch name.\n\n### Code/Run\nHelp improve our project by implementing missing features, adding capabilites or fixing bugs.\n\nTo run the code, simply follow the steps in the [installation guide](#installation). Grab the keys from the PerimeterX Portal, and try refreshing your page several times continously. If no default behaviours have been overriden, you should see the PerimeterX block page. Solve the CAPTCHA to clean yourself and start fresh again.\n\n### Test\n\u003e Tests for this project are written using [Mocha](https://mochajs.org/).\n\n**Dont forget to test**. The project relies heavily on tests, thus ensuring each user has the same experience, and no new features break the code.\nBefore you create any pull request, make sure your project has passed all tests, and if any new features require it, write your own.\n\n\n##### \u003ca name=\"tests\"\u003e\u003c/a\u003e Running tests\n\n```bash\n$ npm test\n```\n\n\u003e Note: running tests without a valid PerimeterX app id, auth token and\n\u003e cookie key will not work.\n\n### Pull Request\nAfter you have completed the process, create a pull request to the Upstream repository. Please provide a complete and thorough description explaining the changes. Remember this code has to be read by our maintainers, so keep it simple, smart and accurate.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumansecurity%2Fperimeterx-node-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhumansecurity%2Fperimeterx-node-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumansecurity%2Fperimeterx-node-core/lists"}