From e4809c0baf423166e972952aa11ecdc8bff2930c Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Mon, 19 Jul 2021 21:02:01 -0500 Subject: [PATCH] Migrate to pass's otp extension --- common/bin/pass-migrate-to-pass-otp | 6 ++++++ common/bin/pass-otp | 14 ++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) create mode 100755 common/bin/pass-migrate-to-pass-otp diff --git a/common/bin/pass-migrate-to-pass-otp b/common/bin/pass-migrate-to-pass-otp new file mode 100755 index 0000000..a6979aa --- /dev/null +++ b/common/bin/pass-migrate-to-pass-otp @@ -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 diff --git a/common/bin/pass-otp b/common/bin/pass-otp index 023a8d3..f5e81af 100755 --- a/common/bin/pass-otp +++ b/common/bin/pass-otp @@ -1,12 +1,6 @@ #!/usr/bin/env bash -# TODO: check for pass - -key="$1"; shift -args=("$@") - -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" +echo 'This script is deprecated. Install and use the pass-otp extension. + yay -S pass-otp + pass otp $args' +exit 1