{"_id":"@cheq.ai/cheq-middlewares-sales","_rev":"13-758ce504498c7f3d76c42e40640cedbd","name":"@cheq.ai/cheq-middlewares-sales","dist-tags":{"latest":"1.0.39"},"versions":{"1.0.38":{"name":"@cheq.ai/cheq-middlewares-sales","version":"1.0.38","keywords":["cheq","http","https","middleware","RTI","real time interception"],"author":{"name":"Cheq.ai"},"license":"Apache","_id":"@cheq.ai/cheq-middlewares-sales@1.0.38","maintainers":[{"name":"amit.c2","email":"amit.c@cheq.ai"},{"name":"almog.l.cheq","email":"almog.l@cheq.ai"}],"homepage":"https://github.com/cheq-ai/cheq-middlewares-sales.git#readme","bugs":{"url":"https://github.com/cheq-ai/cheq-middlewares-sales.git/issues"},"dist":{"shasum":"2a56f2a08ea24f918c0e567cb500b126e84763d5","tarball":"https://registry.npmjs.org/@cheq.ai/cheq-middlewares-sales/-/cheq-middlewares-sales-1.0.38.tgz","fileCount":22,"integrity":"sha512-lHTFLOVTlhiuM+3S0mDnFj/flQSuXPUaXqAIGqJiJFp8NkaQmcZBMDTikY3xavXBFqO7OQQhIxBlmu+KjEIXwA==","signatures":[{"sig":"MEYCIQD5EvZyWpAJnZ0T5TD6Ye0VfBiO/B0WbHJ5tINfYtGkwQIhAJCmp3dfzvmXNzhV4Vxs8c4mpMwc10xzd0bbhGk14HxT","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":46642},"main":"index.js","gitHead":"2d33ef6dd8f1f883819907867a56200a17aa09bc","scripts":{"test":"jest --coverage=true","version-patch":"sh scripts/publish.sh"},"_npmUser":{"name":"amit.c2","email":"amit.c@cheq.ai"},"repository":{"url":"git+https://github.com/cheq-ai/cheq-middlewares-sales.git","type":"git"},"_npmVersion":"8.19.4","description":"CHEQ middlewares","directories":{"lib":"lib","test":"test"},"_nodeVersion":"16.20.2","dependencies":{},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^27.5.1","eslint":"^7.32.0","express":"^4.1.1","eslint-plugin-jest":"^26.5.3"},"_npmOperationalInternal":{"tmp":"tmp/cheq-middlewares-sales_1.0.38_1725439086095_0.9574875255319337","host":"s3://npm-registry-packages"}},"1.0.39":{"name":"@cheq.ai/cheq-middlewares-sales","version":"1.0.39","keywords":["cheq","http","https","middleware","RTI","real time interception"],"author":{"name":"Cheq.ai"},"license":"Apache","_id":"@cheq.ai/cheq-middlewares-sales@1.0.39","maintainers":[{"name":"amit.c2","email":"amit.c@cheq.ai"},{"name":"almog.l.cheq","email":"almog.l@cheq.ai"}],"homepage":"https://github.com/cheq-ai/cheq-middlewares-sales.git#readme","bugs":{"url":"https://github.com/cheq-ai/cheq-middlewares-sales.git/issues"},"dist":{"shasum":"b1af3578701be509c484191779c5772260c01ad5","tarball":"https://registry.npmjs.org/@cheq.ai/cheq-middlewares-sales/-/cheq-middlewares-sales-1.0.39.tgz","fileCount":22,"integrity":"sha512-jTJQ6AOqA8uDfUFZGaZ2YeZX/1n4hZ69OJ34NwnhaNmOMY3B+LtA1JvWigpH1WFrblvTA0MiXQdSYH9ye0Li+A==","signatures":[{"sig":"MEUCIQCDY8ynjV5/hqMEV3qGLqR5fE7pXQ10eCzh3X2ad/TQ0AIgeJwWbqQKkx8MJyA7ATDmpQArE7ee2tTvgPa9EMGPBaQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":46853},"main":"index.js","gitHead":"26e5f51c2e417baac86790d4e704de69c650b02e","scripts":{"test":"jest --coverage=true","version-patch":"sh scripts/publish.sh"},"_npmUser":{"name":"amit.c2","email":"amit.c@cheq.ai"},"repository":{"url":"git+https://github.com/cheq-ai/cheq-middlewares-sales.git","type":"git"},"_npmVersion":"8.19.4","description":"CHEQ middlewares","directories":{"lib":"lib","test":"test"},"_nodeVersion":"16.20.2","dependencies":{},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^27.5.1","eslint":"^7.32.0","express":"^4.1.1","eslint-plugin-jest":"^26.5.3"},"_npmOperationalInternal":{"tmp":"tmp/cheq-middlewares-sales_1.0.39_1728380820441_0.5981456011807806","host":"s3://npm-registry-packages"}}},"time":{"created":"2024-09-04T08:38:05.974Z","modified":"2026-04-13T21:05:41.726Z","1.0.38":"2024-09-04T08:38:06.326Z","1.0.39":"2024-10-08T09:47:00.610Z"},"bugs":{"url":"https://github.com/cheq-ai/cheq-middlewares-sales.git/issues"},"author":{"name":"Cheq.ai"},"license":"Apache","homepage":"https://github.com/cheq-ai/cheq-middlewares-sales.git#readme","keywords":["cheq","http","https","middleware","RTI","real time interception"],"repository":{"url":"git+https://github.com/cheq-ai/cheq-middlewares-sales.git","type":"git"},"description":"CHEQ middlewares","maintainers":[{"email":"tms+npm@cheq.ai","name":"cheq-tms"},{"email":"doron.d@cheq.ai","name":"dorondorani"},{"email":"almog.l@cheq.ai","name":"almog.l.cheq"},{"email":"pini.d@cheq.ai","name":"pinidayan"},{"email":"ben.g@cheq.ai","name":"ben.g.cheq"},{"email":"amit.c@cheq.ai","name":"amit.c2"}],"readme":"# cheq-express-middlewares-sales\nCHEQ middlewares for Express.Js\n\n\n\n## Features\n\n* [Installation](#installation)\n* [Real time interception](#real-time-interception)\n    * [Required configuration](#required-configuration)\n        * [API key](#api-key)\n        * [Tag hash](#tag-hash)\n        * [API endpoint](#api-endpoint)\n    * [Optional configuration](#optional-configuration)\n        * [Mode](#mode)\n        * [Threat type codes](#threat-type-codes)\n        * [Redirect URL](#redirect-url)\n        * [Callback function](#callback-function)\n        * [Ja3](#ja3)\n        * [Resource type](#resource-type)\n        * [IP header](#ip-header)\n        * [URI Exclusion](#uri-exclusion)\n        * [Timeout](#timeout)\n        * [Custom event name](#custom-event-name)\n     * [Usage example](#usage-example)\n   \n\n\n## Installation\n````bash\n$ npm install @cheq.ai/cheq-middlewares-sales\n````\n\n## Real time interception\n\nReal-Time Interception (RTI) supports API calls to provide detection of invalid traffic (IVT) to your site, in absolute real-time.  RTI will intercept IVT to prevent invalid visitors from harming your conversion efforts.\n\n### Configuration\n\n#### Required configuration\n\n##### API key\n\nAvailable on the Paradome platform under “Management -> RTI”\n\n```` js\nconst options = {\n    ...\n    apiKey: '11abc111-aa11-11aa-1111-11a11a11111'\n    ...\n}\n````\n\n##### Tag hash\n\nAppears in your CHEQ tag. \n\n```` js\nconst options = {\n    ...\n    tagHash: 'c99651e7936e27743ce51c728492aac9'\n    ...\n}\n````\n\n##### API endpoint\nThe nearest API endpoint to your server. Must be the same region as your tag domain.<br>Select the appropriate endpoint:\n- US: https://rti-us-east-1.cheqzone.com\n- EU: https://rti-eu-west-1.cheqzone.com\n\n```` js\nconst options = {\n    ...\n    apiEndpoint: 'https://rti-eu-west1.cheqzone.com'\n    ...\n}\n````\n\n#### Optional configuration\n\n##### Mode\n\n- `monitoring` - Will not perform any action\n\n- `blocking` - Will block Invalid traffic or redirect them to a different url (defind in [Redirect URL](#redirect-url)).\n\nThe default value will be `monitoring`.\n\n```` js\nconst options = {\n    ...\n    mode: 'monitoring'\n    ...\n}\n````\n\n##### sessionSyncMode\n\nServer (RTI) and Client (cheq-tag) are able to recognize the same session visit to the website by *either* of these 3 methods:\n\n- `banRti` - Will construct the rti-request with USER_AGENT field (IP is mandatory so it is included on all 3 methods).\n\n- `rtiCookie` - Will construct the rti-request with CHEQ_COOKIE (rti cookie) field. This is fetched from the site visit former RTI request. \n\n- `requestId` - Will construct the rti-request with REQUEST_ID field. This is fetched from the response of the client cheq-tag.\n\n- `none` - Will construct the rti-request with all above fields.\n\nThe default value will be `none`.\n\n```` js\nconst options = {\n    ...\n    sessionSyncMode: 'none'\n    ...\n}\n````\n\n##### Threat type codes\n\nThreat types are devided to two groups:\n\n1. Block/Redirect - traffic detected as threat types in this group would be blocked or redirected to a different page (defind in [Redirect URL](#redirect-url).<br>\n        Default threat type codes for this group:  2,3,6,7,10,11,16,18.\n        \n2. Captcha - threat type codes in this group would be reffered to [Callback function](#callback-function). <br>\n        Default threat type codes for this group:  4,5,13,14,15,17.\nThreat type must be unique for each list. \n\n```` js\nconst options = {\n  ...\n    threatTypesCodes: {\n        blockRedirect: [2, 3, 6, 7, 10, 11, 16, 18],\n        captcha: [4, 5, 13, 14, 15, 17]\n    }\n  ...\n};\n````\n##### Redirect URL\n\nA URL you would like to redirect invalid users to. \n\nIf it is empty the response will be status code 403 and the user will be blocked.\n\n```` js\nconst options = {\n    ...\n     redirectUrl: 'https://invalid-user.com'\n    ...\n}\n````\n\n##### Callback function\n\nA custom callback option, for instance to redirect to captcha page.\nIf it is empty, will use express next function.\n\n```` js\nconst options = {\n    ...\n     callback: function(req, res, next) {\n        //do somthing or call next()\n        }\n    ...\n}\n````\n##### Ja3\n\nRecommended - A function that extracts ja3 fingerprint from the request.<br>\nSSL/TLS client fingerprints\n\n```` js\nconst options = {\n    ...\n     getJa3: function getJa3(req) {\n        return req.query.ja3\n     }\n    ...\n}\n````\n##### Resource type\n\nA function to get the response content-type header. \n\nThis is recommended to improve detection.\n\n```` js\nconst options = {\n  ...\n  getResourceType: function(req) {\n    if(req.method === 'POST') {\n        return 'application/json';\n    } else if(req.url === '/') {\n        return 'text/html';\n    }\n   \n  }\n  ...\n};\n````\n\n##### IP header\n\nSpecify a trusted IP header to be used as client IP\n```` js\nconst options = {\n  ...\n  trustedIPHeader: 'client-ip'\n  ...\n};\n````\n\n\n\n\n\n\n##### URI Exclusion\n\nAn array of regular expressions or path that will be excluded\n\n```` js\nconst options = {\n  ...\n  URIExclusion: ['/about', '/careers']\n  ...\n};\n````\n\n\n\n\n\n##### Timeout\n\nOptional timeout in milliseconds, if absent value will be set to 100 milliseconds.\n\n```` js\nconst options = {\n    ...\n     timeout: 1000 // one second\n    ...\n}\n````\n\n##### Custom event name\n\nIn case a custom event name is used, this function extracts the name of the custom event.<br> \n\n```` js\nconst options = {\n    ...\n     getChannel: function getChannel(req) {\n        return req.query.channel\n     }\n    ...\n}\n````\n\n\n\n### Usage example RTI\n\n\n```` js\nconst express = require('express');\nconst app = express();\nconst PORT = process.env.PORT || 5000;\nconst { rti, eventsTypes } = require('@cheq.ai/cheq-express-middlewares');\nconst rtiOptions = {...};\nconst middleware = rti(rtiOptions);\n\napp.get('/subscribe', middleware(eventsTypes.SUBSCRIBE), function (req, res) {\n  res.send('Hello World');\n})\napp.get('/page_load', middleware(eventsTypes.PAGE_LOAD), function (req, res) {\n  res.send('Hello World');\n})\n\napp.listen(PORT);\n````\n\n### Usage example SLP\n\n\n```` js\nconst express = require('express');\nconst app = express();\nconst PORT = process.env.PORT || 3000;\nconst { slp, eventsTypes } = require('@cheq.ai/cheq-express-middlewares');\nconst slpOptions = {...};\nconst slpMiddleware = slp(slpOptions);\n\napp.post('/form-submit', slpMiddleware(eventsTypes.FORM_SUBMISSION), (req, res) => {\n  const slpRes = res.locals.slpRes\n\n  res.json(slpRes);\n});\n\napp.listen(PORT);\n````\n\n```` js\nconst slpOptions = {\n  apiKey: process.env.API_KEY,\n  tagHash: process.env.TAG_HASH,\n  apiEndpoint: SERVICE_ENDPOINT,\n  mode: \"fast\",\n  timeout: null,\n};\n````\n\n\n","readmeFilename":"README.md"}