6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'spaceship/lib/spaceship/two_step_or_factor_client.rb', line 6
def handle_two_step_or_factor(response)
raise "2FA can only be performed in interactive mode" if ENV["SPACESHIP_ONLY_ALLOW_INTERACTIVE_2FA"] == "true" && ENV["FASTLANE_IS_INTERACTIVE"] == "false"
@x_apple_id_session_id = response["x-apple-id-session-id"]
@scnt = response["scnt"]
r = request(:get) do |req|
req.url("https://idmsa.apple.com/appleauth/auth")
(req)
end
if r.body.kind_of?(Hash) && r.body["trustedDevices"].kind_of?(Array)
handle_two_step(r)
elsif r.body.kind_of?(Hash) && r.body["trustedPhoneNumbers"].kind_of?(Array) && r.body["trustedPhoneNumbers"].first.kind_of?(Hash)
handle_two_factor(r)
else
raise "Although response from Apple indicated activated Two-step Verification or Two-factor Authentication, spaceship didn't know how to handle this response: #{r.body}"
end
end
|