Class: OnePass::Password

Inherits:
Object
  • Object
show all
Defined in:
lib/OnePass/password.rb

Overview

Fork out to ‘pinentry` for password

Constant Summary collapse

DESCRIPTION =
'Please enter your 1Password master password for the following vault:'.freeze
DEFAULT =
{
  title: '1Password CLI',
  prompt: 'Master Password: '
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Password

Returns a new instance of Password.



12
13
14
15
16
17
# File 'lib/OnePass/password.rb', line 12

def initialize(opts = {})
  @config = OpenStruct.new DEFAULT.merge(opts)
  if @config.vault_path
    @config.description ||= "#{DESCRIPTION}%0a#{@config.vault_path}"
  end
end

Instance Method Details

#doneObject



28
29
30
31
# File 'lib/OnePass/password.rb', line 28

def done
  send 'BYE'
  @pipe.close
end

#prompt(error_message = nil) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/OnePass/password.rb', line 19

def prompt(error_message = nil)
  @config.error = error_message
  @pipe = IO.popen 'pinentry', 'r+'
  check
  send_settings
  fetch_password
  @password
end