One time password
TOTP implementation (incomplete. Token is generated, but not verified.)
This commit is contained in:
parent
c8a02fb468
commit
ec1ed9e487
9 changed files with 307 additions and 60 deletions
17
packages/src/lib/utils.js
Normal file
17
packages/src/lib/utils.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
import * as OTPAuth from 'otpauth'
|
||||
|
||||
export const totp = () => {
|
||||
let totp = new OTPAuth.TOTP({
|
||||
issuer: 'Private data',
|
||||
label: 'otp',
|
||||
algorithm: 'SHA1',
|
||||
digits: 6,
|
||||
period: 300,
|
||||
})
|
||||
|
||||
let token = totp.generate()
|
||||
let seconds = totp.period - (Math.floor(Date.now() / 1000) % totp.period)
|
||||
let uri = totp.toString()
|
||||
|
||||
return { token, seconds, uri }
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue