Methods
(async, static) setup(password, windowopt) → {MFCHFSetup}
- Description:
- Setup an MFCHF hash with a password and 6-digit TOTP factor
- Source:
- Since:
- 0.2.0
Example
// Setup MFCHF-TOTP6 hash
const { hash, secret } = await mfchf.totp6.setup('password123')
// Verify MFCHF-TOTP6 hash
const otp = parseInt(speakeasy.totp({ secret }))
const result = await mfchf.totp6.verify(hash, 'password123', otp)
result.valid.should.be.true
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
password |
string | The password to use | ||
window |
number |
<optional> |
87600
|
Maximum window between logins, in number of steps (1 month by default) |
Returns:
The resulting MFCHF hash and TOTP secret
- Type
- MFCHFSetup
(async, static) verify(hash, password, code) → {MFCHFVerify}
- Description:
- Verify an MFCHF hash with a password and 6-digit TOTP code
- Source:
- Since:
- 0.2.0
Example
// Setup MFCHF-TOTP6 hash
const { hash, secret } = await mfchf.totp6.setup('password123')
// Verify MFCHF-TOTP6 hash
const otp = parseInt(speakeasy.totp({ secret }))
const result = await mfchf.totp6.verify(hash, 'password123', otp)
result.valid.should.be.true
Parameters:
Name | Type | Description |
---|---|---|
hash |
string | The MFCHF hash to verify |
password |
string | The password to use |
code |
number | The TOTP code to use |
Returns:
The verification result
- Type
- MFCHFVerify