1.0.12 • Published 11 months ago

@gibme/mfa v1.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

MFA/2FA One-Time Password (OTP) Library

Documentation

https://gibme-npm.github.io/mfa/

Secret

The seed used with TOTP and HOTP one-time password(s).

Generate

import { Secret } from '@gibme/mfa';

const secret = new Secret();

console.log(secret.toString());

Restore

import { Secret } from '@gibme/mfa';

const secret = new Secret('ZK26SHUWGERAHUOTQMV7V3YMWIX4XUWS');

TOTP

Used to create and/or verify a Time-based one-time password. The OTP value is based upon the current time and the period specified.

Generate

import { TOTP } from '@gibme/mfa';

const [token] = TOTP.generate({ secret });

Verify

import { TOTP } from '@gibme/mfa';

const [success, delta_window] = TOTP.verify(token, { secret });

if (!success) {
    throw new Error('Invalid OTP code supplied');
}

HOTP

Used to create and/or verify a HMAC-based one-time password. OTPs are generated based upon the counter value supplied.

Generate

import { HOTP } from '@gibme/mfa';

const [token] = HOTP.generate({ secret, counter: 2 });

Verify

import { HOTP } from '@gibme/mfa';

const [success, delta_window] = HOTP.verify(token, { secret, counter: 2 });

if (!success) {
    throw new Error('Invalid OTP code supplied');
}

YubiKey OTP

To obtain a YubiKey API key head on over to the Yubico API key signup page.

Verify

import { YubiKeyOTP } from '@gibme/mfa';

(async () => {
    const response = await YubiKeyOTP.verify(token, {
        clientId: 12345,
        apiKey: 'yourapikey'
    })
    
    if (!response.valid) {
        throw new Error('Invalid OTP code supplied');
    }
})();
1.0.12

11 months ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

2 years ago

1.0.7

2 years ago

1.0.5

2 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago