poke-go-api 0.1.7 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62e2737346452ed25a9d5d7844df4a7389fdbd31
4
- data.tar.gz: b7695c8567f9e12971a8e2002f5e4962d4625802
3
+ metadata.gz: e7174fe383036d773b7b7835987f7afe081b430f
4
+ data.tar.gz: f5c36de9678ac660b4b20359f2b5aa3dd797b71b
5
5
  SHA512:
6
- metadata.gz: 507f26d5261a1a5257bb44c1d5c36755a825d33b1ee1ee82a00155a8596adeaec523ac77522ea053779711a4bb4e85ad8c4fd809e9a9c4175693328faba35a2a
7
- data.tar.gz: a9554db26d2c2fce91d246d0dd1ff70d8009f4a2ec9b44c64f9caef53dfb4cf01a842abc4f38d28622f878abbc4d3e9a93b6a5c45ad0da0ec39148df56339f62
6
+ metadata.gz: 54dc83f4ff668d16e0b212070f01a2c4f2c7f377619a8f4f6b02d93b183c3790287f90088ec5d6d0a67d5487177e9724ccc9e65409370fe67bc64ed41f1c3c5a
7
+ data.tar.gz: cf57382065fd8ba7d48933a892c221249840619b87117c2dcaf99364c55cbd15b7b4d72d2e5c52e3068d480d917fc7aa95fba5c9a1d546acda85b095a9db1c2e
@@ -62,7 +62,7 @@ module Poke
62
62
  code: ticket
63
63
  }
64
64
 
65
- resp = URI.decode_www_form(@client.post(PTC_LOGIN_OAUTH, data).body).to_h
65
+ resp = Hash[URI.decode_www_form(@client.post(PTC_LOGIN_OAUTH, data).body)]
66
66
  @access_token = resp['access_token']
67
67
  @expiry = resp['expires'].to_i + Helpers.fetch_time(ms: false)
68
68
  end
@@ -3,7 +3,9 @@ module Poke
3
3
  class Client
4
4
  include Logging
5
5
  attr_accessor :endpoint, :sig_loaded, :refresh_token,
6
- :lat, :lng, :alt, :http_client, :ticket
6
+ :lat, :lng, :alt, :http_client, :ticket,
7
+ :android_gps_info, :sensor_info, :device_info,
8
+ :activity_status, :location_fix
7
9
  attr_reader :sig_path, :auth
8
10
 
9
11
  def initialize
@@ -41,7 +43,7 @@ module Poke
41
43
  begin
42
44
  resp = req.request(@reqs, self)
43
45
  rescue StandardError => ex
44
- raise Errors::UnknownProtoFault, ex
46
+ error(ex)
45
47
  ensure
46
48
  @reqs = []
47
49
  logger.info '[+] Cleaning up RPC requests'
@@ -80,7 +82,11 @@ module Poke
80
82
  private
81
83
 
82
84
  def initialize_ticket
83
- get_hatched_eggs
85
+ mark_tutorial_complete(
86
+ tutorials_completed: [0],
87
+ send_marketing_emails: false,
88
+ send_push_notifications: false
89
+ )
84
90
  call
85
91
  end
86
92
 
@@ -99,6 +105,14 @@ module Poke
99
105
  end
100
106
  end
101
107
 
108
+ def error(ex)
109
+ if Poke::API::Errors.constants.include?(ex.class.to_s.split('::').last.to_sym)
110
+ raise ex.class
111
+ end
112
+
113
+ raise Errors::UnknownProtoFault, ex
114
+ end
115
+
102
116
  def method_missing(method, *args)
103
117
  POGOProtos::Networking::Requests::RequestType.const_get(method.upcase)
104
118
  @reqs << (args.empty? ? method.to_sym.upcase : { method.to_sym.upcase => args.first })
@@ -32,7 +32,7 @@ module Poke
32
32
  end
33
33
 
34
34
  class GoogleTwoFactorAuthenticationFailure < StandardError
35
- def initialize(response)
35
+ def initialize
36
36
  super("Two-factor authentication not supported. Create an app-specific password to log in.")
37
37
  end
38
38
  end
@@ -66,6 +66,12 @@ module Poke
66
66
  super("Level #{level} is invalid, must be between 0 and 30.")
67
67
  end
68
68
  end
69
+
70
+ class ForbiddenAccess < StandardError
71
+ def initialize
72
+ super("Your host is unable to receive a response as it is banned.")
73
+ end
74
+ end
69
75
  end
70
76
  end
71
77
  end
@@ -27,7 +27,7 @@ module Poke
27
27
  def generate_location_two(pos)
28
28
  location_bytes = d2h(pos[0]) + d2h(pos[1]) + d2h(pos[2])
29
29
 
30
- XXhash.xxh32(location_bytes, seed=0x1B845238)
30
+ XXhash.xxh32(location_bytes, 0x1B845238)
31
31
  end
32
32
 
33
33
  def generate_request(auth_ticket, request)
@@ -53,7 +53,7 @@ module Poke
53
53
  next_cell = s2_cell.next
54
54
  prev_cell = s2_cell.prev
55
55
 
56
- radius.times.reduce([s2_cell.id]) do |acc, el|
56
+ radius.times.reduce([s2_cell.id]) do |acc, _|
57
57
  acc += [next_cell.id, prev_cell.id]
58
58
  next_cell = next_cell.next
59
59
  prev_cell = prev_cell.prev
@@ -51,6 +51,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
51
51
  optional :equipped_badge, :message, 12, "POGOProtos.Data.Player.EquippedBadge"
52
52
  optional :contact_settings, :message, 13, "POGOProtos.Data.Player.ContactSettings"
53
53
  repeated :currencies, :message, 14, "POGOProtos.Data.Player.Currency"
54
+ optional :remaining_codename_claims, :int32, 15
54
55
  end
55
56
  add_message "POGOProtos.Data.AssetDigestEntry" do
56
57
  optional :asset_id, :string, 1
@@ -18,12 +18,13 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
18
18
  optional :result, :enum, 1, "POGOProtos.Data.Logs.CatchPokemonLogEntry.Result"
19
19
  optional :pokemon_id, :enum, 2, "POGOProtos.Enums.PokemonId"
20
20
  optional :combat_points, :int32, 3
21
- optional :pokemon_data_id, :uint64, 4
21
+ optional :pokemon_data_id, :fixed64, 4
22
22
  end
23
23
  add_enum "POGOProtos.Data.Logs.CatchPokemonLogEntry.Result" do
24
24
  value :UNSET, 0
25
25
  value :POKEMON_CAPTURED, 1
26
26
  value :POKEMON_FLED, 2
27
+ value :POKEMON_HATCHED, 3
27
28
  end
28
29
  add_message "POGOProtos.Data.Logs.FortSearchLogEntry" do
29
30
  optional :result, :enum, 1, "POGOProtos.Data.Logs.FortSearchLogEntry.Result"
@@ -29,11 +29,11 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
29
29
  optional :guard_pokemon_cp, :int32, 7
30
30
  optional :gym_points, :int64, 10
31
31
  optional :is_in_battle, :bool, 11
32
+ repeated :active_fort_modifier, :enum, 12, "POGOProtos.Inventory.Item.ItemId"
33
+ optional :lure_info, :message, 13, "POGOProtos.Map.Fort.FortLureInfo"
32
34
  optional :cooldown_complete_timestamp_ms, :int64, 14
33
35
  optional :sponsor, :enum, 15, "POGOProtos.Map.Fort.FortSponsor"
34
36
  optional :rendering_type, :enum, 16, "POGOProtos.Map.Fort.FortRenderingType"
35
- optional :active_fort_modifier, :bytes, 12
36
- optional :lure_info, :message, 13, "POGOProtos.Map.Fort.FortLureInfo"
37
37
  end
38
38
  add_message "POGOProtos.Map.Fort.FortLureInfo" do
39
39
  optional :fort_id, :string, 1
@@ -19,6 +19,8 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
19
19
  optional :pokemon_id, :enum, 1, "POGOProtos.Enums.PokemonId"
20
20
  optional :distance_in_meters, :float, 2
21
21
  optional :encounter_id, :fixed64, 3
22
+ optional :fort_id, :string, 4
23
+ optional :fort_image_url, :string, 5
22
24
  end
23
25
  add_message "POGOProtos.Map.Pokemon.MapPokemon" do
24
26
  optional :spawn_point_id, :string, 1
@@ -10,19 +10,20 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
10
10
  add_message "POGOProtos.Networking.Envelopes.Signature" do
11
11
  optional :timestamp_since_start, :uint64, 2
12
12
  repeated :location_fix, :message, 4, "POGOProtos.Networking.Envelopes.Signature.LocationFix"
13
- optional :gps_info, :message, 5, "POGOProtos.Networking.Envelopes.Signature.AndroidGpsInfo"
13
+ optional :android_gps_info, :message, 5, "POGOProtos.Networking.Envelopes.Signature.AndroidGpsInfo"
14
14
  optional :sensor_info, :message, 7, "POGOProtos.Networking.Envelopes.Signature.SensorInfo"
15
15
  optional :device_info, :message, 8, "POGOProtos.Networking.Envelopes.Signature.DeviceInfo"
16
16
  optional :activity_status, :message, 9, "POGOProtos.Networking.Envelopes.Signature.ActivityStatus"
17
- optional :location_hash1, :uint32, 10
18
- optional :location_hash2, :uint32, 20
19
- optional :unknown22, :bytes, 22
17
+ optional :location_hash1, :uint64, 10
18
+ optional :location_hash2, :uint64, 20
19
+ optional :session_hash, :bytes, 22
20
20
  optional :timestamp, :uint64, 23
21
21
  repeated :request_hash, :uint64, 24
22
+ optional :unknown25, :int64, 25
22
23
  end
23
24
  add_message "POGOProtos.Networking.Envelopes.Signature.LocationFix" do
24
25
  optional :provider, :string, 1
25
- optional :timestamp_since_start, :uint64, 2
26
+ optional :timestamp_snapshot, :uint64, 2
26
27
  optional :latitude, :float, 13
27
28
  optional :longitude, :float, 14
28
29
  optional :horizontal_accuracy, :float, 20
@@ -93,6 +93,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
93
93
  optional :player_longitude, :double, 3
94
94
  optional :gym_latitude, :double, 4
95
95
  optional :gym_longitude, :double, 5
96
+ optional :client_version, :string, 6
96
97
  end
97
98
  add_message "POGOProtos.Networking.Requests.Messages.SfidaActionLogMessage" do
98
99
  end
@@ -201,7 +202,6 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
201
202
  optional :hash, :string, 1
202
203
  end
203
204
  add_message "POGOProtos.Networking.Requests.Messages.GetPlayerMessage" do
204
- optional :app_version, :string, 1
205
205
  end
206
206
  add_message "POGOProtos.Networking.Requests.Messages.AddFortModifierMessage" do
207
207
  optional :modifier_type, :enum, 1, "POGOProtos.Inventory.Item.ItemId"
@@ -416,6 +416,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
416
416
  optional :user_message, :string, 2
417
417
  optional :is_assignable, :bool, 3
418
418
  optional :status, :enum, 4, "POGOProtos.Networking.Responses.ClaimCodenameResponse.Status"
419
+ optional :updated_player, :message, 5, "POGOProtos.Data.PlayerData"
419
420
  end
420
421
  add_enum "POGOProtos.Networking.Responses.ClaimCodenameResponse.Status" do
421
422
  value :UNSET, 0
@@ -426,6 +427,15 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
426
427
  value :CODENAME_CHANGE_NOT_ALLOWED, 5
427
428
  end
428
429
  add_message "POGOProtos.Networking.Responses.AddFortModifierResponse" do
430
+ optional :result, :enum, 1, "POGOProtos.Networking.Responses.AddFortModifierResponse.Result"
431
+ optional :fort_details, :message, 2, "POGOProtos.Networking.Responses.FortDetailsResponse"
432
+ end
433
+ add_enum "POGOProtos.Networking.Responses.AddFortModifierResponse.Result" do
434
+ value :NO_RESULT_SET, 0
435
+ value :SUCCESS, 1
436
+ value :FORT_ALREADY_HAS_MODIFIER, 2
437
+ value :TOO_FAR_AWAY, 3
438
+ value :NO_ITEM_IN_INVENTORY, 4
429
439
  end
430
440
  add_message "POGOProtos.Networking.Responses.CatchPokemonResponse" do
431
441
  optional :status, :enum, 1, "POGOProtos.Networking.Responses.CatchPokemonResponse.CatchStatus"
@@ -628,6 +638,7 @@ module POGOProtos
628
638
  ClaimCodenameResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("POGOProtos.Networking.Responses.ClaimCodenameResponse").msgclass
629
639
  ClaimCodenameResponse::Status = Google::Protobuf::DescriptorPool.generated_pool.lookup("POGOProtos.Networking.Responses.ClaimCodenameResponse.Status").enummodule
630
640
  AddFortModifierResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("POGOProtos.Networking.Responses.AddFortModifierResponse").msgclass
