fix(storage): parse enums properly #1451
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix incorrect parsing of the OTP algorithm introduced in version 8.0.0 to enable this feature.
The code before (in v7.0.0):
Authenticator/src/models/storage.ts
Lines 383 to 384 in bf630cc
The code after (in v8.0.0):
Authenticator/src/models/storage.ts
Lines 490 to 492 in 2cf9b0f
@mymindstorm parsed the algorithm-friendly name (
SHA***
) as an integer instead of casting the enum directly. This resulted in aNaN
, which would be stripped during serialization.Since
SHA1
is now considered insecure, companies are likely usingSHA256
, which cannot be parsed and defaults toSHA1
.I wasn't sure if keeping
undefined
was what you wanted. Revert 1fc616b if you think it's better to always useSHA1
as the default.It's the same parsing mistake for the
type
, but this one "worked" because the fallback wasOTPType.totp
(the most commonly used).All of the following issues will likely be fixed by this pull request.
Fixes #1442
Fixes #1443
Fixes #1449
Fixes #1450