Skip to content

fix(storage): parse enums properly #1451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

Caceresenzo
Copy link

@Caceresenzo Caceresenzo commented Aug 15, 2025

Fix incorrect parsing of the OTP algorithm introduced in version 8.0.0 to enable this feature.

The code before (in v7.0.0):

data[hash].algorithm =
data[hash].algorithm || OTPAlgorithm[OTPAlgorithm.SHA1];

The code after (in v8.0.0):

algorithm: rawAlgorithm
? (parseInt(rawAlgorithm) as OTPAlgorithm)
: OTPAlgorithm.SHA1,

@mymindstorm parsed the algorithm-friendly name (SHA***) as an integer instead of casting the enum directly. This resulted in a NaN, which would be stripped during serialization.

Since SHA1 is now considered insecure, companies are likely using SHA256, which cannot be parsed and defaults to SHA1.

I wasn't sure if keeping undefined was what you wanted. Revert 1fc616b if you think it's better to always use SHA1 as the default.

It's the same parsing mistake for the type, but this one "worked" because the fallback was OTPType.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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants