Migrate to pass's otp extension

This commit is contained in:
Daniel Flanagan 2021-07-19 21:02:01 -05:00
parent e0bcf03ce4
commit e4809c0baf
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4
2 changed files with 10 additions and 10 deletions

View file

@ -0,0 +1,6 @@
#!/usr/bin/env fish
set entry $argv[1]
set otp_secret (pass $entry | awk -F': ' '/^otp/{gsub(/\s/,"",$2);print $2}')
set otp_uri "otpauth://totp/totp-secret?secret=$otp_secret&issuer=$entry"
echo $otp_uri | pass otp append $entry

View file

@ -1,12 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# TODO: check for pass echo 'This script is deprecated. Install and use the pass-otp extension.
yay -S pass-otp
key="$1"; shift pass otp $args'
args=("$@") exit 1
otp="$(set -e; pass "$key" 2>/dev/null | grep -Pi '^otp' | cut -d ':' -f 2 | sed 's/ //g')"
otp_status="$?"
[[ $otp_status != 0 ]] && { echo "pass command failed with exit code $otp_status"; exit 1; }
[[ -z $otp ]] && { echo "No OTP secret found for pass entry '$key'"; exit 2; }
simple-otp "$otp"