{"id":13487479,"url":"https://github.com/eggjs/jsonp","last_synced_at":"2025-10-14T14:17:32.988Z","repository":{"id":57220550,"uuid":"79703486","full_name":"eggjs/jsonp","owner":"eggjs","description":"jsonp support for egg, with security check inside","archived":false,"fork":false,"pushed_at":"2025-01-11T10:42:49.000Z","size":36,"stargazers_count":17,"open_issues_count":0,"forks_count":1,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-09-29T01:07:44.695Z","etag":null,"topics":["egg-plugin","jsonp"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eggjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-01-22T08:04:08.000Z","updated_at":"2025-07-16T23:26:54.000Z","dependencies_parsed_at":"2025-01-11T10:33:54.725Z","dependency_job_id":"1d4a7984-5497-4334-94b0-a50799c80a4d","html_url":"https://github.com/eggjs/jsonp","commit_stats":null,"previous_names":["eggjs/jsonp"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/eggjs/jsonp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fjsonp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fjsonp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fjsonp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fjsonp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eggjs","download_url":"https://codeload.github.com/eggjs/jsonp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fjsonp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278464277,"owners_count":25991178,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["egg-plugin","jsonp"],"created_at":"2024-07-31T18:00:59.872Z","updated_at":"2025-10-14T14:17:32.954Z","avatar_url":"https://github.com/eggjs.png","language":"TypeScript","readme":"# @eggjs/jsonp\n\n[![NPM version][npm-image]][npm-url]\n[![Node.js CI](https://github.com/eggjs/jsonp/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/jsonp/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/@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[codecov-image]: https://img.shields.io/codecov/c/github/eggjs/jsonp.svg?style=flat-square\n[codecov-url]: https://codecov.io/github/eggjs/jsonp?branch=master\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## Requirements\n\n- egg \u003e= 4.x\n\n## Install\n\n```bash\nnpm i @eggjs/jsonp\n```\n\n## Usage\n\n```ts\n// {app_root}/config/plugin.ts\n\nexport default {\n  jsonp: {\n    enable: true,\n    package: '@eggjs/jsonp',\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/jsonp/blob/master/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\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## Questions \u0026 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/jsonp)](https://github.com/eggjs/jsonp/graphs/contributors)\n\nMade with [contributors-img](https://contrib.rocks).\n","funding_links":[],"categories":["仓库"],"sub_categories":["[内置插件](https://eggjs.org/zh-cn/basics/plugin.html#%E6%8F%92%E4%BB%B6%E5%88%97%E8%A1%A8)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feggjs%2Fjsonp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feggjs%2Fjsonp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feggjs%2Fjsonp/lists"}