lib/lastpass/vault.rb in lastpass-1.6.1 vs lib/lastpass/vault.rb in lastpass-1.7.0
- old
+ new
@@ -1,11 +1,11 @@
# Copyright (C) 2013 Dmitry Yakimenko (detunized@gmail.com).
# Licensed under the terms of the MIT license. See LICENCE for details.
module LastPass
class Vault
- attr_reader :accounts
+ attr_reader :accounts, :notes
# Fetches a blob from the server and creates a vault
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
@@ -35,36 +35,44 @@
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
+ @accounts, @notes = parse_accounts_and_notes chunks, encryption_key, private_key
end
+ def accounts_and_notes
+ @accounts_and_notes ||= @accounts + @notes
+ end
+
def complete? chunks
!chunks.empty? && chunks.last.id == "ENDM" && chunks.last.payload == "OK"
end
- def parse_accounts chunks, encryption_key, private_key
+ def parse_accounts_and_notes chunks, encryption_key, private_key
accounts = []
+ notes = []
key = encryption_key
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
+ case account
+ when Account
accounts << account
+ when Note
+ notes << account
end
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, private_key)[:encryption_key]
end
end
- accounts
+ [accounts, notes]
end
end
end