{"id":18351312,"url":"https://github.com/rojer95/click-captcha-server","last_synced_at":"2025-04-13T14:53:37.646Z","repository":{"id":143809709,"uuid":"530191351","full_name":"rojer95/click-captcha-server","owner":"rojer95","description":"基于坐标的点选验证码生成/验证器（服务器SDK）","archived":false,"fork":false,"pushed_at":"2023-04-27T08:30:48.000Z","size":316,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T05:51:12.313Z","etag":null,"topics":["captcha"],"latest_commit_sha":null,"homepage":"click-captcha-server.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rojer95.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2022-08-29T11:35:10.000Z","updated_at":"2024-03-29T14:13:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"f9f0c3b8-f759-4617-85e5-94ee2931d7b6","html_url":"https://github.com/rojer95/click-captcha-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rojer95%2Fclick-captcha-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rojer95%2Fclick-captcha-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rojer95%2Fclick-captcha-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rojer95%2Fclick-captcha-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rojer95","download_url":"https://codeload.github.com/rojer95/click-captcha-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248732512,"owners_count":21152851,"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","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":["captcha"],"created_at":"2024-11-05T21:30:14.618Z","updated_at":"2025-04-13T14:53:37.624Z","avatar_url":"https://github.com/rojer95.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# click-captcha-server\n\n[![NPM version](https://img.shields.io/npm/v/click-captcha-server.svg?style=flat)](https://npmjs.org/package/click-captcha-server)\n[![NPM downloads](http://img.shields.io/npm/dm/click-captcha-server.svg?style=flat)](https://npmjs.org/package/click-captcha-server)\n\n## 预览 / Preview\n\n![Preview](./preview.png)\n\n## 安装 / Install\n\n```bash\n$ yarn add click-captcha-server\n```\n\n## 快速开始 / Quickstart\n\n```ts\nimport ClickCaptcha from \"click-captcha-server\";\n\nconst clickCaptcha = new ClickCaptcha();\n\n// 生成验证码图片与答案区域\nconst { img, front, answer, count } = await clickCaptcha.generate();\n\n// 验证点选位置\nconst input = ctx.body; // input 来自用户点选的坐标集合\nconst pass = clickCaptcha.check(input, answer);\n\nconsole.log(pass ? \"验证成功\" : \"验证失败\");\n```\n\n## 参数 / Options\n\n关于 `ClickCaptcha` 的参数说明如下：\n\n```ts\n// 需要在全局初始化保持单例\nconst clickCaptcha = new ClickCaptcha({\n  bg: (width, height) =\u003e \"http://xxx.xxx.xx/bg.png\", // 返回一个背景图片的 url 【可选】\n  unsplashAccessKey: string, // unsplash AccessKey 【可选，1.0.2版本开始支持】\n  character: [\"你\", \"我\", \"他\", \"等\"], // 显示的字符集合，是一个字符数组预设 【可选】\n  width: 300, // 宽 【可选】\n  height: 200, // 高 【可选】\n  fontMinSize: 26, // 字体大小-最小值 【可选】\n  fontMaxSize: 34, // 字体大小-最大值 【可选】\n  count: 3, // 正确答案数量 【可选】\n  confuseCount: 2, // 迷惑项数量 【可选】\n});\n\n// 导入字体（路径），一样在全局执行一次即可。会扫描路径下的所有ttf格式的字体，且以字体文件名作为font family导入到node-canvas\nclickCaptcha.registerFontByPath(path.join(__dirname, \"./fonts\"));\n```\n\n## 案例 / Example\n\n```bash\ngit clone https://github.com/rojer95/click-captcha-server.git\n\ncd click-captcha-server\n# 安装依赖\nyarn install\n# 构建\nyarn build\n# 运行example\nyarn example\n\n# 打开 http://localhost:3000/ 体验\n```\n\n## node-canvas 依赖说明 / About Canvas Dependence\n\nBy default, binaries for macOS, Linux and Windows will be downloaded. If you want to build from source, use `npm install --build-from-source` and see the **Compiling** section below.\n\nThe minimum version of Node.js required is **6.0.0**.\n\n### Compiling\n\nIf you don't have a supported OS or processor architecture, or you use `--build-from-source`, the module will be compiled on your system. This requires several dependencies, including Cairo and Pango.\n\nFor detailed installation information, see the [wiki](https://github.com/Automattic/node-canvas/wiki/_pages). One-line installation instructions for common OSes are below. Note that libgif/giflib, librsvg and libjpeg are optional and only required if you need GIF, SVG and JPEG support, respectively. Cairo v1.10.0 or later is required.\n\n| OS      | Command                                                                                                         |\n| ------- | --------------------------------------------------------------------------------------------------------------- |\n| OS X    | Using [Homebrew](https://brew.sh/):\u003cbr/\u003e`brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman` |\n| Ubuntu  | `sudo apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev`        |\n| Fedora  | `sudo yum install gcc-c++ cairo-devel pango-devel libjpeg-turbo-devel giflib-devel`                             |\n| Solaris | `pkgin install cairo pango pkg-config xproto renderproto kbproto xextproto`                                     |\n| OpenBSD | `doas pkg_add cairo pango png jpeg giflib`                                                                      |\n| Windows | See the [wiki](https://github.com/Automattic/node-canvas/wiki/Installation:-Windows)                            |\n| Others  | See the [wiki](https://github.com/Automattic/node-canvas/wiki)                                                  |\n\n**Mac OS X v10.11+:** If you have recently updated to Mac OS X v10.11+ and are experiencing trouble when compiling, run the following command: `xcode-select --install`. Read more about the problem [on Stack Overflow](http://stackoverflow.com/a/32929012/148072).\nIf you have xcode 10.0 or higher installed, in order to build from source you need NPM 6.4.1 or higher.\n\n## LICENSE\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frojer95%2Fclick-captcha-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frojer95%2Fclick-captcha-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frojer95%2Fclick-captcha-server/lists"}