{"id":16098833,"url":"https://github.com/tormozz48/algebraic-captcha","last_synced_at":"2025-03-17T17:31:19.337Z","repository":{"id":33858375,"uuid":"162762177","full_name":"tormozz48/algebraic-captcha","owner":"tormozz48","description":"Generate CAPTCHA from algebraic formula","archived":false,"fork":false,"pushed_at":"2023-06-05T21:18:49.000Z","size":915,"stargazers_count":11,"open_issues_count":6,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T02:23:28.022Z","etag":null,"topics":["algebraic","captcha","equation","express","formula","image","math","middleware","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tormozz48.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-21T22:15:40.000Z","updated_at":"2025-01-04T19:13:21.000Z","dependencies_parsed_at":"2024-06-19T05:46:06.860Z","dependency_job_id":"c6a06f48-555c-42a6-891a-2fb8f19394e1","html_url":"https://github.com/tormozz48/algebraic-captcha","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/tormozz48%2Falgebraic-captcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tormozz48%2Falgebraic-captcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tormozz48%2Falgebraic-captcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tormozz48%2Falgebraic-captcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tormozz48","download_url":"https://codeload.github.com/tormozz48/algebraic-captcha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243872436,"owners_count":20361480,"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":["algebraic","captcha","equation","express","formula","image","math","middleware","typescript"],"created_at":"2024-10-09T18:24:50.215Z","updated_at":"2025-03-17T17:31:18.862Z","avatar_url":"https://github.com/tormozz48.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# algebraic-captcha\n\nGenerate CAPTCHA from algebraic equation\n\n[![version](https://img.shields.io/npm/v/algebraic-captcha.svg)](https://www.npmjs.org/package/algebraic-captcha)\n[![npm license](https://img.shields.io/npm/l/algebraic-captcha.svg)](https://www.npmjs.com/package/algebraic-captcha)\n[![Build Status](https://travis-ci.org/tormozz48/algebraic-captcha.svg?branch=master)](https://travis-ci.org/tormozz48/algebraic-captcha)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n\n[DEMO](https://tormozz48.github.io/algebraic-captcha)\n\n## Install\n\nInstall package as yet another npm package:\n\n```bash\nnpm install algebraic-captcha\n```\n\nAlso [yarn](https://yarnpkg.com/en/) package manager can be used:\n\n```bash\nyarn add algebraic-captcha\n```\n\n## Usage\n\nSimple example.\n\n```js\nconst {AlgebraicCaptcha} = require('algebraic-captcha');\n\nasync function generateCaptcha() {\n    const algebraicCaptcha = new AlgebraicCaptcha({\n        width: 200,\n        height: 200,\n        background: '#ffffff',\n        noise: 1,\n        minValue: 1,\n        maxValue: 10,\n        operandAmount: 1,\n        operandTypes: ['+', '-'],\n        mode: 'formula',\n        targetSymbol: '?'\n    });\n\n    const {image, answer} = await algebraicCaptcha.generateCaptcha();\n}\n```\n\nHere:\n\n-   `answer` - is numeric answer for given equation (10 for this case).\n-   `image` - svg image string\n    ![image](./docs/default.svg)\n\nUsing inside express middleware.\n\n```js\nconst express = require('express');\nconst session = require('express-session');\nconst {AlgebraicCaptcha} = require('algebraic-captcha');\n\nconst app = express();\nconst algebraicCaptcha = new AlgebraicCaptcha({});\n\napp.use(session({secret: 'my awesome session', resave: true}));\n\napp.get('/captcha', async (req, res) =\u003e {\n    const {image, answer} = await algebraicCaptcha.generateCaptcha();\n    req.session.captcha = answer;\n    res.writeHead(200, {'Content-Type': 'image/svg+xml'});\n    res.end(image);\n});\n\napp.listen(3000);\n```\n\n## Options\n\nAvailable options:\n\n#### `width`.\n\nWidth of generated image in pixels\n\n-   minimal value: 20\n-   minimal value: 1000\n-   default value: 200\n\n#### `height`\n\nHeight of generated image in pixels\n\n-   minimal value: 20\n-   minimal value: 1000\n-   default value: 100\n\n#### `minValue`\n\nMin operand value used in equation\n\n-   minimal value: 1\n-   minimal value: 10000\n-   default value: 1\n\n#### `maxValue`\n\nMax operand value used in equation\n\n-   minimal value: 1\n-   minimal value: 10000\n-   default value: 1\n\n#### `background`\n\nBackground color of captcha image\n\n-   default value: '#ffffff'\n\n#### `noise`\n\nNumber of noise lines\n\n-   default value: 1\n\n#### `operandAmount`\n\nNumber of equation operations\n\n-   default value: 1\n\n#### `operandTypes`\n\nArray of used math operators\n\n-   default value: ['+', '-']\n\n#### `mode`\n\nCan have two available values: `formula`, `equation`\n\nIn `formula` mode anwer placeholder will be put to the last position of generated string, such as:\n\n```\n5 + 2 = ?\n```\n\nIn `equation` mode answer placeholder will be put on random operand position except last:\n\n```\n5 + ? = 7 //(or ? + 2 = 7)\n```\n\n-   default value: 'formula'\n\n#### `targetSymbol`\n\nSymbol which is used as placeholder for answer\n\n-   default value: '?'\n\n## Development\n\nClone repository or its fork to local filesystem\n\n```bash\ngit clone https://github.com/tormozz48/algebraic-captcha.git\n```\n\nInstall npm dependencies:\n\n```bash\nnpm install\n```\n\nHere are some suitable commands that can be used during development:\n\n-   `npm run build` - compile [typescript](https://www.typescriptlang.org/index.html) files\n-   `npm run lint` - run [tslint](https://palantir.github.io/tslint/) verification tool\n-   `npm test` - run tests with [mocha](https://mochajs.org)\n-   `npm run watch` - launch watcher for compile source files during development\n\n**Important** Use command `npm run cm` for commit your changes instead of `git commit`.\n\n## License\n\nApache-2.0\n\n## Support\n\nBugs, PRs, comments, suggestions welcomed!\n\nMaintainer: [Andrey Kuznetsov](andrey.kuznetsov48@yandex.ru)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftormozz48%2Falgebraic-captcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftormozz48%2Falgebraic-captcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftormozz48%2Falgebraic-captcha/lists"}