641
+ AddFortModifierResponse::Result = Google::Protobuf::DescriptorPool.generated_pool.lookup("POGOProtos.Networking.Responses.AddFortModifierResponse.Result").enummodule
631
642
  CatchPokemonResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("POGOProtos.Networking.Responses.CatchPokemonResponse").msgclass
632
643
  CatchPokemonResponse::CatchStatus = Google::Protobuf::DescriptorPool.generated_pool.lookup("POGOProtos.Networking.Responses.CatchPokemonResponse.CatchStatus").enummodule
633
644
  UseItemReviveResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("POGOProtos.Networking.Responses.UseItemReviveResponse").msgclass
@@ -21,12 +21,19 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
21
21
  optional :deploy_attack_multiplier, :double, 5
22
22
  optional :far_interaction_range_meters, :double, 6
23
23
  end
24
+ add_message "POGOProtos.Settings.GpsSettings" do
25
+ optional :driving_warning_speed_meters_per_second, :float, 1
26
+ optional :driving_warning_cooldown_minutes, :float, 2
27
+ optional :driving_speed_sample_interval_seconds, :float, 3
28
+ optional :driving_speed_sample_count, :int32, 4
29
+ end
24
30
  add_message "POGOProtos.Settings.GlobalSettings" do
25
31
  optional :fort_settings, :message, 2, "POGOProtos.Settings.FortSettings"
26
32
  optional :map_settings, :message, 3, "POGOProtos.Settings.MapSettings"
27
33
  optional :level_settings, :message, 4, "POGOProtos.Settings.LevelSettings"
28
34
  optional :inventory_settings, :message, 5, "POGOProtos.Settings.InventorySettings"
29
35
  optional :minimum_client_version, :string, 6
36
+ optional :gps_settings, :message, 7, "POGOProtos.Settings.GpsSettings"
30
37
  end
31
38
  add_message "POGOProtos.Settings.InventorySettings" do
32
39
  optional :max_pokemon, :int32, 1
@@ -48,6 +55,7 @@ module POGOProtos
48
55
  module Settings
49
56
  MapSettings = Google::Protobuf::DescriptorPool.generated_pool.lookup("POGOProtos.Settings.MapSettings").msgclass
50
57
  FortSettings = Google::Protobuf::DescriptorPool.generated_pool.lookup("POGOProtos.Settings.FortSettings").msgclass
58
+ GpsSettings = Google::Protobuf::DescriptorPool.generated_pool.lookup("POGOProtos.Settings.GpsSettings").msgclass
51
59
  GlobalSettings = Google::Protobuf::DescriptorPool.generated_pool.lookup("POGOProtos.Settings.GlobalSettings").msgclass
52
60
  InventorySettings = Google::Protobuf::DescriptorPool.generated_pool.lookup("POGOProtos.Settings.InventorySettings").msgclass
53
61
  LevelSettings = Google::Protobuf::DescriptorPool.generated_pool.lookup("POGOProtos.Settings.LevelSettings").msgclass
@@ -70,6 +70,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
70
70
  optional :dodge_duration_ms, :int32, 12
71
71
  optional :minimum_player_level, :int32, 13
72
72
  optional :swap_duration_ms, :int32, 14
73
+ optional :dodge_damage_reduction_percent, :float, 15
73
74
  end
74
75
  add_message "POGOProtos.Settings.Master.MoveSettings" do
75
76
  optional :movement_id, :enum, 1, "POGOProtos.Enums.PokemonMove"
@@ -10,7 +10,7 @@ files.each do |file|
10
10
  fopen = File.open(file)
11
11
 
12
12
  new_body = fopen.each_line.map do |x|
13
- if x =~ /require_relative_*pogo/
13
+ if x =~ /require_relative 'pog/i
14
14
  x = x.sub('require', 'require_relative').downcase.tr('.', '_')
15
15
  end
16
16
  x
@@ -64,7 +64,7 @@ module Poke
64
64
  )
65
65
 
66
66
  Signature.load_signature(client) if client.sig_path
67
- Signature.create_signature(req, self) if client.sig_loaded
67
+ Signature.create_signature(req, self, client) if client.sig_loaded
68
68
  end
69
69
 
70
70
  def build_sub_request(req, sub_reqs)
@@ -73,8 +73,6 @@ module Poke
73
73
  append_int_request(req, sub_req)
74
74
  elsif sub_req.is_a?(Hash)
75
75
  append_hash_request(req, sub_req)
76
- else
77
- raise Errors::InvalidRequestEntry, sub_req
78
76
  end
79
77
  end
80
78
  end
@@ -113,7 +111,10 @@ module Poke
113
111
  end
