image-to-totp is a library to generate totp codes from a QR code image with a single API.
npm install @thomaschaplin/image-to-totp
Find full example here but see the below code snippet
src/
images/
example1.png
example2.png
import { imageToTotp } from "@thomaschaplin/image-to-totp";
import * as path from "path";
const example = async (account: string) => {
const projectBaseFolder = path.join(__dirname, "../");
const imagesFolder = path.join(projectBaseFolder, "src/images");
const totp = await imageToTotp(`${imagesFolder}/${account}.png`);
console.log(`Account: ${account} - ${totp}`);
};
example("example1"); // Account: example1 - 034624
example("example2"); // Account: example2 - 084841
This repository allows you to take a QR code image and turn it into a TOTP code.
This project uses:
Make sure you have Node.js installed on your machine
- Clone this repository
git clone git@github.com:thomaschaplin/image-to-totp.git
- Change directory
cd image-to-totp
- Install the dependencies
npm install
- Transpile the code
npm run build
ornpm run watch
- Run the tests
npm test
- Run the tests with coverage
npm run test:coverage
- Run the tests with mutation testing
npm run test:mutation
Image by mohamed Hassan from Pixabay