{"name":"@eggjs/jsonp","version":"3.0.0","keywords":["egg","egg-plugin","jsonp","security"],"author":{"name":"dead-horse"},"license":"MIT","_id":"@eggjs/jsonp@3.0.0","maintainers":[{"name":"gxkl","email":"gxkl203@gmail.com"},{"name":"eggjs-admin","email":"fengmk2+eggjs@gmail.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"atian25","email":"atian25@qq.com"},{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"wanghx","email":"whxaxes@gmail.com"},{"name":"hyj1991","email":"yeekwanvong@gmail.com"},{"name":"killagu","email":"killa07071201@gmail.com"},{"name":"coolme200","email":"2001-wms@163.com"},{"name":"mansonchor.zzw","email":"mansonchor1987@gmail.com"},{"name":"hubcarl","email":"hubcarl@126.com"},{"name":"gemwuu","email":"gemwuu@gmail.com"},{"name":"akitasummer","email":"644171127@qq.com"}],"homepage":"https://github.com/eggjs/jsonp#readme","bugs":{"url":"https://github.com/eggjs/egg/issues"},"dist":{"shasum":"085e2dbd5c44b178293a495d109215af93dcccba","tarball":"http://registry-npm.ywwl.com/@eggjs/jsonp/download/@eggjs/jsonp-3.0.0.tgz","fileCount":42,"integrity":"sha512-cYq+4LI5JtvZHSoyXSKJhSLswPwFOiE4XeCjP5rqszUnFZEnSVldWlcUemtCy54iel5LdcpC+H95SmrLt4MNkw==","signatures":[{"sig":"MEQCIERdHcC3SxsxcpzZUWVYi/1ao9fB88eg04ynjTDo/b/8AiBx7dLIx560iin79ARR1mixR5JJg7U5qXgq1R17Tts7eA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@eggjs%2fjsonp@3.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":45779,"size":11734,"noattachment":false,"key":"/@eggjs/jsonp/-/@eggjs/jsonp-3.0.0.tgz"},"main":"./dist/commonjs/index.js","tshy":{"exports":{".":"./src/index.ts","./package.json":"./package.json"}},"type":"module","types":"./dist/commonjs/index.d.ts","module":"./dist/esm/index.js","engines":{"node":">= 18.19.0"},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./package.json":"./package.json"},"gitHead":"d7b7c5b45c3ec61743c9304a7d68493546934d21","scripts":{"ci":"egg-bin cov","lint":"eslint --cache src test --ext .ts","test":"egg-bin test","clean":"rimraf dist","preci":"npm run clean &&  npm run lint","postci":"npm run prepublishOnly && npm run clean","pretest":"npm run clean && npm run lint -- --fix","prepublishOnly":"tshy && tshy-after && attw --pack"},"_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"eggPlugin":{"name":"jsonp","exports":{"import":"./dist/esm","require":"./dist/commonjs","typescript":"./src"},"optionalDependencies":["security"]},"repository":{"url":"git+https://github.com/eggjs/jsonp.git","type":"git"},"_npmVersion":"10.8.2","description":"jsonp support for egg","directories":{},"_nodeVersion":"20.18.1","dependencies":{"jsonp-body":"^2.0.0","@eggjs/core":"^6.2.13"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"egg":"4","tshy":"3","eslint":"8","rimraf":"6","@eggjs/bin":"7","tshy-after":"1","typescript":"5","@eggjs/mock":"6","@types/node":"22","@types/mocha":"10","@eggjs/tsconfig":"1","eslint-config-egg":"14","@arethetypeswrong/cli":"^0.17.1"},"_npmOperationalInternal":{"tmp":"tmp/jsonp_3.0.0_1736592081445_0.2118146706877706","host":"s3://npm-registry-packages-npm-production"},"readme":"# @eggjs/jsonp\n\n[![NPM version][npm-image]][npm-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n[![Node.js Version](https://img.shields.io/node/v/@eggjs/jsonp.svg?style=flat)](https://nodejs.org/en/download/)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)\n\n[npm-image]: https://img.shields.io/npm/v/@eggjs/jsonp.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/@eggjs/jsonp\n[snyk-image]: https://snyk.io/test/npm/@eggjs/jsonp/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/@eggjs/jsonp\n[download-image]: https://img.shields.io/npm/dm/@eggjs/jsonp.svg?style=flat-square\n[download-url]: https://npmjs.org/package/@eggjs/jsonp\n\nAn egg plugin for jsonp support.\n\n## Usage\n\negg built-in plugin `jsonp` is enabled by default.\n\n```ts\n// {app_root}/config/plugin.ts\n\nexport default {\n  jsonp: {\n    enable: true,\n  },\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```ts\nexport default {\n  jsonp: {\n    whiteList: /^https?:\\/\\/test.com\\//,\n  },\n};\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```ts\nexport default {\n  jsonp: {\n    whiteList: '.test.com',\n  },\n};\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```ts\nexport default {\n  jsonp: {\n    whiteList: 'sub.test.com',\n  },\n};\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```ts\nexport default {\n  jsonp: {\n    whiteList: ['.foo.com', '.bar.com'],\n  },\n};\n```\n\nsee [config/config.default.ts](https://github.com/eggjs/egg/blob/master/plugins/jsonp/src/config/config.default.ts) for more detail.\n\n## API\n\n- ctx.acceptJSONP - detect if response should be jsonp, readonly\n\n## Example\n\n### Standard Application Usage\n\nIn `app/router.ts`\n\n```ts\n// Create once and use in any router you want to support jsonp.\nconst jsonp = app.jsonp();\n\napp.get('/default', jsonp, 'jsonp.index');\napp.get('/another', jsonp, 'jsonp.another');\n\n// Customize by create another jsonp middleware with specific configurations.\napp.get('/customize', app.jsonp({ callback: 'fn' }), 'jsonp.customize');\n```\n\n### tegg HttpController Usage\n\nTODO: TBD\n\n## Questions & Suggestions\n\nPlease open an issue [here](https://github.com/eggjs/egg/issues).\n\n## License\n\n[MIT](LICENSE)\n\n## Contributors\n\n[![Contributors](https://contrib.rocks/image?repo=eggjs/egg)](https://github.com/eggjs/egg/graphs/contributors)\n\nMade with [contributors-img](https://contrib.rocks).\n","publish_time":1736592081633,"_cnpm_publish_time":1736592081633,"dist-tags":{"beta":"4.0.2-beta.27","latest":"4.1.0","rc":"4.0.2-rc.1"}}