Bump libmutton and support new SSH identity file passphrase entry

This commit is contained in:
2024-12-28 15:13:40 -05:00
parent 0e056822ef
commit 4933da4c37
7 changed files with 19 additions and 14 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ go 1.23.4
require (
github.com/Trojan2021/BEAN v0.0.0-20241210230804-8f294833b514
github.com/charmbracelet/glamour v0.7.0
github.com/rwinkhart/libmutton v0.2.5-0.20241221012916-619e4220a60f
github.com/rwinkhart/libmutton v0.2.5-0.20241228200917-a4a39a3a995d
golang.org/x/term v0.27.0
)
+2 -2
View File
@@ -58,8 +58,8 @@ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rwinkhart/convertroman v0.2.0 h1:otUm939eXT77q/Lr31mJtMwVWEw0RjEUB71gO65h9OM=
github.com/rwinkhart/convertroman v0.2.0/go.mod h1:Af6HqvX0EIM4Y3HcnNXbbRey1dLasGB7WU0+3Cowgmw=
github.com/rwinkhart/libmutton v0.2.5-0.20241221012916-619e4220a60f h1:5wWhTS6vS1ozb/j31eSLK32kK0ntAooJSlWNnvpRL2A=
github.com/rwinkhart/libmutton v0.2.5-0.20241221012916-619e4220a60f/go.mod h1:PdB+cyRsd3F4Uwxx8EJCRraJTwbvvrynY9iQVr/V+Wg=
github.com/rwinkhart/libmutton v0.2.5-0.20241228200917-a4a39a3a995d h1:o9fIg0X3BsGUnVQuQ7SqEDHkCCPFTZIxrrjC2sWmdxc=
github.com/rwinkhart/libmutton v0.2.5-0.20241228200917-a4a39a3a995d/go.mod h1:RLpxGyaNGqMgzRf7Qo4q4sBPnUH6Rjt8B6SE5Rp8gXM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
+1 -1
View File
@@ -160,7 +160,7 @@ func main() {
case "clipclear":
core.ClipClearArgument()
case "sync":
sync.RunJob(true)
cli.RunJobWrapper(true)
case "init":
cli.TempInitCli()
case "tweak":
+2 -2
View File
@@ -29,12 +29,12 @@ func AddEntry(targetLocation string, hideSecrets bool, entryType uint8) {
// determine whether to generate the password
var password string
if entryType == 0 {
password = inputHidden("Password:")
password = string(inputHidden("Password:"))
} else {
password = core.StringGen(inputInt("Password length:", -1), inputBinary("Generate a complex (special characters) password?"), 0.2, false)
}
totp := inputHidden("TOTP secret:")
totp := string(inputHidden("TOTP secret:"))
url := input("URL:")
if inputBinary("Add a note to this entry?") {
note, _ := editNote([]string{})
+2 -2
View File
@@ -29,11 +29,11 @@ func EditEntryField(targetLocation string, hideSecrets bool, field int) {
// edit the field
switch field {
case 0:
unencryptedEntry[field] = inputHidden("Password:")
unencryptedEntry[field] = string(inputHidden("Password:"))
case 1:
unencryptedEntry[field] = input("Username:")
case 2:
unencryptedEntry[field] = inputHidden("TOTP secret:")
unencryptedEntry[field] = string(inputHidden("TOTP secret:"))
case 3:
unencryptedEntry[field] = input("URL:")
case 4: // edit notes fields
+1 -2
View File
@@ -5,7 +5,6 @@ import (
"os"
"github.com/rwinkhart/libmutton/core"
"github.com/rwinkhart/libmutton/sync"
)
const ansiShownPassword = "\033[38;5;10m"
@@ -63,7 +62,7 @@ func EntryReader(decryptedEntry []string, hideSecrets, syncEnabled bool) {
}
if syncEnabled {
sync.RunJob(false)
RunJobWrapper(false)
}
os.Exit(0)
+10 -4
View File
@@ -7,6 +7,7 @@ import (
"strings"
"github.com/rwinkhart/libmutton/core"
"github.com/rwinkhart/libmutton/sync"
"golang.org/x/term"
)
@@ -18,13 +19,12 @@ func input(prompt string) string {
return strings.TrimRight(userInput, "\n\r ") // remove trailing newlines, carriage returns, and spaces
}
// inputHidden prompts the user for input and returns the input as a string, hiding the input from the terminal.
func inputHidden(prompt string) string {
// inputHidden prompts the user for input and returns the input as a byte array, hiding the input from the terminal.
func inputHidden(prompt string) []byte {
fmt.Print("\n" + prompt + " ")
byteInput, _ := term.ReadPassword(int(os.Stdin.Fd()))
password := string(byteInput)
fmt.Println()
return password
return byteInput
}
// inputInt prompts the user for input and returns the input as an integer.
@@ -82,3 +82,9 @@ func writeEntryCLI(targetLocation string, unencryptedEntry []string, hideSecrets
func expandPathWithHome(path string) string {
return strings.Replace(path, "~", core.Home, 1)
}
// RunJobWrapper is a wrapper for sync.RunJob that sets the passphrase input function to inputHidden.
func RunJobWrapper(manualSync bool) {
core.PassphraseInputFunction = inputHidden
sync.RunJob(manualSync)
}