114
112
 
115
113
  def execute_rpc_request(request)
116
- @client.post(@endpoint, request)
114
+ resp = @client.post(@endpoint, request)
115
+ raise Errors::ForbiddenAccess if resp.status == 403
116
+
117
+ resp
117
118
  end
118
119
  end
119
120
  end
@@ -30,18 +30,20 @@ module Poke
30
30
  output.to_str
31
31
  end
32
32
 
33
- def self.create_signature(req, client)
33
+ def self.create_signature(req, req_client, api_client)
34
34
  signature = POGOProtos::Networking::Envelopes::Signature.new(
35
- location_hash1: Helpers.generate_location_one(req.auth_ticket.to_proto, client.position),
36
- location_hash2: Helpers.generate_location_two(client.position),
37
- unknown22: SecureRandom.random_bytes(32),
35
+ location_hash1: Helpers.generate_location_one(req.auth_ticket.to_proto, req_client.position),
36
+ location_hash2: Helpers.generate_location_two(req_client.position),
37
+ unknown25: -8537042734809897855,
38
38
  timestamp: Helpers.fetch_time,
39
- timestamp_since_start: Helpers.fetch_time - client.start_time
39
+ timestamp_since_start: Helpers.fetch_time - req_client.start_time
40
40
  )
41
41
 
42
42
  add_requests(req, signature)
43
+ add_optional_signature_information(signature, api_client)
43
44
 
44
- logger.debug "[+] Generated Signature \r\n#{signature.to_proto.inspect}"
45
+ logger.debug "[+] Generated Signature \r\n#{signature.inspect}"
46
+ logger.debug "[+] Generated Protobuf Signature \r\n#{signature.to_proto.inspect}"
45
47
  add_unknown6(req, signature)
46
48
  end
47
49
 
@@ -60,6 +62,22 @@ module Poke
60
62
  )
61
63
  end
62
64
 
65
+ def self.add_optional_signature_information(sig, api_client)
66
+ %i(android_gps_info sensor_info device_info activity_status location_fix).each do |i|
67
+ name = Helpers.camel_case_lower(i)
68
+
69
+ if api_client.send(i)
70
+ message = add_optional_information(name, api_client.send(i))
71
+ i == :location_fix ? (sig.send(i) << message) : sig.send("#{i.to_s}=", message)
72
+ end
73
+ end
74
+ end
75
+
76
+ def self.add_optional_information(name, client_info)
77
+ info_class = POGOProtos::Networking::Envelopes::Signature.const_get(name)
78
+ info_class.new(client_info)
79
+ end
80
+
63
81
  private_class_method :add_requests, :add_unknown6
64
82
  end
65
83
  end
@@ -25,19 +25,24 @@ require_relative 'pogoprotos/pogoprotos_networking_requests_messages'
25
25
  require_relative 'pogoprotos/pogoprotos_networking_responses'
26
26
  OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
27
27
 
28
- #Poke::API::Logging.log_level = :DEBUG
28
+ Poke::API::Logging.log_level = :DEBUG
29
29
  client = Poke::API::Client.new
30
30
  #client.refresh_token = "1/QyOAeM7043LCkvyFfm61MXWV9UOBPutLwuLbjePhqPw"
31
31
  client.activate_signature('C:\encrypt64bit.dll')
32
32
  client.store_location('Glasgow')
33
- client.login('sof2er@gmail.com', 'kidureallypwnme', 'google')
33
+ client.login('srn720', 'illi0wnz', 'ptc')
34
+
35
+
36
+ client.location_fix = {provider: 'foo'}
37
+ client.android_gps_info = {satellites_prn: [1]}
38
+ client.sensor_info = {magnetometer_x: 1.2}
39
+ client.device_info = {device_model: 'some-device'}
40
+ client.activity_status = {cycling: false}
34
41
 
35
- client.get_player
36
- client.call
37
42
  #Get cells
38
43
  cell_ids = Poke::API::Helpers.get_cells(client.lat, client.lng)
39
44
 
40
- # Construct map objects call
45
+ #Construct map objects call
41
46
  client.get_map_objects(
42
47
  latitude: client.lat,
43
48
  longitude: client.lng,
@@ -1,5 +1,5 @@
1
1
  module Poke
2
2
  module API
3
- VERSION = '0.1.7'.freeze
3
+ VERSION = '0.2.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poke-go-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nabeel Amjad
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-10 00:00:00.000000000 Z
11
+ date: 2016-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient