{"id":25406260,"url":"https://github.com/jankapunkt/meteor-altcha","last_synced_at":"2025-04-12T21:58:12.270Z","repository":{"id":277362028,"uuid":"931455771","full_name":"jankapunkt/meteor-altcha","owner":"jankapunkt","description":"Drop-In package t use Altcha with Meteor 3+","archived":false,"fork":false,"pushed_at":"2025-02-15T12:17:39.000Z","size":48,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T21:58:08.096Z","etag":null,"topics":["altcha","form","javascript","meteor","meteorjs","package","validatio","web"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/jankapunkt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2025-02-12T10:01:53.000Z","updated_at":"2025-02-15T12:17:42.000Z","dependencies_parsed_at":"2025-02-13T15:36:36.660Z","dependency_job_id":null,"html_url":"https://github.com/jankapunkt/meteor-altcha","commit_stats":null,"previous_names":["jankapunkt/meteor-altcha"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jankapunkt%2Fmeteor-altcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jankapunkt%2Fmeteor-altcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jankapunkt%2Fmeteor-altcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jankapunkt%2Fmeteor-altcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jankapunkt","download_url":"https://codeload.github.com/jankapunkt/meteor-altcha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248637785,"owners_count":21137538,"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":["altcha","form","javascript","meteor","meteorjs","package","validatio","web"],"created_at":"2025-02-16T05:25:35.368Z","updated_at":"2025-04-12T21:58:12.246Z","avatar_url":"https://github.com/jankapunkt.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Meteor Altcha\n\n[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n[![Test suite](https://github.com/jankapunkt/meteor-altcha/actions/workflows/testsuite.yml/badge.svg)](https://github.com/jankapunkt/meteor-altcha/actions/workflows/testsuite.yml)\n\nEasy Meteor integration for [Altcha](https://altcha.org). Works with any frontend.\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n**Table of Contents**  *generated with [DocToc](https://github.com/thlorenz/doctoc)*\n\n- [Installation](#installation)\n  - [Settings setup](#settings-setup)\n  - [Server setup](#server-setup)\n  - [Client Setup](#client-setup)\n  - [Service Worker considerations](#service-worker-considerations)\n- [Form submission and validation](#form-submission-and-validation)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n## Installation\n\nFirst, add this package via `meteor add jkuester:altcha`\nThen install the Altcha client input type via `npm install --save altcha`.\n\n### Settings setup\n\nFor increased security, the internals are configured via Meteor.settings.\nIf you haven't created a Meteor settings file then you can do it via\n\n```shell\necho \"{}\" \u003e settings.json\n```\n\nSo you can start your Meteor app using the settings via `meteor --settings=settings.json`.\n\nAn example settings for altha may look like he following:\n\n```json\n{\n  \"public\": {\n    \"altcha\": {\n      \"challengeUrl\": \"/altcha-challenge\"\n    }\n  },\n  \"altcha\": {\n    \"algorithm\": \"SHA-256\",\n    \"challengeUrl\": \"/altcha-challenge\",\n    \"hmacKey\": \"01234567890abcdefghijklmnopqrstuvwxyz\",\n    \"maxNumber\": 1000000,\n    \"expirationAfter\": 300000\n  }\n}\n```\n\nThe public part is only needed if you want to configure the challenge url\nvia settings.\n\n### Server setup\n\nNow you need to initialize it on the server. You can optionally pass a\nMongo.Collection as storage for solved challenges (prevent Replay Attacks) or a name of the collection\nor omit to use an in-memory collection:\n\n```js\nimport { Meteor } from 'meteor/meteor';\nimport * as Altcha from 'meteor/jkuester:altcha';\n\nMeteor.startup(() =\u003e {\n  Altcha.init()\n});\n```\n\nAs you can see there is an optional debug param, which\nyou can pass a function to, so the internal is passed to it.\nBeware to disable it in production, though.\n\n### Client Setup\n\nOn your client you can simply follow the altcha integration guide.\n\nThe most minimal setup is to use the altcha component and only\nconfigure the challenge-url. The following is a Blaze example,\nbut you are free to use any frontend!\n\n```handlebars\n\u003ctemplate name=\"myForm\"\u003e\n    \u003cform id=\"myForm\"\u003e\n        \u003cinput type=\"text\" name=\"username\" placeholder=\"Username\" /\u003e\n        \u003caltcha-widget challengeurl=\"{{settings.altcha.challengeUrl}}\" debug\u003e\u003c/altcha-widget\u003e\n        \u003cbutton type=\"submit\"\u003eSubmit\u003c/button\u003e\n    \u003c/form\u003e\n\u003c/template\u003e\n```\n\n```js\nimport { Template } from 'meteor/templating';\nimport './myForm.html';\nimport 'altcha'; // this is the npm package, not the Meteor package!\n\nTemplate.registerHelper('settings', () =\u003e Meteor.settings.public)\n\nTemplate.myForm.events({\n  'submit #myForm' (event) {\n    event.preventDefault()\n\n    const data = Object.fromEntries(new FormData(event.target).entries())\n\n    // see next section\n    Meteor.call('validateForm', data, (err, res) =\u003e {\n      if (err) {\n        alert(err.message)\n      }\n      else {\n        event.target.reset()\n      }\n    })\n  },\n});\n```\n\n### Service Worker considerations\n\nIf you're using a service worker then you should make\nsure, it ignores the challenge url.\n\nOtherwise, aggressive caching might cause forms to reuse\nexisting challenges which in turn are rejected by\ndefault when validating.\n\n## Form submission and validation\n\nIn the above example we now validate the submitted form\nby sending the data to a Meteor Method endpoint.\n\nFor the above example, the endpoint simply looks like this:\n\n```js\nMeteor.methods({\n  async validateForm ({ username, altcha }) {\n    const isValid = await Altcha.validate(altcha);\n    if (!isValid) {\n      throw new Meteor.Error(403, 'challenge failed')\n    }\n    // challenge passed, you can\n    // continue with the form submission\n    // data processing\n  }\n})\n```\n\nThe default field name for the altcha is `altcha` and\nyou should consider this in your schema, if you do Methods-\nvalidation using a schema, like SimpleSchema, zod, etc.\n\n## API Documentation\n\nThe API is documented in a separate [API.md file](./API.md).\n\n## Contribution\n\nThank you for considering to contribute! To make both our time worth the effort,\nplease get familiar with the [contribution guide](./CONTRIBUTING.md), the [security guide](./SECURITY.md) and \nthe [code of conduct](./CODE_OF_CONDUCT.md).\n\n## License\n\nMIT, see [license file](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjankapunkt%2Fmeteor-altcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjankapunkt%2Fmeteor-altcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjankapunkt%2Fmeteor-altcha/lists"}