-
-
Notifications
You must be signed in to change notification settings - Fork 478
/
fallback.go
47 lines (38 loc) · 853 Bytes
/
fallback.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package cli
import (
"context"
"github.com/gopasspw/gopass/pkg/termio"
)
// Client is pinentry CLI drop-in
type Client struct {
repeat bool
}
// New creates a new client
func New() (*Client, error) {
return &Client{repeat: false}, nil
}
// Close is a no-op
func (c *Client) Close() {}
// Confirm is a no-op
func (c *Client) Confirm() bool {
return true
}
// Set is a no-op unless you're requesting a repeat
func (c *Client) Set(key string, _ string) error {
if key == "REPEAT" {
c.repeat = true
}
return nil
}
// Option is a no-op
func (c *Client) Option(string) error {
return nil
}
// GetPin prompts for the pin in the termnial and returns the output
func (c *Client) GetPin() ([]byte, error) {
pw, err := termio.AskForPassword(context.TODO(), "your PIN", c.repeat)
if err != nil {
return nil, err
}
return []byte(pw), nil
}