{"name":"egg-jsonp","version":"1.2.1","description":"jsonp support for egg","eggPlugin":{"name":"jsonp","optionalDependencies":["security"]},"files":["app","lib","config"],"keywords":["egg","egg-plugin","jsonp","security"],"dependencies":{"is-type-of":"^1.2.0","jsonp-body":"^1.0.0"},"devDependencies":{"autod":"^2.9.0","egg":"^1.8.0","egg-bin":"^4.3.2","egg-ci":"^1.8.0","egg-mock":"^3.12.1","eslint":"^4.7.1","eslint-config-egg":"^5.1.1","supertest":"^3.0.0","webstorm-disable-index":"^1.2.0"},"engines":{"node":">=6.0.0"},"scripts":{"test":"npm run lint -- --fix && npm run test-local","test-local":"egg-bin test","cov":"egg-bin cov","lint":"eslint .","ci":"npm run lint && npm run cov","autod":"autod"},"ci":{"version":"6, 7, 8"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-jsonp.git"},"bugs":{"url":"https://github.com/eggjs/egg/issues"},"homepage":"https://github.com/eggjs/egg-jsonp#readme","author":{"name":"dead-horse"},"license":"MIT","boilerplate":{"name":"egg-boilerplate-plugin","version":"1.7.0","description":"boilerplate for egg plugin","repository":{"type":"git","url":"git@github.com:eggjs/egg-boilerplate-plugin.git"},"homepage":"https://github.com/eggjs/egg-boilerplate-plugin"},"gitHead":"dd2b2acb3a9c37685122156095e087a0a1af6825","_id":"egg-jsonp@1.2.1","_npmVersion":"5.4.2","_nodeVersion":"8.4.0","_npmUser":{"name":"dead_horse","email":"dead_horse@qq.com"},"dist":{"integrity":"sha512-7uSc06u0t+jihhHMki/GY1ftG52tNKG72x+VAIVwpeAxSe1qe4IizgWrkduDWEocSeu/whtHwlLwA/fZWEs9Ow==","shasum":"41827a91d8a4f333347fd40821acb5c5bc668fc0","tarball":"http://registry-npm.ywwl.com/egg-jsonp/download/egg-jsonp-1.2.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD2gobhvl1LMfgmUkfqgRq27KgyL2ltwXy/PAje7vw6jgIhAMqqMcnXFnCfaZ/eH/SxLJIk/yWI8IRIm3+ZMf+Ue1xj"}],"size":4490,"noattachment":false,"key":"/egg-jsonp/-/egg-jsonp-1.2.1.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"popomore","email":"sakura9515@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/egg-jsonp-1.2.1.tgz_1507695925256_0.8393333528656512"},"directories":{},"readme":"# egg-jsonp\n\n[![NPM version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![David deps][david-image]][david-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/egg-jsonp.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/egg-jsonp\n[travis-image]: https://img.shields.io/travis/eggjs/egg-jsonp.svg?style=flat-square\n[travis-url]: https://travis-ci.org/eggjs/egg-jsonp\n[codecov-image]: https://img.shields.io/codecov/c/github/eggjs/egg-jsonp.svg?style=flat-square\n[codecov-url]: https://codecov.io/github/eggjs/egg-jsonp?branch=master\n[david-image]: https://img.shields.io/david/eggjs/egg-jsonp.svg?style=flat-square\n[david-url]: https://david-dm.org/eggjs/egg-jsonp\n[snyk-image]: https://snyk.io/test/npm/egg-jsonp/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/egg-jsonp\n[download-image]: https://img.shields.io/npm/dm/egg-jsonp.svg?style=flat-square\n[download-url]: https://npmjs.org/package/egg-jsonp\n\nAn egg plugin for jsonp support.\n\n## Install\n\n```bash\n$ npm i egg-jsonp --save\n```\n\n## Usage\n\n```js\n// {app_root}/config/plugin.js\nexports.jsonp = {\n  enable: true,\n  package: 'egg-jsonp',\n};\n```\n\n## Configuration\n\n* {String|Array} callback - jsonp callback method key, default to `[ '_callback', 'callback' ]`\n* {Number} limit - callback method name's max length, default to `50`\n* {Boolean} csrf - enable csrf check or not. default to false\n* {String|RegExp|Array} whiteList - referrer white list\n\nif whiteList's type is `RegExp`, referrer must match `whiteList`, pay attention to the first `^` and last `/`.\n\n```js\nexports.jsonp = {\n  whiteList: /^https?:\\/\\/test.com\\//,\n}\n// matchs referrer:\n// https://test.com/hello\n// http://test.com/\n```\n\nif whiteList's type is `String` and starts with `.`:\n\n```js\nexports.jsonp = {\n  whiteList: '.test.com',\n};\n// matchs domain test.com:\n// https://test.com/hello\n// http://test.com/\n\n// matchs subdomain\n// https://sub.test.com/hello\n// http://sub.sub.test.com/\n```\n\nif whiteList's type is `String` and not starts with `.`:\n\n```js\nexports.jsonp = {\n  whiteList: 'sub.test.com',\n};\n// only matchs domain sub.test.com:\n// https://sub.test.com/hello\n// http://sub.test.com/\n```\n\nwhiteList also can be an array:\n\n```js\nexports.jsonp = {\n  whiteList: [ '.foo.com', '.bar.com' ],\n};\n```\n\nsee [config/config.default.js](https://github.com/eggjs/egg-jsonp/blob/master/config/config.default.js) for more detail.\n\n## API\n\n* ctx.acceptJSONP - detect if response should be jsonp, readonly\n\n## Example\n\nIn `app/router.js`\n\n```js\n// Create once and use in any router you want to support jsonp.\nconst jsonp = app.jsonp();\napp.get('/default', jsonp, 'jsonp.index');\napp.get('/another', jsonp, 'jsonp.another');\n\n// Customize by create another jsonp middleware with specific sonfigurations.\napp.get('/customize', app.jsonp({ callback: 'fn' }), 'jsonp.customize');\n```\n\n## Questions & Suggestions\n\nPlease open an issue [here](https://github.com/eggjs/egg/issues).\n\n## License\n\n[MIT](https://github.com/eggjs/egg-jsonp/blob/master/LICENSE)\n\n","publish_time":1507695925363,"_cnpm_publish_time":1507695925363,"dist-tags":{"latest":"2.0.0"}}