{"name":"jsonp-body","version":"2.0.0","description":"Helper to create more safe jsonp response body for koa and other web framework","homepage":"https://github.com/node-modules/jsonp-body","repository":{"type":"git","url":"git://github.com/node-modules/jsonp-body.git"},"bugs":{"url":"https://github.com/node-modules/jsonp-body/issues"},"keywords":["jsonp","koa","json","CVE-2014-4671","abusing-jsonp-with-rosetta-flash"],"author":{"name":"fengmk2","email":"fengmk2@gmail.com","url":"https://github.com/fengmk2"},"license":"MIT","engines":{"node":">= 18.19.0"},"dependencies":{},"devDependencies":{"@arethetypeswrong/cli":"^0.17.1","@eggjs/tsconfig":"1","@types/node":"22","@types/mocha":"10","@eggjs/bin":"7","eslint":"8","eslint-config-egg":"14","rimraf":"6","tshy":"3","tshy-after":"1","typescript":"5"},"scripts":{"lint":"eslint --cache src test --ext .ts","pretest":"npm run clean && npm run lint -- --fix","test":"egg-bin test","preci":"npm run clean &&  npm run lint","ci":"egg-bin cov","postci":"npm run prepublishOnly && npm run clean","clean":"rimraf dist","prepublishOnly":"tshy && tshy-after && attw --pack"},"type":"module","tshy":{"exports":{".":"./src/index.ts","./package.json":"./package.json"}},"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"},"types":"./dist/commonjs/index.d.ts","main":"./dist/commonjs/index.js","module":"./dist/esm/index.js","_id":"jsonp-body@2.0.0","gitHead":"7f7fb55a0c9d02c17aa8ee44bfeaccc092b41e1a","_nodeVersion":"18.20.5","_npmVersion":"10.8.2","dist":{"integrity":"sha512-9VZNeFvIO6gjtYiob3KW3HzxMgq8UEO0xUaUaQ1e8eAeOVlCAs49CtrdMXLma8y3GC/lsyfnzZDTrBWkdGxi2g==","shasum":"ea504901e450157d4e00d01fa12a5257694a176a","tarball":"http://registry-npm.ywwl.com/jsonp-body/download/jsonp-body-2.0.0.tgz","fileCount":11,"unpackedSize":13484,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/jsonp-body@2.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCgVpj8OREM0mkx5mxb19FRQ5XQmHp1bdiR/VzjwMHfjQIhAPWHpJvs6vjE87TSU1mg19JgzcUr3vh4yWhVtJFGVOcj"}],"size":4569,"noattachment":false,"key":"/jsonp-body/-/jsonp-body-2.0.0.tgz"},"_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"directories":{},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/jsonp-body_2.0.0_1736586605842_0.7826538614479888"},"_hasShrinkwrap":false,"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":1736586606048,"_cnpm_publish_time":1736586606048,"dist-tags":{"latest":"2.0.0"}}