{"_id":"@acastellon/cors","_rev":"6-c61f19a027820ece3ab3d3fcb08e437b","name":"@acastellon/cors","dist-tags":{"latest":"1.2.0"},"versions":{"1.0.0":{"name":"@acastellon/cors","version":"1.0.0","keywords":["express","cors"],"author":{"name":"Antonio Castellon"},"license":"MIT","_id":"@acastellon/cors@1.0.0","maintainers":[{"name":"acastellon","email":"antonio@castellon.ch"}],"homepage":"https://github.com/antonio-castellon/cors#readme","bugs":{"url":"https://github.com/antonio-castellon/cors/issues"},"dist":{"shasum":"6fc833c4da51876ef9106229f76587727e9e458b","tarball":"https://registry.npmjs.org/@acastellon/cors/-/cors-1.0.0.tgz","fileCount":4,"integrity":"sha512-TIJAmYR6Sj2LRkUXDNj4rLsa9CwyUQcIJNpEFFXFynAAFQLPrKXPF40XgOBxB6SQxIg6tPmdW7+maLUW4qhw2A==","signatures":[{"sig":"MEQCIHj0y1lDukMlla0ZN+qOhsv80adrsTF+zcR0vCIBSzRNAiBw8Q5jMdZdbmqMF0kR76Lv2eUQ911cF7hIVeUQvmjYqw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3895,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdkz4YCRA9TVsSAnZWagAANxEP+gPUVE4KYBXrfMoZwFZs\nj4gWJ0wYo0tKh9+kOdQCSZ2UVvgRishItkctK4Rw0Jse7lnyAEgRClCx0uDR\nCEgq+Wgx/x/FmyMuHWdUz19pOk9Uo/LQs26PKFMuBb4MQNg2u/MBPxL/nw9M\nUG/8S69v+to5A3ALz5FR1xMCisFKEE2lbj5SbMEzGhdMYP5+4enTRJ1blEee\n1H7Ctgl2bAsHH03kZdw5dh16YY829xt+m/ZD/3l6ifdmy9UfjYQO1lzJ9dJe\n0wHwCPDrPLD533zobXFnFF3aVuP2aspAzy0M1Fe87zg0sInUN8yEQbWaOjdj\n7Vj4IQVtRxuZvV96xkEVP/0FsKzQkZpbTFyMX4aVrJa26InOOSOEj1LpfcTW\n5nTtA4y/SRC26XG81kWqcQIqy4dVrLhWVq/VLrHemxdFZw3YlaP/L94pfIsD\ny267FsZMakDhV0OsyMHyq5qSQdwo5Vfeo2TOPVQmTKdqt3OYqquudfHtqII1\nJ12wZ9ANA5i3hVj8suYfIdGUHjeHxK8n+LKpNCmTDYSPOYktgDSvxRNvDBpG\nOGNJucc9joUOlqCf24CFPllv7E+res/w3QYN+L5Eokn/83c2ls+JmEpluobg\nm9hnaBxN0rMAfVNTLbKp+fWjidx2uwnnr3+w4ePrXDzZsS28sWJtD3QJ13Rr\nfd7B\r\n=qH5I\r\n-----END PGP SIGNATURE-----\r\n"},"main":"cors.js","gitHead":"26dac317339f767396fc44745ea7eb585ee54f6a","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"acastellon","email":"antonio@castellon.ch"},"repository":{"url":"git+https://github.com/antonio-castellon/cors.git","type":"git"},"_npmVersion":"6.4.1","description":"CORS filter for Node Express Application","directories":{},"_nodeVersion":"10.15.0","dependencies":{"cors":"^2.8.4"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/cors_1.0.0_1569930776273_0.5384163362007475","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@acastellon/cors","version":"1.0.1","keywords":["express","cors"],"author":{"name":"Antonio Castellon"},"license":"MIT","_id":"@acastellon/cors@1.0.1","maintainers":[{"name":"acastellon","email":"antonio@castellon.ch"}],"homepage":"https://github.com/antonio-castellon/module-cors#readme","bugs":{"url":"https://github.com/antonio-castellon/module-cors/issues"},"dist":{"shasum":"059406393741ad9bab21a6961f695c8039862e6c","tarball":"https://registry.npmjs.org/@acastellon/cors/-/cors-1.0.1.tgz","fileCount":4,"integrity":"sha512-4DWNC1/RVkUiu3qEanXrzoUeBYwWmww8YkfZhyWhuuS+psXtyZNAWfEtc+Zpr8CMVXgYg8fryQPwpIlGRlfoOA==","signatures":[{"sig":"MEUCIA4LD71kR7adiZ+Q8ALOCQKfCdlJsQTAvCxzwsB6He/BAiEAinytgYzcCpJkdd3fhSwFKK2oPkoS9tlYe5iJ7VRNTS4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3916,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdrum9CRA9TVsSAnZWagAAszAP/jsdKuBDSSTR5/9P4Wv/\n0aCiAypKD5BYYiLCJfJ1NQrpnep9vCtCG0In0geXaQUK9jRZr9lt7jUdG0oO\nR9P+Od632f8mTYvnNw0fg5RKZs5S0gkSQxfX5tcGw//5mlEJC8EAW1GtT3Gy\nJ5E3JIMo4mLNcEZpdZM5fuf/Aubsf7YVDw0KZPmQzgfzd0181AQrgcTVKR0q\nTkfkhxRewe3sZ6pf8R+lR7WVTowvkmpnLePx+njEpalIslRr/ry8OJYTJzvm\nWHd5gui+MYz7zNhQutmbwforCYCqC76A2d1lLdhG3s+QtAbCpenWHCElMZq2\nNq2hb3HXh/9RAKKsXU35MxWiC0xxyIFlcz38bCwPn35XJq0Bi68lsxTi/ySz\nS9AUH1Gn+KtUZxkOimtiIrEAM+DyK9TeTxWCXawv55PVJzDaJ45QRU23YK3W\nSjtdOehhMELUXn4533+0gdL8CN2K19MEa2Zi2DF6dgJwKsPSeXmIzu6aYtfj\nzwza8D0YtTGl6s1ur54JHvso332ZfJonzXEAjmvOfG1+lvjqRNzBzPa4BlQ/\nZ6V8LM6kXcINcogd7G3PDrW4S3+n2aNNMhpwrxiCO5yKbmYsqq5L7JWzqqXD\nY0zU0XLOuwzRv2AfmmntGISDSPlUay2b+ghtF1j2MJq1nqxo25nbP+jsBwL9\nO7vj\r\n=6zWs\r\n-----END PGP SIGNATURE-----\r\n"},"main":"cors.js","gitHead":"26dac317339f767396fc44745ea7eb585ee54f6a","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"acastellon","email":"antonio@castellon.ch"},"repository":{"url":"git+https://github.com/antonio-castellon/module-cors.git","type":"git"},"_npmVersion":"6.4.1","description":"CORS filter for Node Express Application","directories":{},"_nodeVersion":"10.15.0","dependencies":{"cors":"^2.8.4"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/cors_1.0.1_1571744189251_0.16405793280553183","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"@acastellon/cors","version":"1.0.2","keywords":["express","cors"],"author":{"name":"Antonio Castellon"},"license":"MIT","_id":"@acastellon/cors@1.0.2","maintainers":[{"name":"acastellon","email":"antonio@castellon.ch"}],"homepage":"https://github.com/antonio-castellon/module-cors#readme","bugs":{"url":"https://github.com/antonio-castellon/module-cors/issues"},"dist":{"shasum":"433839eb9bc002b080bae2403e9ba8fd853c0b50","tarball":"https://registry.npmjs.org/@acastellon/cors/-/cors-1.0.2.tgz","fileCount":4,"integrity":"sha512-PL867PjsivqErbjs+yFCR35wusrldjIvJWYq/CgFbU8jvcTpQMmhePkT+CqU87gpJhLP/nXGX8e+9II1lmifRw==","signatures":[{"sig":"MEUCIBVNHIBDVBrLcsz9T6etuAkQJOPlq6TJyUTnfmAd5uLTAiEAg+xKh5poUilO/sIx82RfrjUZEh5Glvngi2qa/m1aChs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4171,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdxUOHCRA9TVsSAnZWagAAdlEP/RS8jqohPIF+dZAOEJsJ\nv292IaZHXWtdPfoPqxmRNjjW6Kg0jz9xSy5KwHdPae5twoxuE0CFTE13XWUT\nB+/WcH+YUSFtWZYv2WPppcHVhCftzEzCb9Fva9YoklANkLen0la++tEsBq8C\nZ+a6MR6TryPtq+XBDLf2L3j6DQijNnxFoJgz35hL/1qLuWPDUakwNV2PCs5l\n/sQBcolUPXUqOeftzfSGz6FOOt4Wzk6OfqUfbYlD8Id2Kq1KG7j+kmYtnJXw\npeJxAHRx55ui9kKKUfxmq9q2A4X3Iw63WDI3PJggrS3CYQnRud0hGmOVvGGL\nsvbjMy/6UN1GpqLR2nK7xJHPDKiZPVZJD/vvyCPDTfZJ5yAZjzJmK/PTBz0o\nBpli9xPF1FfzUcWUaRStL+f8jzRpc4XVzhjKVDRS+8R+pPtbrovnRVJDrsKq\n/Kj7aimZxicXJfvdlE0wDF/VSXEr++Ho0H2wNY1eyamBLrNjowkK6KT73L7y\nJeClN+16qVcF2rrSZiK26PS0qdIE8F3VEOkzhMVOWFKeQlbG09mDx6o1EgK1\nW67BawOKHSFDxWmawjonh/CxIa35ha6WqGoHLVeJe56yH4J+wF02Yzx4r1Is\n99NBDxY4vB9k+VDVJuXft87xdyGqWuRKEvSCfVj1n/nv5/BQD0gVwp0KWSGC\nz7Dp\r\n=83eB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"cors.js","gitHead":"c26cccab8a522ede822b38e5008a4ac7f6a734a6","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"acastellon","email":"antonio@castellon.ch"},"repository":{"url":"git+https://github.com/antonio-castellon/module-cors.git","type":"git"},"_npmVersion":"6.4.1","description":"CORS filter for Node Express Application","directories":{},"_nodeVersion":"10.15.0","dependencies":{"cors":"^2.8.4"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/cors_1.0.2_1573208966623_0.4944787088180451","host":"s3://npm-registry-packages"}},"1.0.3":{"name":"@acastellon/cors","version":"1.0.3","keywords":["express","cors"],"author":{"name":"Antonio Castellon"},"license":"MIT","_id":"@acastellon/cors@1.0.3","maintainers":[{"name":"acastellon","email":"antonio@castellon.ch"}],"homepage":"https://github.com/antonio-castellon/module-cors#readme","bugs":{"url":"https://github.com/antonio-castellon/module-cors/issues"},"dist":{"shasum":"f8ab92ab1cace7c180b3eda65173b52c2c9eaa20","tarball":"https://registry.npmjs.org/@acastellon/cors/-/cors-1.0.3.tgz","fileCount":4,"integrity":"sha512-V4BVsXHpXO0m/b3UaWCsAvqbtUuw2aegz+5JJgmA/Ka62fFOUvF2RMNduebhW35L8Chk+2Jox/7s/hrtKk3S5g==","signatures":[{"sig":"MEUCIQD0ZZ3tliTgn0pL57iKrYCJMgVBbI9mkW7SaO23g9/oiwIgFiUauXIG7poU2qaz2GBburBwnm848uUDmhCP2kR+Hsg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4165,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeHYqmCRA9TVsSAnZWagAAhEMQAIsBEIIveHeYoUjOwNqU\nRXG07KB1FkTTE1A91LvTC7EhwLPf1+2TQz4jSZ/YRrh3ZTb8IzSyQ3dJbfDB\nczSLK00voRCb9RNOCqoGOb5migJsjtiU7JiMXnUz23SvjLwmbxBKnxM4naQt\n5FR1l4qGj8NkCe6nRZa7wkkY9c9+cKW4EG2sQ3olhB0yQIAmEQTYIY+R18j0\nr//P/IKXPvT+wehx5OAqtD+1/7Il07bvmzfscKxplMclShWnRHFw+52pVHt6\ngvtfpZWHOCigdt5IbnCIB/muHnzj/sGnoo4XIXEf/dAAjibPsvS/GDDGIsuz\nxKWGKHrUQXAxAN27VQcurat/hyscuHWSFQYGMJcHBZSe4Ly3ryvSZ636n3z8\ngp4lc0IM3fJE/RUxNB8a501PxjRNm4/uUD+4BkvrikXHWfpqdvl7UszR7qME\nGWG8sTQRGdFeDxgV7S+jcw0JlSU/1Z4Vi01NjtMmvO4nwJ8wGb0eo+IHm/uZ\nMhrrM7XgYAM36gAfURGQN2MH4nCie0THfnn3n90wK1T/3PdwRyCIAaHd+pSu\ny0MzYHK72KmKwy2EqaksGI8r4zQAJQxu8tW+Bll2MrpTb3VuApl6vFXLPkEK\n+deOSOMljPfu3Am+SyKcnrkoPezYV2XrZ/azxJmu/pqeRbCV1wiqm7jpSEUj\nE1xx\r\n=hKKp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"cors.js","gitHead":"03c45dc0df71265ffaf3ba02f945586b29cc5a1b","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"acastellon","email":"antonio@castellon.ch"},"repository":{"url":"git+https://github.com/antonio-castellon/module-cors.git","type":"git"},"_npmVersion":"6.12.1","description":"CORS filter for Node Express Application","directories":{},"_nodeVersion":"12.13.1","dependencies":{"cors":"^2.8.5"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/cors_1.0.3_1578994342433_0.9651060089220054","host":"s3://npm-registry-packages"}},"1.2.0":{"name":"@acastellon/cors","version":"1.2.0","description":"CORS filter for Node Express Application","main":"cors.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/antonio-castellon/module-cors.git"},"keywords":["express","cors"],"author":{"name":"Antonio Castellon"},"license":"MIT","bugs":{"url":"https://github.com/antonio-castellon/module-cors/issues"},"homepage":"https://github.com/antonio-castellon/module-cors#readme","engines":{"node":">=18.0.0"},"dependencies":{"cors":"^2.8.5"},"_id":"@acastellon/cors@1.2.0","gitHead":"68a8d39cf3127d071987990a88e6b1c87dc8a1ad","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-4FzdQamI8WJVH4JJpXadCY5veoeOE3xZDqPpBBARZAsZ6CWEcIV7X2+jYGlkWQkLPJsLCm7Xgb9e4BHv8Q/+xQ==","shasum":"9f8086aa06395e8a32db65a464279d3fa93c8c7e","tarball":"https://registry.npmjs.org/@acastellon/cors/-/cors-1.2.0.tgz","fileCount":4,"unpackedSize":5451,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIFYjc6GqWhZKyzH30xmF/BeAKsyFlYYispRXMN98fxhrAiAiiBimJDB4y8eA0DR5cPry/nvg8IbhOGQ1ps6LyvDD/A=="}]},"_npmUser":{"name":"acastellon","email":"antonio@castellon.ch"},"directories":{},"maintainers":[{"name":"acastellon","email":"antonio@castellon.ch"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cors_1.2.0_1780483653868_0.5372442938523505"},"_hasShrinkwrap":false}},"time":{"created":"2019-10-01T11:52:56.038Z","modified":"2026-06-03T10:47:34.181Z","1.0.0":"2019-10-01T11:52:56.387Z","1.0.1":"2019-10-22T11:36:29.352Z","1.0.2":"2019-11-08T10:29:26.756Z","1.0.3":"2020-01-14T09:32:22.550Z","1.2.0":"2026-06-03T10:47:34.046Z"},"bugs":{"url":"https://github.com/antonio-castellon/module-cors/issues"},"author":{"name":"Antonio Castellon"},"license":"MIT","homepage":"https://github.com/antonio-castellon/module-cors#readme","keywords":["express","cors"],"repository":{"type":"git","url":"git+https://github.com/antonio-castellon/module-cors.git"},"description":"CORS filter for Node Express Application","maintainers":[{"name":"acastellon","email":"antonio@castellon.ch"}],"readme":"# @acastellon/cors\r\n\r\nCORS filter for Node Express Application.\r\n\r\n## Install\r\n\r\n```bash\r\nnpm install @acastellon/cors\r\n```\r\n\r\n## Usage\r\n\r\n```js\r\nconst corsMod = require('@acastellon/cors')('./whitelist');\r\ncorsMod.enableCORS(app);\r\n```\r\n\r\nThe whitelist file should contain one allowed origin per line (e.g. https://example.com). Origin check allows undefined (server-side) and matches exact.\r\n\r\n**Note:** Whitelist is read synchronously at module load time.\r\n\r\n## API\r\n\r\n### enableCORS(app: ExpressApplication): void\r\n\r\nApplies two middlewares:\r\n1. Custom header setter (expose, allow headers for auth/cors, methods, credentials).\r\n2. `cors()` from the 'cors' package, configured with origin whitelist check + credentials.\r\n\r\n- **Parameters**: `app` - An express app (will call app.use twice).\r\n- **Side effects**: Mutates the app by adding middleware. Reads whitelist file at construction time.\r\n- **Errors**: Will call next(err) with 'Not allowed by CORS' for disallowed origins.\r\n\r\n**Minimal example (self-contained):**\r\n\r\n```js\r\nconst express = require('express');\r\nconst corsMod = require('@acastellon/cors');\r\nconst fs = require('fs');\r\nconst path = require('path');\r\n\r\n// Minimal whitelist file for demo\r\nconst wl = path.join(__dirname, 'whitelist.txt');\r\nfs.writeFileSync(wl, 'https://example.com\\nhttps://127.0.0.1\\n');\r\n\r\nconst app = express();\r\nconst cors = corsMod(wl);\r\n\r\ncors.enableCORS(app);\r\n\r\napp.get('/api/test', (req, res) => res.json({ ok: true }));\r\n\r\napp.listen(3000, () => console.log('Server with CORS started'));\r\n```\r\n\r\n## License\r\n\r\nMIT\r\n","readmeFilename":"README.md"}