@@ -185,6 +185,10 @@ export class EntryStorage {
185185 storageItem . account = entry . account ;
186186 }
187187
188+ if ( entry . digits && entry . digits !== 6 ) {
189+ storageItem . digits = entry . digits ;
190+ }
191+
188192 return storageItem ;
189193 }
190194
@@ -348,6 +352,7 @@ export class EntryStorage {
348352 data [ hash ] . issuer = data [ hash ] . issuer || "" ;
349353 data [ hash ] . type = data [ hash ] . type || OTPType [ OTPType . totp ] ;
350354 data [ hash ] . counter = data [ hash ] . counter || 0 ;
355+ data [ hash ] . digits = data [ hash ] . digits || 6 ;
351356 const period = data [ hash ] . period ;
352357 if (
353358 data [ hash ] . type !== OTPType [ OTPType . totp ] ||
@@ -356,6 +361,12 @@ export class EntryStorage {
356361 delete data [ hash ] . period ;
357362 }
358363
364+ // If invalid digits, then use defualt.
365+ const digits = data [ hash ] . digits ;
366+ if ( digits && ( digits > 10 || digits < 1 ) ) {
367+ data [ hash ] . digits = 6 ;
368+ }
369+
359370 if ( / ^ ( b l z \- | b l i z \- ) / . test ( data [ hash ] . secret ) ) {
360371 const secretMatches = data [ hash ] . secret . match (
361372 / ^ ( b l z \- | b l i z \- ) ( .* ) /
@@ -521,7 +532,7 @@ export class EntryStorage {
521532 entryData . type = OTPType [ OTPType . totp ] ;
522533 }
523534
524- let period = 30 ;
535+ let period : number | undefined ;
525536 if (
526537 entryData . type === OTPType [ OTPType . totp ] &&
527538 entryData . period &&
@@ -539,7 +550,8 @@ export class EntryStorage {
539550 secret : entryData . secret ,
540551 type,
541552 counter : entryData . counter ,
542- period
553+ period,
554+ digits : entryData . digits
543555 } ) ;
544556
545557 data . push ( entry ) ;
0 commit comments