{"id":16193577,"url":"https://github.com/pyramation/totp","last_synced_at":"2025-04-07T15:20:03.730Z","repository":{"id":66351172,"uuid":"312723848","full_name":"pyramation/totp","owner":"pyramation","description":"RFC6238 TOTP implementation in pure PostgreSQL plpgsql","archived":false,"fork":false,"pushed_at":"2022-09-30T17:20:42.000Z","size":205,"stargazers_count":117,"open_issues_count":3,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-13T02:03:53.583Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PLpgSQL","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/pyramation.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":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-14T01:42:23.000Z","updated_at":"2025-02-07T11:53:09.000Z","dependencies_parsed_at":"2023-02-27T00:00:24.151Z","dependency_job_id":null,"html_url":"https://github.com/pyramation/totp","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/pyramation%2Ftotp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyramation%2Ftotp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyramation%2Ftotp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyramation%2Ftotp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyramation","download_url":"https://codeload.github.com/pyramation/totp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247675597,"owners_count":20977378,"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":[],"created_at":"2024-10-10T08:15:34.605Z","updated_at":"2025-04-07T15:20:03.705Z","avatar_url":"https://github.com/pyramation.png","language":"PLpgSQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# totp [![Build Status](https://travis-ci.com/pyramation/totp.svg?branch=master)](https://travis-ci.com/pyramation/totp)\n\nTOTP implementation in pure PostgreSQL plpgsql\n\nThis extension provides the HMAC Time-Based One-Time Password Algorithm (TOTP) as specfied in RFC 6238/4226 as pure plpgsql functions.\n\n# Usage\n\n## totp.generate\n\n```sql\nSELECT totp.generate('mysecret');\n\n-- you can also specify totp_interval, and totp_length\nSELECT totp.generate('mysecret', 30, 6);\n```\n\nIn this case, produces a TOTP code of length 6\n\n```\n013438\n```\n\n## totp.verify\n\n```sql\nSELECT totp.verify('mysecret', '765430');\n\n-- you can also specify totp_interval, and totp_length\nSELECT totp.verify('mysecret', '765430', 30, 6);\n```\n\nDepending on input, returns `TRUE/FALSE` \n\n## totp.url\n\n```sql\n-- totp.url ( email text, totp_secret text, totp_interval int, totp_issuer text )\nSELECT totp.url(\n    'customer@email.com',\n    'mysecret',\n    30,\n    'Acme Inc'\n);\n```\n\nWill produce a URL-encoded string\n\n```\notpauth://totp/customer@email.com?secret=mysecret\u0026period=30\u0026issuer=Acme%20Inc\n```\n\n# caveats\n\n* Currently only supports `sha1`\n* Currently only supports 20 byte secrets \n\npull requests welcome!\n\n# credits\n\nThanks to \n\nhttps://tools.ietf.org/html/rfc6238\n\nhttps://www.youtube.com/watch?v=VOYxF12K1vE\n\nhttps://pgxn.org/dist/otp/\n\n# Development\n\n## start the postgres db process\n\nFirst you'll want to start the postgres docker (you can also just use `docker-compose up -d`):\n\n```sh\nmake up\n```\n\n## install modules\n\nInstall modules\n\n```sh\nyarn install\n```\n\n## install the Postgres extensions\n\nNow that the postgres process is running, install the extensions:\n\n```sh\nmake install\n```\n\nThis basically `ssh`s into the postgres instance with the `packages/` folder mounted as a volume, and installs the bundled sql code as pgxn extensions.\n\n## testing\n\nTesting will load all your latest sql changes and create fresh, populated databases for each sqitch module in `packages/`.\n\n```sh\nyarn test:watch\n```\n\n## building new modules\n\nCreate a new folder in `packages/`\n\n```sh\nlql init\n```\n\nThen, run a generator:\n\n```sh\nlql generate\n```\n\nYou can also add arguments if you already know what you want to do:\n\n```sh\nlql generate schema --schema myschema\nlql generate table --schema myschema --table mytable\n```\n\n## deploy code as extensions\n\n`cd` into `packages/\u003cmodule\u003e`, and run `lql package`. This will make an sql file in `packages/\u003cmodule\u003e/sql/` used for `CREATE EXTENSION` calls to install your sqitch module as an extension.\n\n## recursive deploy\n\nYou can also deploy all modules utilizing versioning as sqtich modules. Remove `--createdb` if you already created your db:\n\n```sh\nlql deploy awesome-db --yes --recursive --createdb\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyramation%2Ftotp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyramation%2Ftotp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyramation%2Ftotp/lists"}