Promise-based JS implementation of Steam's mobile two factor authentication
yarn add steamguard-totp
const { generateCode } = require('steamguard-totp');
const shared_secret = '8cr0T+zCLiaSdo1E+Alp7nzAPno=';
// async/await style
(async () => {
const code = await generateCode(shared_secret);
console.log(code);
})();
// promise style
generateCode(shared_secret)
.then((code) => console.log(code));
const { generateCodeForTime } = require('steamguard-totp');
const shared_secret = '8cr0T+zCLiaSdo1E+Alp7nzAPno=';
const timestamp = 1516070462; // Unix timestamp (seconds)
const code = generateCodeForTime(shared_secret, timestamp);
console.log(code); // WMJ5T