mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-08-28 04:46:41 -04:00
Move TOTP secrets to a dedicated entry field (breaks sshyp entry format compatibility)
This commit is contained in:
@@ -72,13 +72,13 @@ func main() {
|
||||
field = 0
|
||||
case "username", "-u":
|
||||
field = 1
|
||||
case "url", "-l":
|
||||
field = 2
|
||||
case "note", "-n":
|
||||
field = 3
|
||||
case "totp", "-t":
|
||||
fmt.Println("TOTP code will be copied to clipboard - your clipboard will be kept up to date with the current TOTP code until this process is closed")
|
||||
field = 5 // TODO Update field after removed from notes (breaking sshyp entry compatibility)
|
||||
field = 2
|
||||
case "url", "-l":
|
||||
field = 3
|
||||
case "note", "-n":
|
||||
field = 4
|
||||
default:
|
||||
cli.HelpCopy()
|
||||
}
|
||||
@@ -90,10 +90,12 @@ func main() {
|
||||
field = 0
|
||||
case "username", "-u":
|
||||
field = 1
|
||||
case "url", "-l":
|
||||
case "totp", "-t":
|
||||
field = 2
|
||||
case "note", "-n":
|
||||
case "url", "-l":
|
||||
field = 3
|
||||
case "note", "-n":
|
||||
field = 4
|
||||
case "rename", "-r":
|
||||
cli.RenameCli(targetLocation)
|
||||
default:
|
||||
|
||||
+4
-3
@@ -28,16 +28,17 @@ func AddEntry(targetLocation string, hidePassword bool, entryType uint8) {
|
||||
password = backend.StringGen(inputInt("Password length:", -1), inputBinary("Generate a complex (special characters) password?"), 0.2)
|
||||
}
|
||||
|
||||
totp := inputHidden("TOTP secret:")
|
||||
url := input("URL:")
|
||||
if inputBinary("Add a note to this entry?") {
|
||||
note, _ := editNote([]string{})
|
||||
unencryptedEntry = append([]string{password, username, url}, note...)
|
||||
unencryptedEntry = append([]string{password, username, totp, url}, note...)
|
||||
} else {
|
||||
unencryptedEntry = []string{password, username, url}
|
||||
unencryptedEntry = []string{password, username, totp, url}
|
||||
}
|
||||
} else {
|
||||
note, _ := editNote([]string{})
|
||||
unencryptedEntry = append([]string{"", "", ""}, note...)
|
||||
unencryptedEntry = append([]string{"", "", "", ""}, note...)
|
||||
}
|
||||
|
||||
// write and preview the new entry
|
||||
|
||||
+5
-3
@@ -34,11 +34,13 @@ func EditEntryField(targetLocation string, hidePassword bool, field int) {
|
||||
case 1:
|
||||
unencryptedEntry[field] = input("Username:")
|
||||
case 2:
|
||||
unencryptedEntry[field] = inputHidden("TOTP secret:")
|
||||
case 3:
|
||||
unencryptedEntry[field] = input("URL:")
|
||||
case 3: // edit notes fields
|
||||
case 4: // edit notes fields
|
||||
// store note and non-note data separately
|
||||
nonNoteData := unencryptedEntry[:3]
|
||||
noteData := unencryptedEntry[3:]
|
||||
nonNoteData := unencryptedEntry[:4]
|
||||
noteData := unencryptedEntry[4:]
|
||||
|
||||
// edit the note
|
||||
editedNote, noteEdited := editNote(noteData)
|
||||
|
||||
+12
-3
@@ -34,17 +34,26 @@ func EntryReader(decryptedEntry []string, hidePassword bool, syncEnabled bool) {
|
||||
fmt.Print(ansiDirectoryHeader + "Username:" + backend.AnsiReset + "\n" + decryptedEntry[1] + "\n\n")
|
||||
}
|
||||
case 2:
|
||||
// if the third field (url) is not empty, print it
|
||||
// if the third field (TOTP secret) is not empty, print it
|
||||
if decryptedEntry[2] != "" {
|
||||
fmt.Print(ansiDirectoryHeader + "URL:" + backend.AnsiReset + "\n" + decryptedEntry[2] + "\n\n")
|
||||
if !hidePassword {
|
||||
fmt.Print(ansiDirectoryHeader + "TOTP Secret:" + backend.AnsiReset + "\n" + ansiShownPassword + decryptedEntry[2] + backend.AnsiReset + "\n\n")
|
||||
} else {
|
||||
fmt.Print(ansiDirectoryHeader + "TOTP Secret:" + backend.AnsiReset + "\n" + ansiEmptyDirectoryWarning + "End command in \"show\" or \"-s\" to view" + backend.AnsiReset + "\n\n")
|
||||
}
|
||||
}
|
||||
case 3:
|
||||
// if the fourth field (url) is not empty, print it
|
||||
if decryptedEntry[3] != "" {
|
||||
fmt.Print(ansiDirectoryHeader + "URL:" + backend.AnsiReset + "\n" + decryptedEntry[3] + "\n\n")
|
||||
}
|
||||
case 4:
|
||||
// print the notes header
|
||||
fmt.Println(ansiDirectoryHeader + "Notes:" + backend.AnsiReset)
|
||||
|
||||
// combine remaining fields into a single string (for markdown rendering)
|
||||
var markdownNotes []string
|
||||
for field := 3; field < len(decryptedEntry); field++ {
|
||||
for field := 4; field < len(decryptedEntry); field++ {
|
||||
markdownNotes = append(markdownNotes, decryptedEntry[field])
|
||||
}
|
||||
r, _ := glamour.NewTermRenderer(glamour.WithStylesFromJSONBytes(glamourStyle()), glamour.WithPreservedNewLines(), glamour.WithWordWrap(width))
|
||||
|
||||
@@ -37,12 +37,13 @@ This program comes with absolutely no warranty; type "mutn version" for details.
|
||||
password|-pw|<blank> Copy the password of an entry to your clipboard
|
||||
username|-u Copy the username of an entry to your clipboard
|
||||
totp|-t Copy the TOTP code of an entry to your clipboard
|
||||
url|-l Copy the url of an entry to your clipboard
|
||||
url|-l Copy the URL of an entry to your clipboard
|
||||
note|-n Copy the note of an entry to your clipboard
|
||||
edit:
|
||||
password|-pw|<blank> Change the password of an entry
|
||||
username|-u Change the username of an entry
|
||||
url|-l Change the url attached to an entry
|
||||
totp|-t Change the TOTP secret of an entry
|
||||
url|-l Change the URL attached to an entry
|
||||
note|-n Change the note attached to an entry
|
||||
rename|-r Rename or relocate an entry
|
||||
gen:
|
||||
@@ -77,7 +78,8 @@ func HelpEdit() {
|
||||
edit:
|
||||
password|-pw|<blank> Change the password of an entry
|
||||
username|-u Change the username of an entry
|
||||
url|-l Change the url attached to an entry
|
||||
totp|-t Change the TOTP secret of an entry
|
||||
url|-l Change the URL attached to an entry
|
||||
note|-n Change the note attached to an entry
|
||||
rename|-r Rename or relocate an entry` + "\n\n")
|
||||
os.Exit(0)
|
||||
@@ -91,7 +93,7 @@ func HelpCopy() {
|
||||
password|-pw|<blank> Copy the password in an entry to your clipboard
|
||||
username|-u Copy the username in an entry to your clipboard
|
||||
totp|-t Copy the TOTP code of an entry to your clipboard
|
||||
url|-l Copy the url in an entry to your clipboard
|
||||
url|-l Copy the URL in an entry to your clipboard
|
||||
note|-n Copy the first note line in an entry to your clipboard` + "\n\n")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user