{"id":50679087,"url":"https://github.com/mint-lang/mint-totp","last_synced_at":"2026-06-08T17:05:05.568Z","repository":{"id":336861989,"uuid":"1135654101","full_name":"mint-lang/mint-totp","owner":"mint-lang","description":"A Mint package providing TOTP code generation for two-factor authentication.","archived":false,"fork":false,"pushed_at":"2026-02-06T13:15:04.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-02-06T21:16:43.038Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Mint","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/mint-lang.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"open_collective":"mint"}},"created_at":"2026-01-16T12:01:39.000Z","updated_at":"2026-02-06T13:15:08.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/mint-lang/mint-totp","commit_stats":null,"previous_names":["mint-lang/mint-totp"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/mint-lang/mint-totp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mint-lang%2Fmint-totp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mint-lang%2Fmint-totp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mint-lang%2Fmint-totp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mint-lang%2Fmint-totp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mint-lang","download_url":"https://codeload.github.com/mint-lang/mint-totp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mint-lang%2Fmint-totp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34071737,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"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":[],"created_at":"2026-06-08T17:05:04.527Z","updated_at":"2026-06-08T17:05:05.562Z","avatar_url":"https://github.com/mint-lang.png","language":"Mint","funding_links":["https://opencollective.com/mint"],"categories":[],"sub_categories":[],"readme":"# TOTP (Time-Based One-Time Password)\n\nA Mint package providing RFC 6238-compliant TOTP code generation for two-factor authentication.\n\n## Features\n\n- Support for SHA-1, SHA-256, and SHA-512 hash algorithms\n- Configurable code length (6, 8, or any digit count)\n- Configurable time period (default 30 seconds)\n- Generate `otpauth://` URLs for QR code generation\n- Verify TOTP codes with configurable time window support\n- Zero external dependencies (uses Web Crypto API)\n\n## Installation\n\nAdd to your `mint.json` dependencies:\n\n```json\n{\n  \"dependencies\": {\n    \"totp\": {\n      \"repository\": \"https://github.com/mint-lang/mint-totp\",\n      \"constraint\": \"0.0.0 \u003c= v \u003c 1.0.0\"\n    }\n  }\n}\n```\n\n## Basic Usage\n\n### Generate Current Code\n\n```mint\ncomponent AuthenticatorDemo {\n  fun onGenerate {\n    case await TOTP.generateWithDefaults(\"JBSWY3DPEHPK3PXP\") {\n      Ok(code) =\u003e\n        Debug.log(\"Current TOTP code: #{code}\")\n\n      Err(error) =\u003e\n        Debug.log(\"Error generating code\")\n    }\n  }\n\n  fun render {\n    \u003cbutton onClick={onGenerate}\u003e\n      \"Generate Code\"\n    \u003c/button\u003e\n  }\n}\n```\n\n### Advanced Configuration\n\n```mint\n{\n  let config = {\n    algorithm: Totp.Algorithm.SHA256,\n    secret: \"JBSWY3DPEHPK3PXP\",\n    period: 30,\n    digits: 8\n  }\n\n  case await Totp.generate(config) {\n    Ok(code) =\u003e\n      // Use 8-digit SHA256 code\n      Debug.log(\"Code: #{code}\")\n\n    Err(Totp.Error.InvalidSecret(msg)) =\u003e\n      // Handle invalid base32 secret\n      Debug.log(\"Invalid secret: #{msg}\")\n\n    Err(error) =\u003e\n      // Handle other errors\n      Debug.log(\"Error\")\n  }\n}\n```\n\n### Generate QR Code URL\n\n```mint\n{\n  let url = TOTP.URI.generateWithDefaults(\n    \"JBSWY3DPEHPK3PXP\",\n    \"MyApp\",\n    \"user@example.com\"\n  )\n\n  // url = \"otpauth://totp/MyApp:user@example.com?secret=JBSWY3DPEHPK3PXP\u0026issuer=MyApp\u0026algorithm=SHA1\u0026digits=6\u0026period=30\"\n  // Convert to QR code and display to user for setup\n}\n```\n\n### Verify User Input\n\n```mint\n{\n  let config = {\n    algorithm: Totp.Algorithm.SHA1,\n    secret: \"JBSWY3DPEHPK3PXP\",\n    period: 30,\n    digits: 6\n  }\n\n  case await Totp.verify(config, userInput, 1) {\n    Ok(true) =\u003e\n      // Code is valid - allow login\n      Debug.log(\"Authentication successful\")\n\n    Ok(false) =\u003e\n      // Code is invalid - reject\n      Debug.log(\"Invalid code\")\n\n    Err(error) =\u003e\n      // Handle error\n      Debug.log(\"Verification error\")\n  }\n}\n```\n\n## Testing\n\nRun tests with RFC 6238 official test vectors:\n\n```bash\nmint test\n```\n\nAll tests validate against the official RFC 6238 test vectors to ensure correctness.\n\n## References\n\n- [RFC 6238 - TOTP: Time-Based One-Time Password Algorithm](https://tools.ietf.org/html/rfc6238)\n- [RFC 4226 - HOTP: An HMAC-Based One-Time Password Algorithm](https://tools.ietf.org/html/rfc4226)\n- [RFC 4648 - The Base16, Base32, and Base64 Data Encodings](https://tools.ietf.org/html/rfc4648)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmint-lang%2Fmint-totp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmint-lang%2Fmint-totp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmint-lang%2Fmint-totp/lists"}