lib/lastpass/fetcher.rb in lastpass-1.2.1 vs lib/lastpass/fetcher.rb in lastpass-1.3.0
- old
+ new
@@ -6,21 +6,21 @@
def self.login username, password, multifactor_password = nil
key_iteration_count = request_iteration_count username
request_login username, password, key_iteration_count, multifactor_password
end
- def self.fetch session, web_client = HTTParty
+ def self.fetch session, web_client = http
response = web_client.get "https://lastpass.com/getaccts.php?mobile=1&b64=1&hash=0.0&hasplugin=3.0.23&requestsrc=android",
format: :plain,
cookies: {"PHPSESSID" => URI.encode(session.id)}
raise NetworkError unless response.response.is_a? Net::HTTPOK
Blob.new decode_blob(response.parsed_response), session.key_iteration_count
end
- def self.request_iteration_count username, web_client = HTTParty
+ def self.request_iteration_count username, web_client = http
response = web_client.post "https://lastpass.com/iterations.php",
query: {email: username}
raise NetworkError unless response.response.is_a? Net::HTTPOK
@@ -37,11 +37,11 @@
def self.request_login username,
password,
key_iteration_count,
multifactor_password = nil,
- web_client = HTTParty
+ web_client = http
body = {
method: "mobile",
web: 1,
xml: 1,
@@ -127,9 +127,17 @@
salt: password,
iterations: 1,
key_length: 32)
.hex_string
end
+ end
+
+ def self.http
+ @http ||= HTTP
+ end
+
+ def self.http= client
+ @http = client
end
# Can't instantiate Fetcher
private_class_method :new
end