Skip to content

fix(import): preserve SHA algorithms from otpauth URIs - #1599

Open
sean0407 wants to merge 1 commit into
Authenticator-Extension:devfrom
sean0407:codex/authenticator-1593-totp-qr-algorithm
Open

sean0407 wants to merge 1 commit into
Authenticator-Extension:devfrom
sean0407:codex/authenticator-1593-totp-qr-algorithm

Conversation

@sean0407

Copy link
Copy Markdown

Summary

otpauth:// import parsed the algorithm query parameter as a name such as SHA512, but EntryStorage.import() expects the numeric enum value. The name failed parseInt() and silently fell back to SHA-1.

algorithm=SHA512 -> "SHA512" -> NaN -> SHA1
algorithm=SHA512 -> "3"      -> 3   -> SHA512

Normalize recognized enum names to their numeric values before the import storage step. Add SHA-256 and SHA-512 regression coverage.

Evidence

  • Reproduction URI: otpauth://totp/alice?secret=JBSWY3DPEHPK3PXP&algorithm=SHA512.
  • The production import function returned SHA512 before the fix; the storage conversion then selected SHA-1. After the fix it returns 3, which the storage conversion resolves to SHA-512.
  • Changed files: src/import.ts, src/test/import.test.ts.
  • Checks run: isolated before/after reproduction passed; tsc --noEmit passed; webpack --config webpack.dev.js --mode development compiled successfully; git diff --check passed; patch policy accepted 2 text files and 27 changed lines.

Fixes #1593

Merge Danger

Door: two-way

Blast Radius: localized

Only named algorithm values in otpauth:// imports are normalized; unknown values retain the existing fallback behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scanning QR codes with SHA-512 (or SHA-256) generates wrong codes unless added manually

1 participant