lib/lastpass/vault.rb in lastpass-1.5.0 vs lib/lastpass/vault.rb in lastpass-1.6.0

- old
+ new

@@ -9,16 +9,10 @@ def self.open_remote username, password, multifactor_password = nil, client_id = nil blob = Vault.fetch_blob username, password, multifactor_password, client_id open blob, username, password end - # Creates a vault from a locally stored blob - def self.open_local blob_filename, username, password - # TODO: read the blob here - raise NotImplementedError - end - # Creates a vault from a blob object def self.open blob, username, password new blob, blob.encryption_key(username, password) end @@ -36,35 +30,38 @@ chunks = Parser.extract_chunks blob if !complete? chunks raise InvalidResponseError, "Blob is truncated" end - @accounts = parse_accounts chunks, encryption_key + private_key = nil + if blob.encrypted_private_key + private_key = Parser.parse_private_key blob.encrypted_private_key, encryption_key + end + + @accounts = parse_accounts chunks, encryption_key, private_key end def complete? chunks !chunks.empty? && chunks.last.id == "ENDM" && chunks.last.payload == "OK" end - def parse_accounts chunks, encryption_key + def parse_accounts chunks, encryption_key, private_key accounts = [] - key = encryption_key - rsa_private_key = nil chunks.each do |i| case i.id when "ACCT" # TODO: Put shared folder name as group in the account account = Parser.parse_ACCT i, key if account accounts << account end - when "PRIK" - rsa_private_key = Parser.parse_PRIK i, encryption_key when "SHAR" + raise "private_key must be provided" if !private_key + # After SHAR chunk all the folliwing accounts are enrypted with a new key - key = Parser.parse_SHAR(i, encryption_key, rsa_private_key)[:encryption_key] + key = Parser.parse_SHAR(i, encryption_key, private_key)[:encryption_key] end end accounts end