goldwarden-vaultwarden-bitw.../cli/agent/systemauth/pinentry/keybase-pinentry.go

51 lines
1.0 KiB
Go
Raw Normal View History

2024-06-01 15:18:11 +02:00
//go:build windows
2024-02-03 22:17:19 +01:00
package pinentry
import (
"errors"
"github.com/keybase/client/go/logger"
"github.com/keybase/client/go/protocol/keybase1"
2024-05-04 01:06:24 +02:00
pinentry "github.com/quexten/goldwarden/cli/agent/systemauth/pinentry/keybase-pinentry"
2024-02-03 22:17:19 +01:00
)
2024-02-09 00:24:28 +01:00
func getPassword(title string, description string) (string, error) {
2024-02-03 22:17:19 +01:00
pinentryInstance := pinentry.New("", logger.New(""), "")
result, err := pinentryInstance.Get(keybase1.SecretEntryArg{
Prompt: title,
Desc: description,
})
if err != nil {
return "", err
}
if result.Canceled {
return "", errors.New("Cancelled")
}
return result.Text, nil
}
2024-02-09 00:24:28 +01:00
func getApproval(title string, description string) (bool, error) {
2024-02-03 22:17:19 +01:00
pinentryInstance := pinentry.New("", logger.New(""), "")
result, err := pinentryInstance.Get(keybase1.SecretEntryArg{
Prompt: title,
Desc: description,
Cancel: "Decline",
Ok: "Approve",
ShowTyping: true,
})
if err != nil {
return false, err
}
if result.Canceled {
return false, errors.New("Cancelled")
}
return true, nil
}