Added a QR code code generator that might be used for auth. Updated README with better instructions for setting up Tahoe grid.
20 lines
433 B
JavaScript
20 lines
433 B
JavaScript
import * as OTPAuth from 'otpauth'
|
|
|
|
let secret = new OTPAuth.Secret({ size: 20 })
|
|
|
|
export const totp = () => {
|
|
let totp = new OTPAuth.TOTP({
|
|
issuer: 'Private data',
|
|
label: 'otp',
|
|
algorithm: 'SHA256',
|
|
digits: 6,
|
|
period: 300,
|
|
secret
|
|
})
|
|
|
|
let token = totp.generate()
|
|
let seconds = totp.period - (Math.floor(Date.now() / 1000) % totp.period)
|
|
let uri = totp.toString()
|
|
|
|
return { token, seconds, uri }
|
|
}
|