{"name":"jsonp-body","version":"1.1.0","keywords":["jsonp","koa","json","CVE-2014-4671","abusing-jsonp-with-rosetta-flash"],"author":{"url":"https://github.com/fengmk2","name":"fengmk2","email":"fengmk2@gmail.com"},"license":"MIT","_id":"jsonp-body@1.1.0","maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"contributors":[{"url":"https://github.com/fengmk2","name":"fengmk2","email":"fengmk2@gmail.com"},{"url":"https://github.com/dead-horse","name":"dead-horse","email":"heyiyu.deadhorse@gmail.com"}],"homepage":"https://github.com/node-modules/jsonp-body","bugs":{"url":"https://github.com/node-modules/jsonp-body/issues","email":"fengmk2@gmail.com"},"dist":{"shasum":"f01f185c79b0976e20c09f474bf74976fd5a302c","tarball":"http://registry-npm.ywwl.com/jsonp-body/download/jsonp-body-1.1.0.tgz","fileCount":7,"integrity":"sha512-ZQyNWgHI8vvqclzz0l4/PatmeGureejrdMiLQGxTupMw0yQMHf+pQwS/7d5tpo2NBHsuwLCmXvZeNiz2RKdklA==","signatures":[{"sig":"MEUCIAYUQzjHeO+CfY50lZL8LVZkDgOTPuNE3Jj42dSY7WgFAiEA958E7iTHDHa3utD7iNWP/slPwqf+fOQSafmeEwrrvWE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6572,"size":3058,"noattachment":false,"key":"/jsonp-body/-/jsonp-body-1.1.0.tgz"},"main":"index.js","types":"index.d.ts","engines":{"node":">= 0.10.0"},"gitHead":"64616a934068c5d853d169e1b79a7ccf84d00694","scripts":{"test":"mocha test/*.test.js","test-cov":"istanbul cover _mocha -- test/*.test.js"},"_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"repository":{"url":"git://github.com/node-modules/jsonp-body.git","web":"https://github.com/node-modules/jsonp-body","type":"git"},"_npmVersion":"10.9.0","description":"Helper to create more safe jsonp response body for koa and other web framework.","directories":{},"_nodeVersion":"22.11.0","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"autod":"*","mocha":"*","jshint":"*","should":"7","istanbul":"*","contributors":"*"},"_npmOperationalInternal":{"tmp":"tmp/jsonp-body_1.1.0_1736584451751_0.6872550938582851","host":"s3://npm-registry-packages-npm-production"},"readme":"# jsonp-body\n\n[![NPM version][npm-image]][npm-url]\n[![Node.js CI](https://github.com/node-modules/jsonp-body/actions/workflows/nodejs.yml/badge.svg)](https://github.com/node-modules/jsonp-body/actions/workflows/nodejs.yml)\n[![Test coverage][codecov-image]][codecov-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/jsonp-body.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/jsonp-body.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/jsonp-body\n[codecov-image]: https://img.shields.io/codecov/c/github/node-modules/jsonp-body.svg?style=flat-square\n[codecov-url]: https://codecov.io/github/node-modules/jsonp-body?branch=master\n[snyk-image]: https://snyk.io/test/npm/jsonp-body/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/jsonp-body\n[download-image]: https://img.shields.io/npm/dm/jsonp-body.svg?style=flat-square\n[download-url]: https://npmjs.org/package/jsonp-body\n\nHelper to create more safe jsonp response body for [koa](http://koajs.com/) and other web framework.\n\n## Install\n\n```bash\nnpm install jsonp-body --save\n```\n\n## Usage\n\n```js\nconst koa = require('koa');\nconst { jsonp } = require('jsonp-body');\n\nvar app = koa();\napp.use(async function () {\n  this.set('X-Content-Type-Options', 'nosniff');\n  if (this.query.callback) {\n    this.set('Content-Type', 'text/javascript');\n  } else {\n    this.set('Content-Type', 'application/json');\n  }\n  this.body = jsonp({foo: 'bar'}, this.query.callback);\n});\n```\n\n## API Reference\n\n### `jsonp(obj, callback, options)`\n\nGet `obj` jsonp string response with `callback`.\n\n- __obj__: object convert to JSON string\n- __callback__: callback function name\n- __options__: optional for `JSON.stringify`\n  - __limit__: length limit for `callback`, default to `512`\n  - __replacer__: replacer in `JSON.stringify(obj, [replacer, [space]])`\n  - __space__: space in `JSON.stringify(obj, [replacer, [space]])`\n\n## License\n\n[MIT](LICENSE)\n\n## Contributors\n\n[![Contributors](https://contrib.rocks/image?repo=node-modules/jsonp-body)](https://github.com/node-modules/jsonp-body/graphs/contributors)\n\nMade with [contributors-img](https://contrib.rocks).\n","publish_time":1736584451939,"_cnpm_publish_time":1736584451939,"dist-tags":{"latest":"2.0.0"}}