File tree Expand file tree Collapse file tree 3 files changed +10
-11
lines changed Expand file tree Collapse file tree 3 files changed +10
-11
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ export {
4343 after ,
4444} from './core' ;
4545export { 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
You can’t perform that action at this time.
0 commit comments