@@ -127,9 +127,12 @@ class MFAAdapter extends AuthAdapter {
127
127
if ( digits < 4 || digits > 10 ) {
128
128
throw 'mfa.digits must be between 4 and 10' ;
129
129
}
130
- if ( period < 10 ) {
131
- throw 'mfa.period must be greater than 10' ;
132
- }
130
+
131
+ validOptions . forEach ( method => {
132
+ if ( typeof this . period [ method ] !== 'number' || this . period [ method ] < 10 ) {
133
+ throw `mfa.period.${ method } must be a number greater than or equal to 10` ;
134
+ }
135
+ } ) ;
133
136
134
137
const sendSMS = opts . sendSMS ;
135
138
const sendEmail = opts . sendEmail ;
@@ -232,7 +235,7 @@ class MFAAdapter extends AuthAdapter {
232
235
const totp = new TOTP ( {
233
236
algorithm : this . algorithm ,
234
237
digits : this . digits ,
235
- period : this . period ,
238
+ period : this . period [ 'TOTP' ] ,
236
239
secret : Secret . fromBase32 ( secret ) ,
237
240
} ) ;
238
241
const valid = totp . validate ( {
@@ -337,7 +340,7 @@ class MFAAdapter extends AuthAdapter {
337
340
}
338
341
token = token . substring ( 0 , this . digits ) ;
339
342
await Promise . resolve ( this . smsCallback ( token , mobile ) ) ;
340
- const expiry = new Date ( new Date ( ) . getTime ( ) + this . period * 1000 ) ;
343
+ const expiry = new Date ( new Date ( ) . getTime ( ) + this . period [ 'SMS' ] * 1000 ) ;
341
344
return { token, expiry } ;
342
345
}
343
346
@@ -351,7 +354,7 @@ class MFAAdapter extends AuthAdapter {
351
354
}
352
355
token = token . substring ( 0 , this . digits ) ;
353
356
await Promise . resolve ( this . emailCallback ( token , email ) ) ;
354
- const expiry = new Date ( new Date ( ) . getTime ( ) + this . period * 1000 ) ;
357
+ const expiry = new Date ( new Date ( ) . getTime ( ) + this . period [ 'EMAIL' ] * 1000 ) ;
355
358
return { token, expiry } ;
356
359
}
357
360
async confirmSMSOTP ( inputData , authData ) {
@@ -401,7 +404,7 @@ class MFAAdapter extends AuthAdapter {
401
404
const totp = new TOTP ( {
402
405
algorithm : this . algorithm ,
403
406
digits : this . digits ,
404
- period : this . period ,
407
+ period : this . period [ 'TOTP' ] ,
405
408
secret : Secret . fromBase32 ( secret ) ,
406
409
} ) ;
407
410
const valid = totp . validate ( {
0 commit comments