simnalamburt / macos-totp-cli

simple TOTP CLI, powered by keychain of macOS
Other
57 stars 7 forks source link

Friendly error messages #4

Open robertryansqub opened 10 months ago

robertryansqub commented 10 months ago

I installed macos-totp-cli using Brew on an M2 Pro Mini running macOS 14.1. I can add a secret to the keychain, and list them, but when I try to get, there is a panic.

rsir@friday ~ % totp get kelvin2
panic: decode secret failed

goroutine 1 [running]:
github.com/xlzd/gotp.(*OTP).byteSecret(0x1d3d6558a41?)
    /Users/simnalamburt/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/xlzd/gotp@v0.0.0-20181030022105-c8557ba2c119/otp.go:67 +0xd8
github.com/xlzd/gotp.(*OTP).generateOTP(0x140001a1b18, 0x3610d21)
    /Users/simnalamburt/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/xlzd/gotp@v0.0.0-20181030022105-c8557ba2c119/otp.go:46 +0x2c
github.com/xlzd/gotp.(*TOTP).At(...)
    /Users/simnalamburt/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/xlzd/gotp@v0.0.0-20181030022105-c8557ba2c119/totp.go:22
github.com/xlzd/gotp.(*TOTP).Now(0x140001a1b18)
    /Users/simnalamburt/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/xlzd/gotp@v0.0.0-20181030022105-c8557ba2c119/totp.go:27 +0x40
main.main.func4(0x14000186a00?, {0x1400011aa10?, 0x1?, 0x1?})
    /private/tmp/totp-20220806-78375-1tpdfzv/macos-totp-cli-1.0.0/main.go:162 +0x428
github.com/spf13/cobra.(*Command).execute(0x14000186a00, {0x1400011a9f0, 0x1, 0x1})
    /Users/simnalamburt/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:856 +0x4c4
github.com/spf13/cobra.(*Command).ExecuteC(0x14000186f00)
    /Users/simnalamburt/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:974 +0x354
github.com/spf13/cobra.(*Command).Execute(...)
    /Users/simnalamburt/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:902
main.main()
    /private/tmp/totp-20220806-78375-1tpdfzv/macos-totp-cli-1.0.0/main.go:192 +0x31c
simnalamburt commented 10 months ago

I cannot reproduce this issue. Can you share me the exact error reproduction scenario including the secret that is OK to publicy share?

robertryansqub commented 10 months ago

This turns out to be my fault. There was a typo in the secret so it had an extra character. This is then easily reproduced by putting any non-standard text into the keychain and then trying to 'get' that. However that's completely down to user error. Apologies!

scott10000 commented 3 months ago

Hi, I installed macos-totp-cli using brew on an M2 air running macOS 15 beta1. I get the same error as the OP but only on one particular entry. The same seed code works fine on the Apple Passwords app and mintotp (GitHub susam/mintotp). Also there are multiple listings for every entry.