{"name":"@eggjs/jsonp","version":"4.0.0-beta.24","keywords":["egg","egg-plugin","jsonp","security"],"author":{"name":"dead-horse"},"license":"MIT","_id":"@eggjs/jsonp@4.0.0-beta.24","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":"hyj1991","email":"yeekwanvong@gmail.com"},{"name":"killagu","email":"killa07071201@gmail.com"},{"name":"coolme200","email":"2001-wms@163.com"},{"name":"akitasummer","email":"akitasummer@outlook.com"}],"homepage":"https://github.com/eggjs/egg/tree/next/plugins/jsonp","bugs":{"url":"https://github.com/eggjs/egg/issues"},"dist":{"shasum":"bb27116a067285a86b4a11300b1437e6e4219ff9","tarball":"http://registry-npm.ywwl.com/@eggjs/jsonp/download/@eggjs/jsonp-4.0.0-beta.24.tgz","fileCount":17,"integrity":"sha512-kYoKqWbAuBqdsWvuOKBKEiCuEVQhzYStI4ChBTS5SGqpw0hWRiG/UT+FG0eKXqmYVBbJNUq5nf6NBdWQ+2Hg0w==","signatures":[{"sig":"MEUCIQDj8TbXTvwqKV+YXioflR+Hy3c2raUI8+xMIw+p4sZM0QIgPmg2WDbiiqU2/8K38L9ouzdFcbQcO9bZt7brZyMlMXo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@eggjs%2fjsonp@4.0.0-beta.24","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":21838,"size":7610,"noattachment":false,"key":"/@eggjs/jsonp/-/@eggjs/jsonp-4.0.0-beta.24.tgz"},"main":"./dist/index.js","type":"module","_from":"file:eggjs-jsonp-4.0.0-beta.24.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=22.18.0"},"exports":{".":"./dist/index.js","./types":"./dist/types.js","./package.json":"./package.json","./lib/private_key":"./dist/lib/private_key.js","./app/extend/context":"./dist/app/extend/context.js","./config/config.default":"./dist/config/config.default.js","./app/extend/application":"./dist/app/extend/application.js","./error/JSONPForbiddenReferrerError":"./dist/error/JSONPForbiddenReferrerError.js"},"scripts":{"lint":"oxlint --type-aware","test":"npm run lint:fix && vitest run","build":"tsdown && rimraf dist *.tsbuildinfo && tsc -p tsconfig.build.json","lint:fix":"npm run lint -- --fix","typecheck":"tsc --noEmit"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:643b3cc3-6086-4ac3-90fa-77f2a7523cbe"}},"_resolved":"/tmp/c70901f2ccf876486d130883243fda0d/eggjs-jsonp-4.0.0-beta.24.tgz","eggPlugin":{"name":"jsonp","optionalDependencies":["security"]},"_integrity":"sha512-kYoKqWbAuBqdsWvuOKBKEiCuEVQhzYStI4ChBTS5SGqpw0hWRiG/UT+FG0eKXqmYVBbJNUq5nf6NBdWQ+2Hg0w==","repository":{"url":"git://github.com/eggjs/egg.git","type":"git","directory":"plugins/jsonp"},"_npmVersion":"11.6.1","description":"jsonp support for egg","directories":{},"_nodeVersion":"22.20.0","dependencies":{"jsonp-body":"^2.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsdown":"^0.15.4","vitest":"4.0.0-beta.16","typescript":"^5.9.3","@eggjs/mock":"7.0.0-beta.24","@types/node":"^24.6.2","@eggjs/tsconfig":"3.1.0-beta.24"},"peerDependencies":{"egg":"4.1.0-beta.24"},"_npmOperationalInternal":{"tmp":"tmp/jsonp_4.0.0-beta.24_1759653702311_0.47404452755042215","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":1759653702535,"_cnpm_publish_time":1759653702535,"dist-tags":{"beta":"4.0.2-beta.27","latest":"4.1.0","rc":"4.0.2-rc.1"}}