{"_id":"@akc42/totp","_rev":"4-04e0e92a15247fad7d8005a0c720abf7","name":"@akc42/totp","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.0":{"name":"@akc42/totp","version":"1.0.0","keywords":["utilities","totp"],"author":{"name":"Alan Chandler"},"license":"GPL-3.0-or-later","_id":"@akc42/totp@1.0.0","maintainers":[{"name":"akc42","email":"alan@chandlerfamily.org.uk"}],"homepage":"https://github.com/akc42/totp#readme","bugs":{"url":"https://github.com/akc42/totp/issues"},"dist":{"shasum":"a8e3e4ec088eb4e93ef2c55e47584bc8069463e1","tarball":"https://registry.npmjs.org/@akc42/totp/-/totp-1.0.0.tgz","fileCount":5,"integrity":"sha512-Th/+3V9S1tB2kfL12Ft7yNalBZHqsUaNr0ZsjzZVhHxplOpGBMVv5InKgESs6Xxoxt8BZoeE4B8FiXjhEcmVdA==","signatures":[{"sig":"MEYCIQDicPBYuXbkn6QFFt2rCGdBSk8j9I3Pl0TQqoVdKLgOnwIhAIW9o3R1GIGH/XewabkZtN3EBvPMnMhYRBtS5lKTaHYL","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":46577},"main":"./totp.js","type":"module","gitHead":"442ff0d7faabd693075f30e48c193a275292b603","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"akc42","email":"alan@chandlerfamily.org.uk"},"repository":{"url":"git+https://github.com/akc42/totp.git","type":"git"},"_npmVersion":"11.6.4","description":"Simple functions to support Time based One Time Passwords compatible with Google Authenticator (and others)","directories":{},"_nodeVersion":"24.11.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/totp_1.0.0_1768078698403_0.9918498342941253","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@akc42/totp","version":"1.0.1","keywords":["utilities","totp"],"author":{"name":"Alan Chandler"},"license":"GPL-3.0-or-later","_id":"@akc42/totp@1.0.1","maintainers":[{"name":"akc42","email":"alan@chandlerfamily.org.uk"}],"homepage":"https://github.com/akc42/totp#readme","bugs":{"url":"https://github.com/akc42/totp/issues"},"dist":{"shasum":"fbea81a730b55567a38bac007ff24b50468719d8","tarball":"https://registry.npmjs.org/@akc42/totp/-/totp-1.0.1.tgz","fileCount":4,"integrity":"sha512-qaN981cIuZQRv/DhTVxEOY3h3ghWY6tcdhLafyVSKOaw0kYahiLmrddDioq39qQtc5WStkr2QMbfu+XzCEp45w==","signatures":[{"sig":"MEUCIDLx9cO6IAGmyl14sUH7NyidWhbTqiIhkjFxxIf0ZuluAiEAokircdvWfC0GCRLLf7M2A7Cdu/tpGtiCZCoHlhYlf74=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":43258},"main":"./totp.js","type":"module","gitHead":"81a931e6997d9c8f5549a1e0458e05a137009f0f","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"akc42","email":"alan@chandlerfamily.org.uk"},"repository":{"url":"git+https://github.com/akc42/totp.git","type":"git"},"_npmVersion":"11.6.2","description":"Simple functions to support Time based One Time Passwords compatible with Google Authenticator (and others)","directories":{},"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/totp_1.0.1_1768157474488_0.04596360097015273","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@akc42/totp","version":"1.0.2","keywords":["utilities","totp"],"author":{"name":"Alan Chandler"},"license":"GPL-3.0-or-later","_id":"@akc42/totp@1.0.2","maintainers":[{"name":"akc42","email":"alan@chandlerfamily.org.uk"}],"homepage":"https://github.com/akc42/totp#readme","bugs":{"url":"https://github.com/akc42/totp/issues"},"dist":{"shasum":"d2302a68d5847d589acbd2ed10b7e4b31fca5f81","tarball":"https://registry.npmjs.org/@akc42/totp/-/totp-1.0.2.tgz","fileCount":4,"integrity":"sha512-6dTxFYUu5BmBINwZHsbVXKJyIlGWFKEoGh9237C0UfJctr01XbvHItowGvHsMdFvTvHjFAmzHkOKZmgRpc3qQA==","signatures":[{"sig":"MEQCIF3Yos6Dw0cbYAwPjOl7AysrA/ZlkbQNcGb2W9JJw8KRAiB57Ok9TOrF1kQyLn/MXqSW+QXyAR6dry16xR/9zf4CvQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":43836},"main":"./totp.js","type":"module","gitHead":"b59b8457f6476296279fb453c4f54f105e91ac3f","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"akc42","email":"alan@chandlerfamily.org.uk"},"repository":{"url":"git+https://github.com/akc42/totp.git","type":"git"},"_npmVersion":"11.6.2","description":"Simple functions to support Time based One Time Passwords compatible with Google Authenticator (and others)","directories":{},"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/totp_1.0.2_1768316179743_0.4480322821344467","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@akc42/totp","version":"1.0.3","type":"module","description":"Simple functions to support Time based One Time Passwords compatible with Google Authenticator (and others)","main":"./totp.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/akc42/totp.git"},"keywords":["utilities","totp"],"author":{"name":"Alan Chandler"},"license":"GPL-3.0-or-later","bugs":{"url":"https://github.com/akc42/totp/issues"},"homepage":"https://github.com/akc42/totp#readme","gitHead":"7d6b484024bf01c9a0b57744379457789fc3f432","_id":"@akc42/totp@1.0.3","_nodeVersion":"24.12.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-LzXDe9zHBwxDN1o8yTGjRLV+E5MpfPyq7ZrvLFeCgx9ScleDcsykOy9SntlYGev2zgzFu4q228PQOX9dXx25qA==","shasum":"19dfe4ed2bb008a861891782bbb3c3132eb74ed4","tarball":"https://registry.npmjs.org/@akc42/totp/-/totp-1.0.3.tgz","fileCount":4,"unpackedSize":43838,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIFoWUKrjgML99wJOZP5nEHYv1MOlXGEhZfXjSbb55MFgAiEAow6GKOdKm390pyJYEBPwaAw3sFLQqnJcUiEjJes02uA="}]},"_npmUser":{"name":"akc42","email":"alan@chandlerfamily.org.uk"},"directories":{},"maintainers":[{"name":"akc42","email":"alan@chandlerfamily.org.uk"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/totp_1.0.3_1768407613689_0.6819848390063179"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-10T20:58:18.335Z","modified":"2026-01-14T16:20:13.951Z","1.0.0":"2026-01-10T20:58:18.533Z","1.0.1":"2026-01-11T18:51:14.642Z","1.0.2":"2026-01-13T14:56:19.874Z","1.0.3":"2026-01-14T16:20:13.826Z"},"bugs":{"url":"https://github.com/akc42/totp/issues"},"author":{"name":"Alan Chandler"},"license":"GPL-3.0-or-later","homepage":"https://github.com/akc42/totp#readme","keywords":["utilities","totp"],"repository":{"type":"git","url":"git+https://github.com/akc42/totp.git"},"description":"Simple functions to support Time based One Time Passwords compatible with Google Authenticator (and others)","maintainers":[{"name":"akc42","email":"alan@chandlerfamily.org.uk"}],"readme":"Totp is a very simple set of functions to support the generation of time based one time passwords.  The only aim of this\npackage was to provide a simple set of functions to use in conjunction with the `npm qrcode` package to provide the\nability to set up and verify time based passwords using Google Authenticator.  For some time I had been using another\nthird party package, and although it worked flawlessly I had heard it reported that it was totally unmaintained.  I\ndecided to try and see if I could replicate the functions myself as a protection mechanism.\n\nThe more I got into it the more I found that the essence of the algorithmn is really simple and could be implemented\nusing only the `node:crypto` package and a `hexToBase32` module I had already written as part of porting data from SQL\nServer to SQLite. Given its size in comparison to what I was using previously I decided to package it up for use in my\nprojects.\n\nThat is this package.\n\nBefore I talk about the interface, a number of basics.  The key that is carried around will be in hex.  With the old\npackage I carried keys around in the underlying \"base32\" character set - somthing that the Google Autheticator needs\n(within the keyuri that is represented in the QR Code that the it reads).  However the more I looked into things, all\nthe underlying security routines could work with Hex strings and my database (SQLite) could take a Hex string and store\nthe result in a \"BLOB\", and it could also return data from a BLOB as a Hex string. I decided therefore to do most\nmanipulation in Hex and only convert to base32 when building the keyUri.  This package contains the **hexToBase32**\nsoftware that does that conversion.  I also include **base32ToHex** incase anyone what to work with primarly the base32\nstrings and only use Hex when passing to these routines.  Both routines take the appropriate form as a string (uppercase\nonly for base32, lowercase only for hex) as its only parameter and return the other form.\n\n**makeKey** returns a 40 random hex character string (no parameters needed)\n\n**keyUri** takes in parameters `key`, `username`, `appname` (also know as `issuer`) and returns a `uri` that can be\npassed to the qrcode module to produce a qrcode.\n\n**verify** take in a `code` (the 6 digit code displayed by google authenticator) as a `String` and the `key` (in Hex)\nand returns `true` or `false` dependant on whether the code is the correct on for the key at the instance the function\nwas called.  NOTE: this requires the computer this runs with to be closely in sync in time.\n\n**passCode** although just a helper for verify, I decided to extract and enhance the software that takes the time now,\nand the secret `key` and calculates the `code` (for comparison in verify).  It takes an extra paramter `periods` which\nis the number of periods (30 seconds if left unchanged) and produces the code for a period ahead.  0 is now 1 is for 30\nseconds time etc. Negative values should work also - useful to build a different verify with a wider time range.\n\n\n\n","readmeFilename":"README.md"}