Skip to content

Commit ca24ebd

Browse files
rename API
1 parent bad0642 commit ca24ebd

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

__tests__/core/totp.test.ts renamed to __tests__/core/mfa.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@
2323
*
2424
*/
2525

26-
import { createTOTP } from '../../src/core/totp';
26+
import { totp } from '../../src/core/mfa';
2727

28-
describe('TOTP', () => {
29-
it('generate one time token', () => {
30-
const totp = createTOTP({ secret: "FLIIOLP3IR3W" });
31-
expect(totp.generate().length).toBe(6);
32-
expect(totp.toString()).toEqual('otpauth://totp/SyntheticsTOTP?secret=FLIIOLP3IR3Q&algorithm=SHA1&digits=6&period=30')
28+
describe('MFA', () => {
29+
it('generate TOTP', () => {
30+
const token = totp("FLIIOLP3IR3W");
31+
expect(token.length).toBe(6);
3332
});
3433
});
3534

src/core/totp.ts renamed to src/core/mfa.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ type TOTPOptions = {
3636
*/
3737
label?: string
3838
/**
39-
* Include issuer prefix in label.
40-
*/
39+
* Include issuer prefix in label.
40+
*/
4141
issuerInLabel?: boolean
4242
/**
4343
* The encoded secret key used to generate the TOTP.
@@ -60,6 +60,6 @@ type TOTPOptions = {
6060
period?: number
6161
};
6262

63-
export function createTOTP(options: TOTPOptions) {
64-
return new TOTP({ label: "SyntheticsTOTP", ...options });
63+
export function totp(secret?: string, options: TOTPOptions = {}) {
64+
return new TOTP({ label: "SyntheticsTOTP", secret, ...options }).generate();
6565
}

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export {
4343
after,
4444
} from './core';
4545
export { expect } from './core/expect';
46-
export { createTOTP } from './core/totp';
46+
export * as mfa from './core/mfa';
4747

4848
/**
4949
* Export all the driver related types to be consumed

0 commit comments

Comments
 (0)