diff --git a/POGOProtos/Data/Logs/CatchPokemonLogEntry.proto b/POGOProtos/Data/Logs/CatchPokemonLogEntry.proto index e1d193b..08d8126 100644 --- a/POGOProtos/Data/Logs/CatchPokemonLogEntry.proto +++ b/POGOProtos/Data/Logs/CatchPokemonLogEntry.proto @@ -7,11 +7,12 @@ message CatchPokemonLogEntry { .POGOProtos.Data.Logs.CatchPokemonLogEntry.Result result = 1; .POGOProtos.Enums.PokemonId pokemon_id = 2; int32 combat_points = 3; - uint64 pokemon_data_id = 4; + fixed64 pokemon_data_id = 4; enum Result { UNSET = 0; POKEMON_CAPTURED = 1; POKEMON_FLED = 2; + POKEMON_HATCHED = 3; } } \ No newline at end of file diff --git a/POGOProtos/Data/PlayerData.proto b/POGOProtos/Data/PlayerData.proto index 43503bc..ed6249f 100644 --- a/POGOProtos/Data/PlayerData.proto +++ b/POGOProtos/Data/PlayerData.proto @@ -21,4 +21,5 @@ message PlayerData { .POGOProtos.Data.Player.EquippedBadge equipped_badge = 12; .POGOProtos.Data.Player.ContactSettings contact_settings = 13; repeated .POGOProtos.Data.Player.Currency currencies = 14; + int32 remaining_codename_claims = 15; } diff --git a/POGOProtos/Map/Fort/FortData.proto b/POGOProtos/Map/Fort/FortData.proto index 2d550b5..bca9b69 100644 --- a/POGOProtos/Map/Fort/FortData.proto +++ b/POGOProtos/Map/Fort/FortData.proto @@ -3,6 +3,7 @@ package POGOProtos.Map.Fort; import "POGOProtos/Enums/PokemonId.proto"; import "POGOProtos/Enums/TeamColor.proto"; +import "POGOProtos/Inventory/Item/ItemId.proto"; import "POGOProtos/Map/Fort/FortType.proto"; import "POGOProtos/Map/Fort/FortSponsor.proto"; import "POGOProtos/Map/Fort/FortRenderingType.proto"; @@ -32,14 +33,12 @@ message FortData { bool is_in_battle = 11; //// Fields related to pokestops only + repeated .POGOProtos.Inventory.Item.ItemId active_fort_modifier = 12; + .POGOProtos.Map.Fort.FortLureInfo lure_info = 13; // Timestamp when the pokestop can be activated again to get items / xp int64 cooldown_complete_timestamp_ms = 14; .POGOProtos.Map.Fort.FortSponsor sponsor = 15; .POGOProtos.Map.Fort.FortRenderingType rendering_type = 16; - - // Might represent the type of item applied to the pokestop, right now only lures can be applied - bytes active_fort_modifier = 12; - .POGOProtos.Map.Fort.FortLureInfo lure_info = 13; } diff --git a/POGOProtos/Map/Pokemon/NearbyPokemon.proto b/POGOProtos/Map/Pokemon/NearbyPokemon.proto index c0b8ac6..d7689e7 100644 --- a/POGOProtos/Map/Pokemon/NearbyPokemon.proto +++ b/POGOProtos/Map/Pokemon/NearbyPokemon.proto @@ -4,9 +4,9 @@ package POGOProtos.Map.Pokemon; import "POGOProtos/Enums/PokemonId.proto"; message NearbyPokemon { - .POGOProtos.Enums.PokemonId pokemon_id = 1; - float distance_in_meters = 2; - fixed64 encounter_id = 3; - string fort_id = 4; - string fort_image_url = 5; -} \ No newline at end of file + .POGOProtos.Enums.PokemonId pokemon_id = 1; + float distance_in_meters = 2; + fixed64 encounter_id = 3; + string fort_id = 4; + string fort_image_url = 5; +} diff --git a/POGOProtos/Networking/Envelopes/Signature.proto b/POGOProtos/Networking/Envelopes/Signature.proto index 2bb9f21..a11e004 100644 --- a/POGOProtos/Networking/Envelopes/Signature.proto +++ b/POGOProtos/Networking/Envelopes/Signature.proto @@ -5,7 +5,7 @@ message Signature { message LocationFix { string provider = 1; // "network", "gps", "fused", possibly others - uint64 timestamp_since_start = 2; // in ms + uint64 timestamp_snapshot = 2; // in ms since start float latitude = 13; float longitude = 14; @@ -34,7 +34,7 @@ message Signature { } message SensorInfo { - uint64 timestamp_snapshot = 1; // in ms + uint64 timestamp_snapshot = 1; // in ms since start double magnetometer_x = 3; double magnetometer_y = 4; double magnetometer_z = 5; @@ -69,6 +69,7 @@ message Signature { string firmware_fingerprint = 14; // Android only, build.fingerprint } + // Only used in iOS - Android just sends an empty version message ActivityStatus { // all of these had 1 as their value uint64 start_time_ms = 1; @@ -88,14 +89,11 @@ message Signature { SensorInfo sensor_info = 7; DeviceInfo device_info = 8; ActivityStatus activity_status = 9; - uint32 location_hash1 = 10; // Location1 hashed based on the auth_token - xxHash32 - uint32 location_hash2 = 20; // Location2 hashed based on the auth_token - xxHash32 - bytes unknown22 = 22; // possibly replay check. Generation unknown but pointed to by 0001B8614 + uint64 location_hash1 = 10; // Location1 hashed signed based on the auth_token or auth_info - xxHash32 + uint64 location_hash2 = 20; // Location2 hashed (unsigned) - xxHash32 + bytes session_hash = 22; // 16 bytes, unique per session uint64 timestamp = 23; // epoch timestamp in ms - repeated uint64 request_hash = 24; // hashes of each request message in a hashArray - xxhash64 - - // Addresses for the corresponding hash functions: - // xxHash32 00054D28 - // xxhash64 000546C8 - Feeds into 00053D40 + repeated int64 request_hash = 24; // hashes of each request message in a hashArray signed based on the auth_token or auth_info - xxhash64 + int64 unknown25 = 25; // for 0.33 its static -8537042734809897855 or 0x898654dd2753a481, generated via xxHash64("\"b8fa9757195897aae92c53dbcf8a60fb3d86d745\"".ToByteArray(), 0x88533787) } diff --git a/POGOProtos/Networking/Envelopes/Unknown6.proto b/POGOProtos/Networking/Envelopes/Unknown6.proto index 69f419a..1ed599e 100644 --- a/POGOProtos/Networking/Envelopes/Unknown6.proto +++ b/POGOProtos/Networking/Envelopes/Unknown6.proto @@ -7,6 +7,6 @@ message Unknown6 { message Unknown2 { bytes encrypted_signature = 1; // This are the bytes of POGOProtos/Networking/Envelopes/Signature.proto encrypted. - // For an example check https://github.com/keyphact/pgoapi/blob/75eba6b5b630841ee4f7c2ea983f15874fb0862d/pgoapi/rpc_api.py#L192-L212 + // For an example check https://github.com/keyphact/pgoapi/blob/75eba6b5b630841ee4f7c2ea983f15874fb0862d/pgoapi/rpc_api.py#L192-L212 } } diff --git a/POGOProtos/Networking/Requests/Messages/GetGymDetailsMessage.proto b/POGOProtos/Networking/Requests/Messages/GetGymDetailsMessage.proto index 2a84254..01b6afc 100644 --- a/POGOProtos/Networking/Requests/Messages/GetGymDetailsMessage.proto +++ b/POGOProtos/Networking/Requests/Messages/GetGymDetailsMessage.proto @@ -7,4 +7,5 @@ message GetGymDetailsMessage { double player_longitude = 3; double gym_latitude = 4; double gym_longitude = 5; + string client_version = 6; } diff --git a/POGOProtos/Networking/Requests/Messages/GetPlayerMessage.proto b/POGOProtos/Networking/Requests/Messages/GetPlayerMessage.proto index ce14965..d09eba0 100644 --- a/POGOProtos/Networking/Requests/Messages/GetPlayerMessage.proto +++ b/POGOProtos/Networking/Requests/Messages/GetPlayerMessage.proto @@ -2,6 +2,4 @@ syntax = "proto3"; package POGOProtos.Networking.Requests.Messages; message GetPlayerMessage { - // Human readable app version, e.g. "0.31.1" - string app_version = 1; } diff --git a/POGOProtos/Networking/Responses/AddFortModifierResponse.proto b/POGOProtos/Networking/Responses/AddFortModifierResponse.proto index cffb327..5cc76f6 100644 --- a/POGOProtos/Networking/Responses/AddFortModifierResponse.proto +++ b/POGOProtos/Networking/Responses/AddFortModifierResponse.proto @@ -1,6 +1,17 @@ syntax = "proto3"; package POGOProtos.Networking.Responses; +import "POGOProtos/Networking/Responses/FortDetailsResponse.proto"; + message AddFortModifierResponse { - // Initialized by assist.py + .POGOProtos.Networking.Responses.AddFortModifierResponse.Result result = 1; + .POGOProtos.Networking.Responses.FortDetailsResponse fort_details = 2; + + enum Result { + NO_RESULT_SET = 0; + SUCCESS = 1; + FORT_ALREADY_HAS_MODIFIER = 2; + TOO_FAR_AWAY = 3; + NO_ITEM_IN_INVENTORY = 4; + } } diff --git a/POGOProtos/Networking/Responses/ClaimCodenameResponse.proto b/POGOProtos/Networking/Responses/ClaimCodenameResponse.proto index 686d4ff..962644d 100644 --- a/POGOProtos/Networking/Responses/ClaimCodenameResponse.proto +++ b/POGOProtos/Networking/Responses/ClaimCodenameResponse.proto @@ -1,12 +1,14 @@ syntax = "proto3"; package POGOProtos.Networking.Responses; -// TODO: Might be incorrect, please test. +import "POGOProtos/Data/PlayerData.proto"; + message ClaimCodenameResponse { string codename = 1; string user_message = 2; bool is_assignable = 3; .POGOProtos.Networking.Responses.ClaimCodenameResponse.Status status = 4; + .POGOProtos.Data.PlayerData updated_player = 5; enum Status { UNSET = 0; diff --git a/POGOProtos/Settings/GlobalSettings.proto b/POGOProtos/Settings/GlobalSettings.proto index 215379a..f758e91 100644 --- a/POGOProtos/Settings/GlobalSettings.proto +++ b/POGOProtos/Settings/GlobalSettings.proto @@ -5,6 +5,7 @@ import "POGOProtos/Settings/FortSettings.proto"; import "POGOProtos/Settings/MapSettings.proto"; import "POGOProtos/Settings/LevelSettings.proto"; import "POGOProtos/Settings/InventorySettings.proto"; +import "POGOProtos/Settings/GpsSettings.proto"; message GlobalSettings { .POGOProtos.Settings.FortSettings fort_settings = 2; @@ -12,4 +13,5 @@ message GlobalSettings { .POGOProtos.Settings.LevelSettings level_settings = 4; .POGOProtos.Settings.InventorySettings inventory_settings = 5; string minimum_client_version = 6; + .POGOProtos.Settings.GpsSettings gps_settings = 7; } diff --git a/POGOProtos/Settings/GpsSettings.proto b/POGOProtos/Settings/GpsSettings.proto new file mode 100644 index 0000000..36eccf0 --- /dev/null +++ b/POGOProtos/Settings/GpsSettings.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; +package POGOProtos.Settings; + +message GpsSettings { + float driving_warning_speed_meters_per_second = 1; + float driving_warning_cooldown_minutes = 2; + float driving_speed_sample_interval_seconds = 3; + int32 driving_speed_sample_count = 4; +} diff --git a/POGOProtos/Settings/Master/GymBattleSettings.proto b/POGOProtos/Settings/Master/GymBattleSettings.proto index 695e676..2cd4bb7 100644 --- a/POGOProtos/Settings/Master/GymBattleSettings.proto +++ b/POGOProtos/Settings/Master/GymBattleSettings.proto @@ -16,4 +16,5 @@ message GymBattleSettings { int32 dodge_duration_ms = 12; int32 minimum_player_level = 13; int32 swap_duration_ms = 14; + float dodge_damage_reduction_percent = 15; } diff --git a/README.md b/README.md index 2dee965..0e9d24a 100644 --- a/README.md +++ b/README.md @@ -44,4 +44,11 @@ You need a running mongodb service, enter your credentials into ``./cfg.js``. If everything went fine, it should look like: -![Preview](http://image.prntscr.com/image/6ce92058147b4067b8027c42258a198c.png "") \ No newline at end of file +![Preview](http://image.prntscr.com/image/6ce92058147b4067b8027c42258a198c.png "") + +## Todo + - Viewing a pokemon shows invalid data (wrong weight, height, type etc.) + - Transfer button doesnt trigger (maybe related to above?) + - Items doesnt show + - Pokemon models get downloaded correctly, but somehow they dont load properly. They show on map, but not in pokemon info screen, pokedex or while encountering. + - Players exp bar is bugged, proto related? \ No newline at end of file diff --git a/cfg.js b/cfg.js index 3b7694c..a79ed8f 100644 --- a/cfg.js +++ b/cfg.js @@ -6,9 +6,11 @@ export const SERVER_SAVE_INTERVAL = 1e3 * 60; // 1min export const SERVER_MAX_CONNECTIONS = 64; export const SERVER_PLAYER_CONNECTION_TIMEOUT = 1e3 * 60 * 30; // 30min +export const SERVER_LOG_REQUESTS = true; + export const SERVER_DEFAULT_CONSOLE_COLOR = 32; -export const ASSET_DIGEST_PATH = "asset_digest"; +export const ASSET_DIGEST_PATH = "0005368950BD6068_ASSET_DIGEST"; export const MINIMUM_CLIENT_VERSION = "0.33.0"; @@ -18,4 +20,7 @@ export const SERVER_MONGO_DB_NAME = "pokemongo"; export const SERVER_MONGO_COLLECTION_USERS = "users"; export const SERVER_MONGO_URL = `mongodb://${SERVER_MONGO_HOST_IP}:${SERVER_MONGO_PORT}/${SERVER_MONGO_DB_NAME}`; -export const SERVER_GMAPS_API_KEY = "AIzaSyDF9rkP8lhcddBtvH9gVFzjnNo13WtmJIM"; \ No newline at end of file +export const SERVER_GMAPS_API_KEY = "AIzaSyDF9rkP8lhcddBtvH9gVFzjnNo13WtmJIM"; + +export const SERVER_POGO_CLIENT_USERNAME = "USERNAME"; +export const SERVER_POGO_CLIENT_PASSWORD = "PASSWORD"; \ No newline at end of file diff --git a/src/cycle.js b/src/cycle.js index b620613..89f7209 100644 --- a/src/cycle.js +++ b/src/cycle.js @@ -49,7 +49,7 @@ export function resetTimers() { this.saveTick++; // Save interval if (this.saveTick >= CFG.SERVER_SAVE_INTERVAL) { - this.savePlayers(); + this.saveAllPlayers(); this.saveTick = 0; } return void 0; diff --git a/src/database.js b/src/database.js index 4523c06..7e6ee78 100644 --- a/src/database.js +++ b/src/database.js @@ -2,20 +2,19 @@ import mongodb from "mongodb"; import * as CFG from "../cfg"; -/** - * @param {Function} resolve - */ -export function setupMongo(resolve) { +export function setupMongo() { - mongodb.MongoClient.connect(CFG.SERVER_MONGO_URL, (error, db) => { - if (error) { - this.print("Unable to connect to database", 31); - } else { - this.db.instance = db; - this.loadCollection(CFG.SERVER_MONGO_COLLECTION_USERS).then(() => { - resolve(); - }); - } + return new Promise((resolve) => { + mongodb.MongoClient.connect(CFG.SERVER_MONGO_URL, (error, db) => { + if (error) { + this.print("Unable to connect to database", 31); + } else { + this.db.instance = db; + this.loadCollection(CFG.SERVER_MONGO_COLLECTION_USERS).then(() => { + resolve(); + }); + } + }); }); } @@ -70,7 +69,9 @@ export function createUser(obj) { stardust: obj.stardust, pokecoins: obj.pokecoins, avatar: obj.avatar, - contact_settings: obj.contact_settings + team: obj.team, + contact_settings: obj.contact_settings, + tutorial_state: obj.tutorial_state }; return new Promise((resolve) => { @@ -93,7 +94,9 @@ export function updateUser(obj) { stardust: obj.stardust, pokecoins: obj.pokecoins, avatar: obj.avatar, - contact_settings: obj.contact_settings + team: obj.team, + contact_settings: obj.contact_settings, + tutorial_state: obj.tutorial_state }; return new Promise((resolve) => { diff --git a/src/index.js b/src/index.js index 2f4e052..664f603 100644 --- a/src/index.js +++ b/src/index.js @@ -3,12 +3,13 @@ import http from "http"; import proto from "./proto"; import { - inherit, - decodeLong + inherit } from "./utils"; import * as CFG from "../cfg"; +import pogodown from "pogo-asset-downloader"; + import * as _setup from "./setup"; import * as _cycle from "./cycle"; import * as _player from "./player"; @@ -62,7 +63,7 @@ class GameServer { clientAlreadyConnected(client) { - let remoteAddress = client.connection.remoteAddress; + let remoteAddress = client.headers.host; let ii = 0, length = this.clients.length; @@ -76,14 +77,45 @@ class GameServer { } + createAssetDownloadSession() { + + return new Promise((resolve) => { + pogodown.login({ + username: CFG.SERVER_POGO_CLIENT_USERNAME, + password: CFG.SERVER_POGO_CLIENT_PASSWORD, + downloadModels: false + }).then(() => { + resolve(); + }); + }); + + } + + /** + * @param {Array} assets + */ + generateDownloadUrlByAssetId(assets) { + return new Promise((resolve) => { + pogodown.getAssetByAssetId(assets).then((response) => { + // maybe cache and provide own local download link? + resolve(response); + }); + }); + } + /** * @return {HTTP} */ createHTTPServer() { let server = http.createServer((req, res) => { + if (this.clients.length >= CFG.SERVER_MAX_CONNECTIONS) { + this.print(`Server is full! Refused ${req.headers.host}`, 31); + return void 0; + } this.response = res; + // client already connected if (!this.clientAlreadyConnected(req)) { - this.addPlayer(req.connection); + this.addPlayer(req); } let chunks = []; req.on("data", (chunk) => { @@ -93,7 +125,7 @@ class GameServer { let buffer = Buffer.concat(chunks); req.body = buffer; this.request = req; - this.onRequest(req, res); + this.routeRequest(req, res); }); }); server.listen(CFG.SERVER_PORT); @@ -106,7 +138,7 @@ class GameServer { */ print(msg, color) { color = Number.isInteger(color) ? color : CFG.SERVER_DEFAULT_CONSOLE_COLOR; - console.log(`\x1b[${color};1m${msg}\x1b[0m`); + console.log(`[Console] \x1b[${color};1m${msg}\x1b[0m`); } greet() { diff --git a/src/modes/default_player.json b/src/modes/default_player.json new file mode 100644 index 0000000..1f8ab38 --- /dev/null +++ b/src/modes/default_player.json @@ -0,0 +1,9 @@ +{ + "exp": 0, + "level": 5, + "stardust": 1000, + "pokecoins": 0, + "team": 0, + "items": [], + "pokemons": [] +} \ No newline at end of file diff --git a/src/modes/global_settings.json b/src/modes/global_settings.json new file mode 100644 index 0000000..e69de29 diff --git a/src/packets/Responses.CheckAwardedBadges.js b/src/packets/Responses.CheckAwardedBadges.js index 61c0bf8..5e8bbdf 100644 --- a/src/packets/Responses.CheckAwardedBadges.js +++ b/src/packets/Responses.CheckAwardedBadges.js @@ -10,7 +10,9 @@ export default function CheckAwardedBadges(obj) { return ( new proto.Networking.Responses.CheckAwardedBadgesResponse({ - success: true + success: true, + awarded_badges: [], + awarded_badge_levels: [] }).encode() ); diff --git a/src/packets/Responses.ClaimCodeName.js b/src/packets/Responses.ClaimCodeName.js new file mode 100644 index 0000000..f23326f --- /dev/null +++ b/src/packets/Responses.ClaimCodeName.js @@ -0,0 +1,25 @@ +import proto from "../proto"; + +import { GetPlayer } from "./"; + +/** + * @param {Request} req + * @param {Player} player + * @return {Object} + */ +export default function ClaimCodeName(req, player) { + + let data = proto.Networking.Requests.Messages.ClaimCodenameMessage.decode(req.request_message.toBuffer()); + + player.username = data.codename; + + return ( + new proto.Networking.Responses.ClaimCodenameResponse({ + codename: data.codename, + user_message: data.codename, + is_assignable: true, + status: 1 + }).encode() + ); + +} \ No newline at end of file diff --git a/src/packets/Responses.DownloadRemoteConfigVersion.js b/src/packets/Responses.DownloadRemoteConfigVersion.js index 8551461..749b4b7 100644 --- a/src/packets/Responses.DownloadRemoteConfigVersion.js +++ b/src/packets/Responses.DownloadRemoteConfigVersion.js @@ -9,8 +9,8 @@ export default function DownloadRemoteConfigVersion(obj) { return ( new proto.Networking.Responses.DownloadRemoteConfigVersionResponse({ result: 1, - item_templates_timestamp_ms: 1468540960537, - asset_digest_timestamp_ms: 1467338276561000 + item_templates_timestamp_ms: new Date().getTime() * 1e3, + asset_digest_timestamp_ms: new Date().getTime() * 1e3 }).encode() ); diff --git a/src/packets/Responses.DownloadSettings.js b/src/packets/Responses.DownloadSettings.js index 5dc785c..6dbc4da 100644 --- a/src/packets/Responses.DownloadSettings.js +++ b/src/packets/Responses.DownloadSettings.js @@ -10,30 +10,37 @@ export default function DownloadSettings(obj) { return ( new proto.Networking.Responses.DownloadSettingsResponse({ - hash: "54b359c97e46900f87211ef6e6dd0b7f2a3ea1f5", + hash: "2788184af4004004d6ab0740f7632983332106f6", settings: new proto.Settings.GlobalSettings({ fort_settings: new proto.Settings.FortSettings({ - interaction_range_meters: 40, - max_total_deployed_pokemon: 10, - max_player_deployed_pokemon: 1, - deploy_stamina_multiplier: 2, - far_interaction_range_meters: 1000 + "interaction_range_meters": 40.25098039215686, + "max_total_deployed_pokemon": 10, + "max_player_deployed_pokemon": 1, + "deploy_stamina_multiplier": 8.062745098039215, + "deploy_attack_multiplier": 0, + "far_interaction_range_meters": 1000.0156862745098 }), map_settings: new proto.Settings.MapSettings({ - pokemon_visible_range: 70, - poke_nav_range_meters: 751, - encounter_range_meters: 50, - get_map_objects_min_refresh_seconds: 10, - get_map_objects_max_refresh_seconds: 30, - get_map_objects_min_distance_meters: 10, - google_maps_api_key: CFG.SERVER_GMAPS_API_KEY + "pokemon_visible_range": 70.00196078431372, + "poke_nav_range_meters": 751.0156862745098, + "encounter_range_meters": 50.25098039215686, + "get_map_objects_min_refresh_seconds": 10.007843017578125, + "get_map_objects_max_refresh_seconds": 30.01568603515625, + "get_map_objects_min_distance_meters": 10.007843017578125, + "google_maps_api_key": CFG.SERVER_GMAPS_API_KEY }), inventory_settings: new proto.Settings.InventorySettings({ - max_pokemon: 1000, - max_bag_items: 1000, - base_pokemon: 250, - base_bag_items: 350, - base_eggs: 9 + "max_pokemon": 1000, + "max_bag_items": 1000, + "base_pokemon": 250, + "base_bag_items": 350, + "base_eggs": 9 + }), + gps_settings: new proto.Settings.GpsSettings({ + driving_warning_speed_meters_per_second: 10, + driving_warning_cooldown_minutes: 0, + driving_speed_sample_interval_seconds: 0, + driving_speed_sample_count: 0 }), minimum_client_version: CFG.MINIMUM_CLIENT_VERSION }) diff --git a/src/packets/Responses.Encounter.js b/src/packets/Responses.Encounter.js index 7579bb1..2c4d596 100644 --- a/src/packets/Responses.Encounter.js +++ b/src/packets/Responses.Encounter.js @@ -10,46 +10,68 @@ import { decodeLong } from "../utils"; */ export default function Encounter(req) { - let data = proto.Networking.Requests.Messages.EncounterMessage.decode(req.request_message.toBuffer()); - - let encounter_id = decodeLong( - data.encounter_id.high, data.encounter_id.low, data.encounter_id.unsigned - ); + let id = decodeLong({ + "low": 0, + "high": 0, + "unsigned": true + }); return ( new proto.Networking.Responses.EncounterResponse({ - wild_pokemon: new proto.Map.Pokemon.WildPokemon({ - encounter_id: 11810991820755313517, - last_modified_timestamp_ms: 1470787552996, - latitude: 39.19047143172622, - longitude: -96.58502161502839, - spawn_point_id: "87bdd289c69", - pokemon_data: new proto.Data.PokemonData({ - pokemon_id: 19, - cp: 277, - stamina: 41, - stamina_max: 41, - move_1: 221, - move_2: 26, - height_m: 0.22802678267819977, - weight_kg: 1.3452539511871338, - individual_attack: 9, - individual_defense: 13, - individual_stamina: 14, - cp_multiplier: 0.5663545199394226 + wild_pokemon: new proto.Map.Pokemon.WildPokemon({ + encounter_id: decodeLong({ + "low": -1477718883, + "high": -1178282273, + "unsigned": true }), - time_till_hidden_ms: 730176 + last_modified_timestamp_ms: decodeLong({ + "low": 2047340539, + "high": 342, + "unsigned": false + }), + latitude: 39.19071817474392, + longitude: -96.58505386390713, + spawn_point_id: "87bdcd8e959", + pokemon_data: new proto.Data.PokemonData({ + id: id, + pokemon_id: 17, + cp: 48, + stamina: 22, + stamina_max: 22, + move_1: 210, + move_2: 45, + deployed_fort_id: "", + owner_name: "", + is_egg: false, + egg_km_walked_target: 0, + egg_km_walked_start: 0, + origin: 0, + height_m: 0.8371214866638184, + weight_kg: 19.039264678955078, + individual_attack: 6, + individual_defense: 12, + individual_stamina: 7, + cp_multiplier: 0.16639786958694458, + pokeball: 0, + captured_cell_id: id, + battles_attacked: 0, + battles_defended: 0, + egg_incubator_id: "", + creation_time_ms: id, + num_upgrades: 0, + additional_cp_multiplier: 0, + favorite: 0, + nickname: "", + from_fort: 0 + }), + time_till_hidden_ms: 336009 }), - background: proto.Networking.Responses.EncounterResponse.Background.PARK, - status: proto.Networking.Responses.EncounterResponse.Status.ENCOUNTER_SUCCESS, + background: 0, + status: 1, capture_probability: new proto.Data.Capture.CaptureProbability({ pokeball_type: [1, 2, 3], - capture_probability: [ - 0.352886438369751, - 0.47944003343582153, - 0.5812440514564514 - ], - reticle_difficulty_scale: 2 + capture_probability: [0.6009692549705505, 0.7479367256164551, 0.8407744765281677], + reticle_difficulty_scale: 0 }) }).encode() ); diff --git a/src/packets/Responses.GetAssetDigest.js b/src/packets/Responses.GetAssetDigest.js index 2e74ddf..83cf017 100644 --- a/src/packets/Responses.GetAssetDigest.js +++ b/src/packets/Responses.GetAssetDigest.js @@ -6,10 +6,10 @@ import * as CFG from "../../cfg"; let asset = fs.readFileSync(CFG.ASSET_DIGEST_PATH); /** - * @param {Object} obj + * @param {Request} req * @return {Object} */ -export default function GetAssetDigest(obj) { +export default function GetAssetDigest(req) { return (asset); diff --git a/src/packets/Responses.GetDownloadUrls.js b/src/packets/Responses.GetDownloadUrls.js index e1a81d6..ed69c92 100644 --- a/src/packets/Responses.GetDownloadUrls.js +++ b/src/packets/Responses.GetDownloadUrls.js @@ -2,24 +2,42 @@ import proto from "../proto"; import DownloadUrlEntry from "./Data.DownloadUrlEntry"; +import { + getDownloadUrlByAssetId +} from "../utils.js"; + /** * @return {Object} */ -export default function GetDownloadUrls() { +export default function GetDownloadUrls(req, download) { - let download_urls = [ - DownloadUrlEntry({ - asset_id: "9649e04b-ccd8-4b1c-b066-cc75ed4c0976/1467338147687000", - url: "https://storage.googleapis.com/cloud_assets_pgorelease/bundles/android/pm0101?generation=1467338147687000&GoogleAccessId=pgorelease-service-account@pgorelease.iam.gserviceaccount.com&Expires=1469970173&Signature=CY4YbWipMVMUzyDgHGceoo2NO429spFyH39p%2FSMltBlQOBYLcRD8panRgTH8tuMc3uB65rtp613IkGwUMaMMXx40v0NBECEsRXcggYxYluO2k4waShMyOmWHOomMPKwGXg5ot93wLH6aXFwv0%2FD%2FUaqZDrJYJ9bMRcsF2KlPPy363XbrbcSCcT19otqU3D9yjWU1mDbzRy9yZRqmaCu%2FPtWHKKWnUKiN2f2UqL8Gbulex8BDpm4OKf4lXnOwAKYDpcAMph%2FC3LKVhvoRuryzPRJgXojb1CvfHaY0svUFoKq0N%2FuFl9hzR8RAVLsAPaD%2FpKuql4BUm%2BZtoc%2BWi0lQXA%3D%3D", - size: 169205, - checksum: 0xbe30d925 - }) - ]; + let data = proto.Networking.Requests.Messages.GetDownloadUrlsMessage.decode(req.request_message.toBuffer()); - return ( - new proto.Networking.Responses.GetDownloadUrlsResponse({ - download_urls: download_urls - }).encode() - ); + let key = data.asset_id[0]; + + let download_urls = []; + + let obj = getDownloadUrlByAssetId(key); + + return new Promise((resolve) => { + + download(key).then((asset) => { + download_urls.push( + new proto.Data.DownloadUrlEntry({ + url: asset[0].asset, + asset_id: key, + size: obj.size, + checksum: obj.checksum + }) + ); + let output = ( + new proto.Networking.Responses.GetDownloadUrlsResponse({ + download_urls: download_urls + }).encode() + ); + resolve(output); + }); + + }); } \ No newline at end of file diff --git a/src/packets/Responses.GetInventory.js b/src/packets/Responses.GetInventory.js index df75b67..ddfc8a3 100644 --- a/src/packets/Responses.GetInventory.js +++ b/src/packets/Responses.GetInventory.js @@ -13,21 +13,39 @@ export default function GetInventoryData(obj) { success: true, inventory_delta: new proto.Inventory.InventoryDelta({ inventory_items: [ - // player stats new proto.Inventory.InventoryItem({ - inventory_item_data: new proto.Inventory.InventoryItemData({ + "modified_timestamp_ms": new Date().getTime() * 1e3, + "inventory_item_data": new proto.Inventory.InventoryItemData({ + "candy": new proto.Inventory.Candy({ + "family_id": 48, + "candy": 3 + }) + }) + }), + new proto.Inventory.InventoryItem({ + "modified_timestamp_ms": new Date().getTime() * 1e3, + "inventory_item_data": new proto.Inventory.InventoryItemData({ + "candy": new proto.Inventory.Candy({ + "family_id": 16, + "candy": 3 + }) + }) + }), + new proto.Inventory.InventoryItem({ + "modified_timestamp_ms": new Date().getTime() * 1e3, + "inventory_item_data": new proto.Inventory.InventoryItemData({ "player_stats": new proto.Data.Player.PlayerStats({ - "level": 98, - "experience": 2000, - "prev_level_xp": 1000, - "next_level_xp": 6000, - "km_walked": 0.55459213256836, - "pokemons_encountered": 1, - "unique_pokedex_entries": 1, - "pokemons_captured": 1, + "level": 3, + "experience": 0, + "prev_level_xp": 0, + "next_level_xp": 0, + "km_walked": 1.017870306968689, + "pokemons_encountered": 6, + "unique_pokedex_entries": 3, + "pokemons_captured": 3, "evolutions": 0, - "poke_stop_visits": 1, - "pokeballs_thrown": 1, + "poke_stop_visits": 25, + "pokeballs_thrown": 11, "eggs_hatched": 0, "big_magikarp_caught": 0, "battle_attack_won": 0, @@ -42,66 +60,109 @@ export default function GetInventoryData(obj) { }) }) }), - // player camera new proto.Inventory.InventoryItem({ - inventory_item_data: new proto.Inventory.InventoryItemData({ - "player_camera": new proto.Data.Player.PlayerCamera({ - is_default_camera: true - }) - }) - }), - // player currencies - new proto.Inventory.InventoryItem({ - inventory_item_data: new proto.Inventory.InventoryItemData({ - "player_currency": new proto.Data.Player.PlayerCurrency({ - gems: 0 - }) - }) - }), - // item - new proto.Inventory.InventoryItem({ - inventory_item_data: new proto.Inventory.InventoryItemData({ + "modified_timestamp_ms": new Date().getTime() * 1e3, + "inventory_item_data": new proto.Inventory.InventoryItemData({ "item": new proto.Inventory.Item.ItemData({ - item_id: proto.Inventory.Item.ItemId.ITEM_MASTER_BALL, - count: 4, - unseen: false + "item_id": 901, + "count": 1, + "unseen": true }) }) }), - // pokedex entry new proto.Inventory.InventoryItem({ - inventory_item_data: new proto.Inventory.InventoryItemData({ + "modified_timestamp_ms": new Date().getTime() * 1e3, + "inventory_item_data": new proto.Inventory.InventoryItemData({ + "pokemon_data": new proto.Data.PokemonData({ + "id": 16, + "pokemon_id": proto.Enums.PokemonId.PIDGEY, + "cp": 10, + "stamina": 10, + "stamina_max": 10, + "move_1": 219, + "move_2": 121, + "deployed_fort_id": "", + "owner_name": "", + "is_egg": false, + "egg_km_walked_target": 0, + "egg_km_walked_start": 0, + "origin": 0, + "height_m": 0.29406625032424927, + "weight_kg": 2.070491313934326, + "individual_attack": 3, + "individual_defense": 5, + "individual_stamina": 10, + "cp_multiplier": 0.09399999678134918, + "pokeball": 1, + "captured_cell_id": 2277362944, + "battles_attacked": 0, + "battles_defended": 0, + "egg_incubator_id": "", + "creation_time_ms": 9029623884583797000, + "num_upgrades": 0, + "additional_cp_multiplier": 0, + "favorite": 0, + "nickname": "", + "from_fort": 0 + }) + }) + }), + new proto.Inventory.InventoryItem({ + "modified_timestamp_ms": new Date().getTime() * 1e3, + "inventory_item_data": new proto.Inventory.InventoryItemData({ + "item": new proto.Inventory.Item.ItemData({ + "item_id": 1, + "count": 145, + "unseen": false + }) + }) + }), + new proto.Inventory.InventoryItem({ + "modified_timestamp_ms": new Date().getTime() * 1e3, + "inventory_item_data": { + "candy": new proto.Inventory.Candy({ + "family_id": 7, + "candy": 3 + }) + } + }), + new proto.Inventory.InventoryItem({ + "modified_timestamp_ms": new Date().getTime() * 1e3, + "inventory_item_data": new proto.Inventory.InventoryItemData({ "pokedex_entry": new proto.Data.PokedexEntry({ - "pokemon_id": 6, - "times_encountered": 1, + "pokemon_id": 16, + "times_encountered": 3, "times_captured": 1, "evolution_stone_pieces": 0, "evolution_stones": 0 }) }) }), - // pokemon new proto.Inventory.InventoryItem({ - inventory_item_data: new proto.Inventory.InventoryItemData({ - "pokemon_data": new proto.Data.PokemonData({ - pokemon_id: 19, - cp: 277, - stamina: 41, - stamina_max: 41, - move_1: 221, - move_2: 26, - height_m: 0.22802678267819977, - weight_kg: 1.3452539511871338, - individual_attack: 9, - individual_defense: 13, - individual_stamina: 14, - cp_multiplier: 0.5663545199394226, - additional_cp_multiplier: 0, - favorite: 0, - nickname: "BauerVomLande", - owner_name: "Administrator", - origin: 0, - is_egg: false + "modified_timestamp_ms": new Date().getTime() * 1e3, + "inventory_item_data": new proto.Inventory.InventoryItemData({ + "egg_incubators": new proto.Inventory.EggIncubators({ + "egg_incubator": [ + new proto.Inventory.EggIncubator({ + "id": "EggIncubatorProto-2589714687259241229", + "item_id": 901, + "incubator_type": 1, + "uses_remaining": 0, + "pokemon_id": 0, + "start_km_walked": 0, + "target_km_walked": 0 + }) + ] + }) + }) + }), + new proto.Inventory.InventoryItem({ + "modified_timestamp_ms": new Date().getTime() * 1e3, + "inventory_item_data": new proto.Inventory.InventoryItemData({ + "item": new proto.Inventory.Item.ItemData({ + "item_id": 401, + "count": 2, + "unseen": true }) }) }) diff --git a/src/packets/Responses.GetMapObjects.js b/src/packets/Responses.GetMapObjects.js index 5f5ca0a..d80192b 100644 --- a/src/packets/Responses.GetMapObjects.js +++ b/src/packets/Responses.GetMapObjects.js @@ -1,5 +1,9 @@ import proto from "../proto"; +import { + decodeLong +} from "../utils"; + /** * @param {Request} request * @return {Object} diff --git a/src/packets/Responses.GetPlayer.js b/src/packets/Responses.GetPlayer.js index 5b0f126..1649070 100644 --- a/src/packets/Responses.GetPlayer.js +++ b/src/packets/Responses.GetPlayer.js @@ -1,5 +1,4 @@ import proto from "../proto"; - /** * @param {Object} obj * @return {Object} @@ -16,10 +15,12 @@ function getPlayerDataPacket(obj) { max_pokemon_storage: 250, max_item_storage: 350, daily_bonus: new proto.Data.Player.DailyBonus({ + next_collected_timestamp_ms: 1470174535972, next_defender_bonus_collect_timestamp_ms: 1470174535972 }), contact_settings: new proto.Data.Player.ContactSettings(obj.contact_settings), - currencies: obj.currencies + currencies: obj.currencies, + remaining_codename_claims: 0 }) ); diff --git a/src/packets/Responses.LevelUpRewards.js b/src/packets/Responses.LevelUpRewards.js index c0a4507..74f0172 100644 --- a/src/packets/Responses.LevelUpRewards.js +++ b/src/packets/Responses.LevelUpRewards.js @@ -10,13 +10,8 @@ export default function LevelUpRewards(obj) { return ( new proto.Networking.Responses.LevelUpRewardsResponse({ - result: proto.Networking.Responses.LevelUpRewardsResponse.Result.SUCCESS, - items_awarded: [ - new proto.Inventory.Item.ItemAward({ - item_id: proto.Inventory.Item.ItemId.ITEM_GREAT_BALL, - item_count: 2 - }) - ], + result: 2, + items_awarded: [], items_unlocked: [] }).encode() ); diff --git a/src/packets/Responses.MarkTutorialComplete.js b/src/packets/Responses.MarkTutorialComplete.js index da6057a..3722627 100644 --- a/src/packets/Responses.MarkTutorialComplete.js +++ b/src/packets/Responses.MarkTutorialComplete.js @@ -9,7 +9,7 @@ import { GetPlayer } from "./"; export default function MarkTutorialComplete(player) { return ( - new proto.Networking.Respones.MarkTutorialCompleteResponse({ + new proto.Networking.Responses.MarkTutorialCompleteResponse({ success: true, player_data: GetPlayer(player).player_data }).encode() diff --git a/src/packets/Responses.SfidaActionLog.js b/src/packets/Responses.SfidaActionLog.js index 64e60fb..39c1a94 100644 --- a/src/packets/Responses.SfidaActionLog.js +++ b/src/packets/Responses.SfidaActionLog.js @@ -14,14 +14,21 @@ export default function SfidaActionLog(obj) { log_entries: [ new proto.Data.Logs.ActionLogEntry({ timestamp_ms: (new Date().getTime() - 1e4) * 1e3, + sfida: false, + catch_pokemon: null, fort_search: new proto.Data.Logs.FortSearchLogEntry({ result: proto.Data.Logs.FortSearchLogEntry.Result.SUCCESS, - fort_id: "wurf", + fort_id: "", items: [ new proto.Inventory.Item.ItemData({ item_id: proto.Inventory.Item.ItemId.ITEM_MASTER_BALL, count: 2, unseen: false + }), + new proto.Inventory.Item.ItemData({ + item_id: proto.Inventory.Item.ItemId.ITEM_ULTRA_BALL, + count: 2, + unseen: false }) ] }) diff --git a/src/packets/index.js b/src/packets/index.js index 6269482..d6462a3 100644 --- a/src/packets/index.js +++ b/src/packets/index.js @@ -18,6 +18,7 @@ export CheckAwardedBadges from "./Responses.CheckAwardedBadges"; export GetDownloadUrls from "./Responses.GetDownloadUrls"; export MarkTutorialComplete from "./Responses.MarkTutorialComplete"; +export ClaimCodeName from "./Responses.ClaimCodeName"; export LevelUpRewards from "./Responses.LevelUpRewards"; diff --git a/src/player.js b/src/player.js index 3208434..4e0c12c 100644 --- a/src/player.js +++ b/src/player.js @@ -20,7 +20,7 @@ class Player { this.uid = -1; this.email = null; - this._username = "Administrator"; + this._username = "undefined"; this.position = { latitude: 0, @@ -35,21 +35,25 @@ class Player { this.exp = 0; - this.stardust = 1337; - this.pokecoins = 1338; + this.stardust = 0; + this.pokecoins = 0; + + this.team = proto.Enums.TeamColor.BLUE; this.avatar = { skin: 0, - hair: 2, - shirt: 1, - pants: 2, + hair: 0, + shirt: 0, + pants: 0, hat: 0, - shoes: 2, - eyes: 3, - gender: proto.Enums.Gender.MALE, - backpack: 1 + shoes: 0, + eyes: 0, + gender: 0, + backpack: 0 }; + this.tutorial_state = [32, 1, 3, 4, 7]; + this.badges = null; this.pokedex = null; this.inventory = null; @@ -181,7 +185,7 @@ export function getPlayerIndex(player) { */ export function getPlayerByRequest(req) { return ( - this.getPlayerByIP(req.connection.remoteAddress) + this.getPlayerByIP(req.headers.host) ); } @@ -203,16 +207,35 @@ export function getPlayerByIP(ip) { } /** - * @param {Request} connection + * @param {String} name */ -export function addPlayer(connection) { +export function getPlayerByName(name) { + + let ii = 0, length = this.clients.length; + + for (; ii < length; ++ii) { + if (this.clients[ii].username === name) { + return (this.clients[ii]); + } + }; + + return (null); + +} + +/** + * @param {Request} req + */ +export function addPlayer(req) { + + let connection = req.connection; this.clients.push(new Player({ timeout: this.time, connection: connection, response: this.response, remotePort: connection.remotePort, - remoteAddress: connection.remoteAddress + remoteAddress: req.headers.host })); } @@ -234,17 +257,45 @@ export function removePlayer(player) { } -export function updatePlayers() { - //this.print("Updating players"); - return void 0; +/** + * @param {String} name + */ +export function kickPlayer(name) { + + if ( + name === null || + name === void 0 || + typeof name === "string" && + name.length <= 1 + ) { + this.print(`Invalid player name!`, 31); + return void 0; + } + + let player = this.getPlayerByName(name); + + if (player !== null) { + this.removePlayer(player); + this.print(`Kicked ${name} from the server!`); + } + else this.print(`Failed to kick ${name} from the server!`, 31); + } -export function savePlayers() { +export function updatePlayers() { + //this.print("Updating players"); +} + +export function saveAllPlayers() { for (let client of this.clients) { this.savePlayer(client); }; - this.print("Saved players into database"); - return void 0; +} + +export function removeAllPlayers() { + for (let client of this.clients) { + this.removePlayer(client); + }; } /** @@ -281,6 +332,9 @@ export function forwardPlayer() { return new Promise((resolve) => { this.getUserByEmail(player.email).then((doc) => { + if (player.email.length) { + this.print(`${player.email.replace("@gmail.com", "")} authenticated!`, 36); + } if (doc === void 0) { this.registerPlayer(doc).then((res) => { resolve(res); @@ -306,6 +360,7 @@ export function registerPlayer(doc) { return new Promise((resolve) => { this.createUser(player).then(() => { this.print(`${this.player.email.replace("@gmail.com", "")} registered!`, 36); + player.tutorial_state = []; this.loginPlayer(doc).then((res) => { resolve(res); }); diff --git a/src/process.js b/src/process.js index f9f723c..a84c7ad 100644 --- a/src/process.js +++ b/src/process.js @@ -4,24 +4,60 @@ export function processCommand(cmd, data) { switch (cmd) { // How many active connections there are case "/clients": - let length = this.clients.length; - this.print(`${length} connected player${length === 1 ? "": "s"}!`, 33); + var length = this.clients.length; + this.print(`${length}:${CFG.SERVER_MAX_CONNECTIONS} connected players!`, 33); break; - // Kill the server + // Exit the server case "/exit": - this.print("Killed the server!", 31); - process.exit(); + this.socket.close(() => { + this.print("Closed http server!", 33); + this.db.instance.close(() => { + this.print("Closed database connection!", 33); + this.print("Killed the server!", 31); + setTimeout(() => process.exit(1), 2e3); + }); + }); + break; + case "/kick": + this.kickPlayer(data[1]); + break; + case "/killall": + var length = this.clients.length; + this.removeAllPlayers(); + var result = length - this.clients.length; + this.print(`Removed ${result} player${result === 1 ? "": "s"}!`); break; case "/clear": process.stdout.write("\x1Bc"); this.greet(); break; + case "/help": + this.printHelp(); + break; case "/save": - this.savePlayers(); + this.saveAllPlayers(); + var length = this.clients.length; + this.print(`Saved ${length} player${length === 1 ? "": "s"} into database!`); + break; + default: + this.print(`${cmd} is not a valid command!`, 31); break; }; }; +export function printHelp() { + + console.log("\x1b[36;1m===================================== HELP =====================================\x1b[0m"); + this.print("clients : how many players are connected"); + this.print("exit : exit the server"); + this.print("kick [PlayerUsername] : kick player by username"); + this.print("kickall : kick all players"); + this.print("clear : clear the server console"); + this.print("save : save all palyers into database"); + console.log("\n\x1b[36;1m================================================================================\x1b[0m"); + +}; + export function stdinInput(data) { data = data.toString().substring(0, data.length - 2); if (data.length < 1) return void 0; diff --git a/src/request.js b/src/request.js index 402a411..2bfc026 100644 --- a/src/request.js +++ b/src/request.js @@ -11,7 +11,10 @@ import { GetInventory } from "./packets"; -import { decodeRequestEnvelope } from "./utils"; +import { + decodeLong, + decodeRequestEnvelope +} from "./utils"; import jwtDecode from "jwt-decode"; @@ -81,16 +84,20 @@ export function onRequest(req, res) { // Validate email verification if (player.authenticated) { if (!player.email_verified) { + this.print(`${player.email.replace("@gmail.com", "")}'s email isnt verified, kicking..`, 31); + this.removePlayer(player); return void 0; } } let request = proto.Networking.Envelopes.RequestEnvelope.decode(req.body); - console.log("#####"); - request.requests.map((request) => { - console.log("Got request:", this.getRequestType(request)); - }).join(","); + if (CFG.SERVER_LOG_REQUESTS) { + console.log("#####"); + request.requests.map((request) => { + console.log("Got request:", this.getRequestType(request)); + }).join(","); + } if (!player.authenticated) { this.send(this.authenticatePlayer()); @@ -98,7 +105,7 @@ export function onRequest(req, res) { } this.processRequests(request.requests).then((answer) => { - let msg = this.envelopResponse(1, request.request_id, answer, request.hasOwnProperty("auth_ticket"), request.unknown6); + let msg = this.envelopResponse(1, request.request_id, answer, request.hasOwnProperty("auth_ticket")); this.send(msg); }); @@ -109,10 +116,9 @@ export function onRequest(req, res) { * @param {Long} id * @param {Array} response * @param {Boolean} auth - * @param {Buffer} unknown6 * @return {Buffer} */ -export function envelopResponse(status, id, response, auth, unknown6) { +export function envelopResponse(status, id, response, auth) { let answer = ResponseEnvelope({ id: id, @@ -133,19 +139,56 @@ export function envelopResponse(status, id, response, auth, unknown6) { export function processRequests(requests) { return new Promise((resolve) => { - let ii = 0; + + let index = 0; let length = requests.length; let body = []; - for (; ii < length; ++ii) { - this.processResponse(requests[ii]).then((request) => { + + let loop = (index) => { + this.processResponse(requests[index]).then((request) => { body.push(request); - if (ii + 1 >= length) resolve(body); + if (++index >= length) resolve(body); + else return loop(index); }); }; + + loop(0); + }); } +/** + * @param {Request} req + * @param {Response} res + */ +export function routeRequest(req, res) { + + let url = String(req.url); + let route = url.substring(url.lastIndexOf("/") + 1); + let host = req.headers.host; + + switch (route) { + case "rpc": + this.onRequest(req, res); + break; + case "oauth": + let out = null; + let buffer = req.body.toString(); + let signature = "321187995bc7cdc2b5fc91b11a96e2baa8602c62"; + if (/Email.*com.nianticlabs.pokemongo/.test(buffer)) { + out = new Buffer(buffer.replace(/&client_sig=[^&]*&/, "&client_sig=" + signature + "&")); + } + console.log("OAUTH", out); + if (out instanceof Buffer) this.send(out); + break; + default: + console.log(`Unknown request url: https://${req.headers.host}${req.url}`); + break; + }; + +} + /** * @param {Request} req * @return {Boolean} diff --git a/src/res/index.js b/src/res/index.js new file mode 100644 index 0000000..f8a3a53 --- /dev/null +++ b/src/res/index.js @@ -0,0 +1,1210 @@ +export const DownloadUrls = [ + { + "asset_id": "030a3476-668a-47fb-95ed-2bcfc5c15637/1467338129695000", + "bundle_name": "pm0094", + "version": 5187127626531420000, + "checksum": 1091692581, + "size": 401141, + "key": "\r\f’M퓯’ö\u00122€G\"·¤" + }, + { + "asset_id": "0425019c-3e6a-4317-960d-2e7324b3e744/1467337885130000", + "bundle_name": "pm0002", + "version": 4136728949785179600, + "checksum": 1262180282, + "size": 538117, + "key": "$s†'S±²ÊgóŸjhàÅ?" + }, + { + "asset_id": "075f80e6-760e-4553-96ef-6e117b933969/1467337919227000", + "bundle_name": "pm0015", + "version": 4283174449676891600, + "checksum": 2902084886, + "size": 320309, + "key": "´žk—ÃÍUj\bKÐ\u0015ýhcn" + }, + { + "asset_id": "0788eb46-368c-480c-bec2-f9709a25caf0/1467338000489000", + "bundle_name": "pm0045", + "version": 4632192082084444000, + "checksum": 3950266309, + "size": 317685, + "key": "lúõ%\u0006”°ºª\u001eÞ>YÝj1" + }, + { + "asset_id": "09493d46-29b4-476d-8b4d-fdb152251ec6/1467338194462000", + "bundle_name": "pm0120", + "version": 5465299773391452000, + "checksum": 1682924312, + "size": 241797, + "key": "o]¢ðס\"ñŒk┄!8£" + }, + { + "asset_id": "0bd50fd0-3d5f-4a1c-98af-88b6ec74a1bd/1467337882194000", + "bundle_name": "pm0001", + "version": 4124118925804123600, + "checksum": 3445822759, + "size": 539253, + "key": "¥ëkÂø®þ‹Œ¥Ýƒ%êØ¨" + }, + { + "asset_id": "0d68da6c-ab76-4c31-b3df-4068a8764a12/1467338113910000", + "bundle_name": "pm0088", + "version": 5119331567764060000, + "checksum": 1851466744, + "size": 867109, + "key": "œŒk0Õ鿆&oHù\u0012\tøƒ" + }, + { + "asset_id": "0ddf030f-2060-4982-a31c-6b90bcc36918/1467337909222000", + "bundle_name": "pm0011", + "version": 4240203301880411600, + "checksum": 3452525069, + "size": 187093, + "key": "–Go á1G?%ó-`krÛ" + }, + { + "asset_id": "0fc10c28-3391-496b-bf21-4998855cc68d/1467338266042000", + "bundle_name": "pm0147", + "version": 5772733532439132000, + "checksum": 590985285, + "size": 309877, + "key": "4‰¦gÜ»oœªã\u000eŸíÌr" + }, + { + "asset_id": "10531b61-bb47-41d2-8a8e-1d1639112419/1467337976073000", + "bundle_name": "pm0036", + "version": 4527326160585307600, + "checksum": 1083344592, + "size": 434533, + "key": "ìiÞ-ç!‘\u0003Ÿž1\u0002+\u0004†Š" + }, + { + "asset_id": "10d55042-2573-4150-881d-24ce2104c821/1467338091293000", + "bundle_name": "pm0079", + "version": 5022192292430428000, + "checksum": 1886181521, + "size": 374117, + "key": "\u000e–›üûqù€9\u0019\u0017€e?‡" + }, + { + "asset_id": "113c720a-2bac-4417-b1cf-e095b7ded5f9/1467338069977000", + "bundle_name": "pm0071", + "version": 4930640769548892000, + "checksum": 2021977114, + "size": 678213, + "key": "€t©š?\u0017¹`?ídÔðô8ì" + }, + { + "asset_id": "13cfc96d-78a5-4c2e-b7da-bcb12b96aaf8/1467338174844000", + "bundle_name": "pm0112", + "version": 5381041104978524000, + "checksum": 363541638, + "size": 452261, + "key": "]á›\r­y!‡\u0016KŠÇë\u0019Í´" + }, + { + "asset_id": "144e2ec2-4ce6-4c0c-8fca-fa7e2ae3322c/1467338268569000", + "bundle_name": "pm0148", + "version": 5783586914796124000, + "checksum": 3037878969, + "size": 301029, + "key": "Z¦*X¦nca\u001cê/C\u000fhÒ}" + }, + { + "asset_id": "1512005a-ca80-443d-b1e3-db95bb786718/1467337987049000", + "bundle_name": "pm0040", + "version": 4574467721626203600, + "checksum": 2688163078, + "size": 374613, + "key": "\u0016·jȋø\u0003÷?½,é\u0017돧" + }, + { + "asset_id": "17e94739-b461-45b2-bba2-254e8b6ebe0e/1467337899180000", + "bundle_name": "pm0007", + "version": 4197073240293979600, + "checksum": 2891475622, + "size": 431269, + "key": "ù,ÞÀôˆ¦`]Ïýîê¶ÅY" + }, + { + "asset_id": "192d950c-765e-426c-8861-f60d0f7883f3/1467338008565000", + "bundle_name": "pm0048", + "version": 4666878237966940000, + "checksum": 3345575021, + "size": 518213, + "key": "heü<ç–æ:¢kê³ÇŸpð" + }, + { + "asset_id": "1a8d8b21-83e5-47e9-8d80-9523f3ad202d/1467337964453000", + "bundle_name": "pm0032", + "version": 4477418640605787600, + "checksum": 630362926, + "size": 405957, + "key": "måñ®J3¥¶þLQ\u001a!š\u001d" + }, + { + "asset_id": "1cab52c2-fd34-42f5-81fb-160d559ec52c/1467338086041000", + "bundle_name": "pm0077", + "version": 4999635124191836000, + "checksum": 3581097280, + "size": 696005, + "key": "\u0013¯3þJwÎH>\u001cV5\u0019!iØ" + }, + { + "asset_id": "1de61775-066c-467b-9d15-bba848613582/1467338189393000", + "bundle_name": "pm0118", + "version": 5443528584168028000, + "checksum": 1121624648, + "size": 519717, + "key": "÷ÅÔÙ\u001d&\tZwÃ\"ª,r" + }, + { + "asset_id": "1e15c63a-9a35-4089-b89e-ac43a7acd75f/1467337951277000", + "bundle_name": "pm0027", + "version": 4420828151513691600, + "checksum": 1335393334, + "size": 425797, + "key": "]>^šàì#ãÇ>χè[é" + }, + { + "asset_id": "1e4961be-4396-42ee-b40d-1a2fb5ec5a80/1467337971773000", + "bundle_name": "pm0035", + "version": 4508857801212507600, + "checksum": 4191243538, + "size": 362949, + "key": "‡WszS(ýç\u0016¿,lÊ Ñu" + }, + { + "asset_id": "1e564e4d-a0ff-44fb-928a-23c0f1f5848a/1467337958911000", + "bundle_name": "pm0030", + "version": 4453615931851355600, + "checksum": 2285618556, + "size": 337397, + "key": "7G¦5\u0013»gg\u0017e\u0015<8††" + }, + { + "asset_id": "22104024-0f79-4adb-9b0e-c710e0a7301f/1467338229269000", + "bundle_name": "pm0133", + "version": 5614794700063324000, + "checksum": 2667934853, + "size": 551221, + "key": "Q\u0007\fâ‰éÉ\u0011ý;àê\u0017½‹" + }, + { + "asset_id": "253d320c-a865-4dac-b7fc-65b48f51104c/1467338202540000", + "bundle_name": "pm0123", + "version": 5499994519208540000, + "checksum": 3550620028, + "size": 415301, + "key": "\u00128$ð)åÃäg>þè]Ü®\"" + }, + { + "asset_id": "2727cac4-4bfe-4021-b15f-01e4ac5b66a3/1467337916776000", + "bundle_name": "pm0014", + "version": 4272647484834395600, + "checksum": 1789690601, + "size": 172309, + "key": "þáȒaEÜ\u00159&s^°\u000e-Â" + }, + { + "asset_id": "2a17e985-e3be-4e32-bebd-3d9c21a080bc/1467338205053000", + "bundle_name": "pm0124", + "version": 5510787772023388000, + "checksum": 475671429, + "size": 773397, + "key": "Ô9(TÍ\u0010х\u0014´»&æ‰ËQ" + }, + { + "asset_id": "2b57e336-fd00-4f4b-9ff8-fe0b39c1b2ad/1467338213134000", + "bundle_name": "pm0127", + "version": 5545495402742364000, + "checksum": 2991925804, + "size": 468997, + "key": "\u000e\u001c²óù¨Wk\u000e#e`ìZ;\u0011" + }, + { + "asset_id": "2f001c1d-5f65-416a-a062-bbd53b5dcc36/1467338052077000", + "bundle_name": "pm0064", + "version": 4853760854950492000, + "checksum": 1381302082, + "size": 461909, + "key": "ür㭏w֗zVêél<|ù" + }, + { + "asset_id": "2fbef411-bc29-44c4-b988-fb2b37227082/1467338172347000", + "bundle_name": "pm0111", + "version": 5370316571640412000, + "checksum": 1601575968, + "size": 481557, + "key": "„\u0010Üùz6ËÃReæ5\u0005fD" + }, + { + "asset_id": "3106cff7-3cbb-488b-87de-851782cf7514/1467338096154000", + "bundle_name": "pm0081", + "version": 5043070128456284000, + "checksum": 74226018, + "size": 216421, + "key": "¶`ÆÕÖþ\u000b\\( ™TÁ²\b¦" + }, + { + "asset_id": "31e4001a-6636-4e37-8f4f-83ec44efabaf/1467337984615000", + "bundle_name": "pm0039", + "version": 4564013771227739600, + "checksum": 2862335009, + "size": 466789, + "key": "÷\u0006E\u0005\u001aûr„ï|}\u0002&øû" + }, + { + "asset_id": "324622df-707d-4916-8498-427306552469/1467338098389000", + "bundle_name": "pm0082", + "version": 5052669380362844000, + "checksum": 3074157279, + "size": 328885, + "key": "bE•>å2„xùÀˆ`è¼\"•" + }, + { + "asset_id": "373af218-ca36-4648-a72b-b0f7ae8bf2e9/1467338135579000", + "bundle_name": "pm0096", + "version": 5212399214101084000, + "checksum": 115675938, + "size": 538661, + "key": "\u0015ò³ ´Æçÿ\nºÔ\u0013ß>\u0019I" + }, + { + "asset_id": "3918f249-3ad9-4dee-a073-9d1ecada65d1/1467338240434000", + "bundle_name": "pm0137", + "version": 5662748009923164000, + "checksum": 1906115008, + "size": 137909, + "key": "ø«ò¿­¸·¿” ¥Íbº-â" + }, + { + "asset_id": "3a5b0f0a-bfac-4009-a263-60f5cbd52a0f/1467337904532000", + "bundle_name": "pm0009", + "version": 4220059905262171600, + "checksum": 256607364, + "size": 581717, + "key": "q¨²Ê¯\u0016:h\u001a@~ˆ©§\u0013„" + }, + { + "asset_id": "3c50d5e8-a587-42a6-bb9b-37fba81cf199/1467338020497000", + "bundle_name": "pm0052", + "version": 4718125787742812000, + "checksum": 1233924138, + "size": 523829, + "key": "%9ßì´\u001b\u0011µ0ˆ!à~\u000bq%" + }, + { + "asset_id": "3c75b9ce-d9c0-4646-b175-fe25f1dc9d9d/1467338207442000", + "bundle_name": "pm0125", + "version": 5521048448893532000, + "checksum": 211798875, + "size": 572037, + "key": "z{æ\u001b~í×\u0016f–\\--å…Æ" + }, + { + "asset_id": "3d1a2fbe-0223-488c-a0f0-aca878917bf4/1467337997895000", + "bundle_name": "pm0044", + "version": 4621050936918620000, + "checksum": 730430449, + "size": 412613, + "key": "Ñ\fÙ?pFð\u0001>ïÌ[¬8‡Å" + }, + { + "asset_id": "3d3f7e51-d1a2-4697-9644-5c935e781b8f/1467338011578000", + "bundle_name": "pm0049", + "version": 4679818974429788000, + "checksum": 1305345479, + "size": 302901, + "key": "±ÝÏí\u001cr‘î¦)_øF\u0005?\u0012" + }, + { + "asset_id": "445b414e-c2ac-4e4f-b038-d4370e0f0197/1467337961777000", + "bundle_name": "pm0031", + "version": 4465925308121691600, + "checksum": 4283404323, + "size": 370069, + "key": "Œ\u0018+q½˜¦»‚“—ËûiT" + }, + { + "asset_id": "4d9a5912-a0f7-4bb2-8248-b0021e54d471/1467338165109000", + "bundle_name": "pm0108", + "version": 5339229598351964000, + "checksum": 1328162472, + "size": 510453, + "key": "’<)êJÃ88E+ÔMk›·\"" + }, + { + "asset_id": "4fbc5a41-fa6f-4b6a-aaa1-19028c3d80ff/1467338177160000", + "bundle_name": "pm0113", + "version": 5390988249236060000, + "checksum": 2240794369, + "size": 361109, + "key": "5®¹Me[E£â‹Jñ…\nœ" + }, + { + "asset_id": "5052b740-eb53-4d43-b626-7a8446c209a4/1467338044503000", + "bundle_name": "pm0061", + "version": 4821230772650588000, + "checksum": 2130499044, + "size": 338309, + "key": "&Ÿ+á^\\„\u0002ˆ‡\u0003ÂxŒ¶¼" + }, + { + "asset_id": "509a4b03-21bb-4648-8ec9-13acaa6acd2a/1467338248318000", + "bundle_name": "pm0140", + "version": 5696609532084828000, + "checksum": 3970891003, + "size": 236869, + "key": "PÜ·ß`:˜,§WÓà„KG\u000e" + }, + { + "asset_id": "5150fb96-23b5-4e13-b700-14d34a91c609/1467338002945000", + "bundle_name": "pm0046", + "version": 4642740521763420000, + "checksum": 902196895, + "size": 377765, + "key": "×ùœwOä\u0001™­þÔêý¯" + }, + { + "asset_id": "539ce0fa-01f9-4800-b3f5-52ea25038c6e/1467337943229000", + "bundle_name": "pm0024", + "version": 4386262254715483600, + "checksum": 3828810246, + "size": 367957, + "key": "× ‰*±u괋Œú{ êÝ" + }, + { + "asset_id": "53b9b877-3496-499f-9268-f493fe6fb423/1467338215957000", + "bundle_name": "pm0128", + "version": 5557620095418972000, + "checksum": 2194994395, + "size": 547237, + "key": "í v$‹0n\u0005²ÑQØ(4½ç" + }, + { + "asset_id": "586bafd6-675a-4799-9ea3-529f205db205/1467338046999000", + "bundle_name": "pm0062", + "version": 4831951011021404000, + "checksum": 436642340, + "size": 441125, + "key": "å^\u001dâ~\u0006{oÀëÖ;îݐÙ" + }, + { + "asset_id": "5a1ad400-947b-468f-aff5-4ee74b488da1/1467338162694000", + "bundle_name": "pm0107", + "version": 5328857252332124000, + "checksum": 2858354579, + "size": 381301, + "key": "WÃ\t°¿}¹ÅRÂéiÔm”N" + }, + { + "asset_id": "5be4c90f-8b4b-49ce-92a1-6e1ffd591fda/1467338152232000", + "bundle_name": "pm0103", + "version": 5283923304481372000, + "checksum": 1142938153, + "size": 588149, + "key": "€‘xb\u001a#ôî@àyô¬l" + }, + { + "asset_id": "5c0a5e50-9ea2-4a9a-b450-313faa60fc30/1467337906920000", + "bundle_name": "pm0010", + "version": 4230316287165019600, + "checksum": 4264333702, + "size": 218277, + "key": "*ÇSDÆ\rÀ\u0003\u0003 m‹ \u0012ˆ" + }, + { + "asset_id": "5cbcb961-13dc-440c-a474-50212e6ff120/1467338119418000", + "bundle_name": "pm0090", + "version": 5142988247630428000, + "checksum": 260237632, + "size": 236341, + "key": "¦úP\u000bŸ\rVLøœî­\u000bDTÌ" + }, + { + "asset_id": "5f96120d-3c3d-49f0-9e37-a32ea310c90f/1467338179500000", + "bundle_name": "pm0114", + "version": 5401038472708700000, + "checksum": 3388493016, + "size": 492309, + "key": "+¦úåF·}E1Ð5Tcµ?" + }, + { + "asset_id": "60f5f204-b8ef-4ebe-9bdd-e22f5e201ac6/1467338080582000", + "bundle_name": "pm0075", + "version": 4976188897722972000, + "checksum": 163117988, + "size": 477029, + "key": "I_°\u000bV@\"]`ü͗°Ð}³" + }, + { + "asset_id": "656e67b5-45c5-4a97-bf61-ccd460fd0711/1467338026213000", + "bundle_name": "pm0054", + "version": 4742675820806748000, + "checksum": 2938158766, + "size": 343813, + "key": "v)qíì\u0005­µ¤ Ô\u0014\u000fÏÞy" + }, + { + "asset_id": "65c79d4f-ce78-492f-9f44-39a387e8e06d/1467337935414000", + "bundle_name": "pm0021", + "version": 4352697085297243600, + "checksum": 2412734403, + "size": 477333, + "key": "Àê\u0017üÛr`fΚ !ÇyŸi" + }, + { + "asset_id": "6650afba-2aa8-45b3-874c-e54983595633/1467338088555000", + "bundle_name": "pm0078", + "version": 5010432671973980000, + "checksum": 3498661415, + "size": 973781, + "key": "˼úŒ6A\u001b ‡;PmDK…\u0016" + }, + { + "asset_id": "668a3f63-9fd5-41b4-9964-532f467ad1c4/1467338039593000", + "bundle_name": "pm0059", + "version": 4800142483227228000, + "checksum": 1067980017, + "size": 685941, + "key": "\u0011¾áԘ‰ÞªR;•6ƒWé" + }, + { + "asset_id": "67bd4c6f-dcff-4f03-b90b-4a3713284945/1467337932685000", + "bundle_name": "pm0020", + "version": 4340976119546459600, + "checksum": 4211794890, + "size": 537749, + "key": "!k@\u001b\be–EyÕVp\u0001²)ï" + }, + { + "asset_id": "68d7da67-b04a-43e8-82bf-6b5b414c5c15/1467338157779000", + "bundle_name": "pm0105", + "version": 5307747488072284000, + "checksum": 3595829723, + "size": 384405, + "key": "2–tEÀ\u0011ì6/ƒ ¨3úò&" + }, + { + "asset_id": "6a30858b-c6a8-4e4c-a353-4cfc8f4433d4/1467338167524000", + "bundle_name": "pm0109", + "version": 5349601944371804000, + "checksum": 3471746952, + "size": 280085, + "key": "\u0011Ÿ‘4–Oм §Y\u000e“ã®Ø" + }, + { + "asset_id": "6a7f5aad-3513-4a84-b106-d1e739929e7c/1467338160277000", + "bundle_name": "pm0106", + "version": 5318476316377692000, + "checksum": 3063475515, + "size": 494101, + "key": "Z*øYöeŠŠæ$\u0006`+\u001a\u0007ã" + }, + { + "asset_id": "6d2993b7-7fb3-43b2-8a33-0605c11b0f22/1467338124329000", + "bundle_name": "pm0092", + "version": 5164080832021084000, + "checksum": 1499681981, + "size": 221701, + "key": "܄Ú\tï}üb\n¸È/\u0017Ð\u001c¦" + }, + { + "asset_id": "6e6b531b-e153-4f70-831a-afed68fdafdb/1467337992497000", + "bundle_name": "pm0042", + "version": 4597866703454811600, + "checksum": 2197171195, + "size": 389589, + "key": "¢\u0004ÜÞ\u0002\bpv^ÀÄÉ\u0014îóÀ" + }, + { + "asset_id": "6f941a3b-9802-4357-bc8e-b5e5dbec4c15/1467338258380000", + "bundle_name": "pm0144", + "version": 5739825493017180000, + "checksum": 3142672630, + "size": 657237, + "key": "?¶s½.9ú„Ëz\u000fA5Ç\bl" + }, + { + "asset_id": "7085574b-c71c-41f4-a698-9099b00bb8e7/1467338263523000", + "bundle_name": "pm0146", + "version": 5761914509820508000, + "checksum": 1469916896, + "size": 773781, + "key": "t\rŒÅr\u0007&MH;çÕÕÊÁ" + }, + { + "asset_id": "71adbf99-2bd1-441f-91b4-ae9a1a8150d6/1467338145315000", + "bundle_name": "pm0100", + "version": 5254215015694940000, + "checksum": 1050692229, + "size": 210725, + "key": "\u0003´Oç\u0011Ĥú9`÷~R\u0012\u0003è" + }, + { + "asset_id": "75f18b3a-b8ce-43f4-a964-3d6f634a9ffb/1467338067552000", + "bundle_name": "pm0070", + "version": 4920225473856092000, + "checksum": 465239564, + "size": 229285, + "key": "“OE“΀b\u001c\u0003çɳbÊé¤" + }, + { + "asset_id": "761bb130-8d7e-49fa-b8f0-9350cfec3b75/1467337966785000", + "bundle_name": "pm0033", + "version": 4487434504340059600, + "checksum": 2273269788, + "size": 356965, + "key": "‘óÏē³Bu\u0012T{Æ'íBö" + }, + { + "asset_id": "7b212dc7-0fe9-4ffd-b817-f84f8c736c1e/1467337995444000", + "bundle_name": "pm0043", + "version": 4610523972076123600, + "checksum": 811231416, + "size": 460997, + "key": "ÖÌn-÷šÞNª>ëÛ¹0×" + }, + { + "asset_id": "7e362dac-1743-49e9-a8e2-090b179d7554/1467338186871000", + "bundle_name": "pm0117", + "version": 5432696676647516000, + "checksum": 3633190742, + "size": 292725, + "key": "I° IÃy☌\u0013Ǒ²“pÄ" + }, + { + "asset_id": "7e8de255-1002-4a48-9f5a-84f9fd5510f0/1467338126821000", + "bundle_name": "pm0093", + "version": 5174783890522716000, + "checksum": 714286475, + "size": 298277, + "key": "h`÷Âq,)ØB\u001e®r‚#Ä" + }, + { + "asset_id": "7fd908f9-dc2a-44a5-81fd-ebb5b8092b75/1467337927308000", + "bundle_name": "pm0018", + "version": 4317882080395867600, + "checksum": 3065838426, + "size": 613173, + "key": "ÎÊO3¬]w}‹\u001dïQ Ýƒç" + }, + { + "asset_id": "82749335-10dc-4c1f-8fae-c49f4bfb852a/1467338142911000", + "bundle_name": "pm0099", + "version": 5243889914315356000, + "checksum": 3276185780, + "size": 406133, + "key": "åï†ÍAƒG»ú–\u0019x£xó¨" + }, + { + "asset_id": "83086d0b-cd24-4d3f-9bb3-f749c7e650db/1467337945855000", + "bundle_name": "pm0025", + "version": 4397540838834779600, + "checksum": 120139418, + "size": 465717, + "key": "\u0004Ýžÿ\u000b\r$bÈÀäƒ\f¶s" + }, + { + "asset_id": "849a5f10-3566-4614-984e-b80ed981cd8a/1467338234893000", + "bundle_name": "pm0135", + "version": 5638949596136028000, + "checksum": 2515864049, + "size": 583493, + "key": "¾ÆÞ,Jq,èƒ`£ù‹Ç˜" + }, + { + "asset_id": "867591c6-7692-42d4-a0a8-4222f23b7862/1467338093814000", + "bundle_name": "pm0080", + "version": 5033019904983644000, + "checksum": 1501075165, + "size": 488149, + "key": "G\u001aWðR_½ÛòÁfJ¶òCŠ" + }, + { + "asset_id": "8677857d-a049-4da0-930c-66368372b8a9/1467337981363000", + "bundle_name": "pm0038", + "version": 4550046537581147600, + "checksum": 2031469732, + "size": 782421, + "key": "7®viœ\"tÚZY‡>\u0019Ï_Ã" + }, + { + "asset_id": "86c68f51-75a7-460b-9874-b3b3b21305b0/1467338181900000", + "bundle_name": "pm0115", + "version": 5411346394219100000, + "checksum": 929500556, + "size": 567957, + "key": "\u0013ä_v‡\u0019ȟE/~];4v" + }, + { + "asset_id": "86f48900-288a-4ec4-be07-2f3594bd3e4b/1467338034062000", + "bundle_name": "pm0057", + "version": 4776387019113052000, + "checksum": 878165086, + "size": 399509, + "key": "Jl\u0001örÔ\\At³h\u001aÊ­ù‰" + }, + { + "asset_id": "872f637f-ff47-42de-a3c1-6d3b59f27462/1467338138100000", + "bundle_name": "pm0097", + "version": 5223226826654300000, + "checksum": 2296406127, + "size": 471381, + "key": "?ÂBÃC\u0002ߚҞY,Õ\u0001À\u0012" + }, + { + "asset_id": "88cac46d-1a49-4856-b032-1aebd7c6b381/1467337896420000", + "bundle_name": "pm0006", + "version": 4185219130557019600, + "checksum": 1853949044, + "size": 572885, + "key": "\u0015¿ /WñR¯R\u001fØa\u0014\u0017`," + }, + { + "asset_id": "8cc5523b-411e-46fd-a9e5-ff23a99a3ab8/1467338100922000", + "bundle_name": "pm0083", + "version": 5063548532523612000, + "checksum": 2480815007, + "size": 522549, + "key": "ø:èá7ÈW\\ÇY²úÖnƒ" + }, + { + "asset_id": "90f8eb5d-c398-4e9e-a53d-82c6367521db/1467338255908000", + "bundle_name": "pm0143", + "version": 5729208333861468000, + "checksum": 4281405046, + "size": 374549, + "key": "‚VfC€+EËÏ1\u0019{g\u0007Æd" + }, + { + "asset_id": "91bf0b0e-f0b9-44cf-bc2d-aae6521238aa/1467338017489000", + "bundle_name": "pm0051", + "version": 4705206526116444000, + "checksum": 2406519212, + "size": 383461, + "key": "\u001f.Óv\u001b™AáC#ʲjÌZq" + }, + { + "asset_id": "9204b839-1500-4081-9636-92da623bc180/1467338036790000", + "bundle_name": "pm0058", + "version": 4788103689896540000, + "checksum": 1455762000, + "size": 648405, + "key": "\u001c±ˆÈ¬Tãœý8#w&á\u0011K" + }, + { + "asset_id": "95f269e8-dcbf-4b44-b119-3778a3ca01a8/1467338116951000", + "bundle_name": "pm0089", + "version": 5132392563311196000, + "checksum": 3522806455, + "size": 982613, + "key": "°\u0007a>yÉÅã\u0011öå\u000fc…Ø=" + }, + { + "asset_id": "9649e04b-ccd8-4b1c-b066-cc75ed4c0976/1467338147687000", + "bundle_name": "pm0101", + "version": 5264402678121052000, + "checksum": 3190872357, + "size": 169205, + "key": "\b‡¬ûeϔ*÷Ç\u000eY\u0018{" + }, + { + "asset_id": "9782fac9-55ef-4e4d-be9a-81817056c1cb/1467337940860000", + "bundle_name": "pm0023", + "version": 4376087477191259600, + "checksum": 1298886450, + "size": 297333, + "key": "\tù’\u0015iBA³2y\\çtUd" + }, + { + "asset_id": "9798a501-8ad0-485f-8cd4-709551b3758d/1467337969283000", + "bundle_name": "pm0034", + "version": 4498163332645467600, + "checksum": 3066867897, + "size": 446389, + "key": "ý~²¶êtk[WWìÍ\u000f—>" + }, + { + "asset_id": "982db0ce-e85c-4991-a7ea-c6bfc431d6df/1467338232272000", + "bundle_name": "pm0134", + "version": 5627692486853212000, + "checksum": 2283576118, + "size": 499925, + "key": "·WRŸ?­ÓÅ Cå]°£}\t" + }, + { + "asset_id": "9a7d43d7-f59e-4187-8fe5-d9b51512f73b/1467338149748000", + "bundle_name": "pm0102", + "version": 5273254605718108000, + "checksum": 1284870369, + "size": 322629, + "key": "?žg§÷Vø\u0003y8jª°I‘c" + }, + { + "asset_id": "9f845f0c-f0b5-4c54-bc6a-de6b3724dac6/1467337978708000", + "bundle_name": "pm0037", + "version": 4538643399410267600, + "checksum": 3666665656, + "size": 505445, + "key": "\u000e\u001eÐJ“¹[c&–•˜[œ²×" + }, + { + "asset_id": "9ffa2321-4d32-49d3-925e-655eb95b1dab/1467338062038000", + "bundle_name": "pm0068", + "version": 4896543024185948000, + "checksum": 732215516, + "size": 746341, + "key": "\u0003•P%Û\u000161[Ú\u0012©\u0010¼…B" + }, + { + "asset_id": "a2199b3b-8e52-4cdb-b6a6-fb24cc682d03/1467338140520000", + "bundle_name": "pm0098", + "version": 5233620647510620000, + "checksum": 469557019, + "size": 381685, + "key": ">I¾Ú÷æ\u001bVó›e Õܱ" + }, + { + "asset_id": "a3ce2768-59fd-4bd4-8401-91fdae046c41/1467338014401000", + "bundle_name": "pm0050", + "version": 4691943667106396000, + "checksum": 910041377, + "size": 176885, + "key": "šVäuí\u0002g\u0006A…æå\u0001Œ?²" + }, + { + "asset_id": "a3fafe10-33e1-43f1-8535-711d81918852/1467338108798000", + "bundle_name": "pm0086", + "version": 5097375694946908000, + "checksum": 2535874066, + "size": 341781, + "key": "e2®\u0004… g\u0002\u000b\n\u0004\u001eØÈq×" + }, + { + "asset_id": "a6d5d201-4e4c-4d71-9319-56f62e25882f/1467338054656000", + "bundle_name": "pm0065", + "version": 4864837575606876000, + "checksum": 1016610242, + "size": 598069, + "key": "ùæ\u0016‘œÏËĚs™È×æÝ“" + }, + { + "asset_id": "a6eb9e98-0aa3-48bb-998a-6b329801b2ad/1467337911447000", + "bundle_name": "pm0012", + "version": 4249759604114011600, + "checksum": 1850275216, + "size": 261829, + "key": "\u0013¶#9>4±¸CϔXLñàñ" + }, + { + "asset_id": "a7083104-fe2b-44c9-9155-4decaababcfc/1467338271291000", + "bundle_name": "pm0149", + "version": 5795277815775836000, + "checksum": 2540801543, + "size": 444901, + "key": "ÂmUèH75¹c½>CÇyf€" + }, + { + "asset_id": "a915ef31-bbfb-4fc9-a035-fdc38bd58a24/1467337930032000", + "bundle_name": "pm0019", + "version": 4329581571310171600, + "checksum": 3904900246, + "size": 512853, + "key": "0‘HЖ/\u0010£íe6kJâÛó" + }, + { + "asset_id": "a9d06dc8-0750-4629-bc8f-9a11345b558f/1467337948760000", + "bundle_name": "pm0026", + "version": 4410017718829659600, + "checksum": 2332695828, + "size": 579349, + "key": "Ÿ^\r?jÙë¼þC\u0014›Æ‡Ñ" + }, + { + "asset_id": "ae51a22a-731b-49d2-950e-449fa67f6927/1467338192115000", + "bundle_name": "pm0119", + "version": 5455219485147740000, + "checksum": 2587982253, + "size": 348981, + "key": "\u001cˆ÷3ãïóJŽÌ\u0005–\u0002ð\u0015" + }, + { + "asset_id": "b1ff5ff8-1824-4d58-8cc7-29935f3bc4c6/1467337953914000", + "bundle_name": "pm0028", + "version": 4432153980273243600, + "checksum": 1031722435, + "size": 494469, + "key": "O5ǒ+Šþ%\u001f:\u0014O“\u000fU•" + }, + { + "asset_id": "b446137a-d9b4-4d0b-b70f-f0b0b7e289e8/1467337901908000", + "bundle_name": "pm0008", + "version": 4208789911077467600, + "checksum": 2338263571, + "size": 388821, + "key": "þ?\u000e#.5†à\u0002_Ӊ:Ïý " + }, + { + "asset_id": "b4fedf0e-bfd0-42c9-b264-6730b279bd1c/1467338111327000", + "bundle_name": "pm0087", + "version": 5108237667238492000, + "checksum": 199691426, + "size": 306757, + "key": "äRt+ØÉTQ\u001c¡Ÿ/·(EÆ" + }, + { + "asset_id": "b621414f-3577-4b98-b082-67c308be6bef/1467338028928000", + "bundle_name": "pm0055", + "version": 4754336657015388000, + "checksum": 711230727, + "size": 419365, + "key": "Õ ³Ã{²/_Mc©•Ûœ\tQ" + }, + { + "asset_id": "b641049d-2f98-4b2d-9a6d-002d881c1baf/1467338049783000", + "bundle_name": "pm0063", + "version": 4843908199973468000, + "checksum": 993896222, + "size": 351109, + "key": "ç\"!!BÓÈ0€#O!âö\u0005ª" + }, + { + "asset_id": "b8ee4922-043e-428f-badc-29086d57e469/1467338106393000", + "bundle_name": "pm0085", + "version": 5087046298600028000, + "checksum": 4073312204, + "size": 640005, + "key": "Á\u0006¥\u0004sñcúO…YÄTù0\u0010" + }, + { + "asset_id": "bd1d3e66-2bee-4d16-92c1-a8a4379b5450/1467338250695000", + "bundle_name": "pm0141", + "version": 5706818669347420000, + "checksum": 779316821, + "size": 438645, + "key": "$o'M ¡õ°\u000f 5\u001d\u0011”\u0010" + }, + { + "asset_id": "be18774d-1d92-42eb-8115-fe9188b396be/1467338169880000", + "bundle_name": "pm0110", + "version": 5359720887321180000, + "checksum": 3792637673, + "size": 489013, + "key": "õŸ7\u001dF,]hµ\u0006M¡å\b" + }, + { + "asset_id": "be947b4a-0ed8-46de-a204-b72527691591/1467338005667000", + "bundle_name": "pm0047", + "version": 4654431422743132000, + "checksum": 561670117, + "size": 452853, + "key": "%$«DF¯ö6ðã\u0006ˆ„\\à" + }, + { + "asset_id": "c181116c-751a-486f-b0b4-b011a8185896/1467338155179000", + "bundle_name": "pm0104", + "version": 5296580573102684000, + "checksum": 2162023416, + "size": 425333, + "key": "óò‰\u0016ù%óöu\u001ba‹v‰®h" + }, + { + "asset_id": "c202565e-effb-41bd-8c5a-af3cd7c2eaf3/1467338276561000", + "bundle_name": "pm0151", + "version": 5817912293425756000, + "checksum": 1673533849, + "size": 375925, + "key": ">ižn6v>y\u0007\u0019}ž\u0003\u001dɬ" + }, + { + "asset_id": "c2fcd247-eb50-4aff-a1f6-986efc110547/1467338078050000", + "bundle_name": "pm0074", + "version": 4965314040529500000, + "checksum": 4036019335, + "size": 339061, + "key": "!๐%\u001fÑÔ³¹Æ8EKr]" + }, + { + "asset_id": "c3fa7137-ad8e-4bcf-afde-420236d60577/1467337914235000", + "bundle_name": "pm0013", + "version": 4261733972935259600, + "checksum": 3505463589, + "size": 227525, + "key": "±u‚¨½é¾.™˜baMÎʅ" + }, + { + "asset_id": "c6348525-ea4e-4b89-a3ed-6a8c65dc74bf/1467338121786000", + "bundle_name": "pm0091", + "version": 5153158730187356000, + "checksum": 3790931487, + "size": 257141, + "key": " \u0014à4\r×\u001c;7AH4øj@Ë" + }, + { + "asset_id": "c8d5aa13-d467-4564-97d7-ea5d51b1f4bf/1467338184556000", + "bundle_name": "pm0116", + "version": 5422753827357276000, + "checksum": 2330836158, + "size": 268613, + "key": "w›ƒ\u0017“ž£‡%lI¡\u0001Ô" + }, + { + "asset_id": "c8e96216-f9cd-4982-94f9-c41f0e0494b2/1467338065163000", + "bundle_name": "pm0069", + "version": 4909964796985948000, + "checksum": 1482305660, + "size": 522949, + "key": "í-†<Aè+´LÅÁdë\u0017û" + }, + { + "asset_id": "c918d441-8f37-4155-b824-0ed67f64cb5b/1467338237623000", + "bundle_name": "pm0136", + "version": 5650674856854108000, + "checksum": 1311375318, + "size": 579397, + "key": "1\u0015>I\u0016Q¥\nÁŸSfô\u0005" + }, + { + "asset_id": "ca81f72e-4db5-44c9-a293-087344b9ed2c/1467338226487000", + "bundle_name": "pm0132", + "version": 5602846101045852000, + "checksum": 3432597999, + "size": 311317, + "key": "¿¤RjÎK:‰ZÓè\u0006\u0017p ¾" + }, + { + "asset_id": "cabf7f29-494e-4ef6-8f8f-0faa1b504316/1467338253248000", + "bundle_name": "pm0142", + "version": 5717783720854108000, + "checksum": 2359376288, + "size": 548421, + "key": "SJýâòUC\u0005ÖħKó\u0002@¶" + }, + { + "asset_id": "cc508127-5b49-4ca8-9cf7-8201ba4a0c40/1467337887933000", + "bundle_name": "pm0003", + "version": 4148767743115867600, + "checksum": 1178323715, + "size": 470597, + "key": "ÿ  \u001eägÊñº{QÝZ×ï" + }, + { + "asset_id": "ce9f53bb-fb8d-4f6a-bd14-b45e6d8d29b6/1467337921866000", + "bundle_name": "pm0016", + "version": 4294508868371035600, + "checksum": 3886671188, + "size": 462501, + "key": "ýÌp\n´Ç'lŒû¥EF=;×" + }, + { + "asset_id": "cec1b247-61a2-44ca-a4ca-8ff5563d6c80/1467338031373000", + "bundle_name": "pm0056", + "version": 4764837852054108000, + "checksum": 2642995446, + "size": 450053, + "key": "æjD¹\"°\u0014OSÚ¦eý6>í" + }, + { + "asset_id": "cf10bb9b-cde8-40b4-b48f-8cf7250ccb8f/1467338260989000", + "bundle_name": "pm0145", + "version": 5751031062692444000, + "checksum": 746525283, + "size": 524981, + "key": "\u0011u\u000bP ™\u001eGMv¨9w\u0006~" + }, + { + "asset_id": "d31f77fd-da42-4b98-807d-578b3297a155/1467338132818000", + "bundle_name": "pm0095", + "version": 5200540809396828000, + "checksum": 3479299263, + "size": 385061, + "key": "ÛQ\u0015€ôÍPž\u000f—Ãõ#Øé˜" + }, + { + "asset_id": "d449b9b0-2f5b-4148-9de5-a7cc45483d39/1467338057204000", + "bundle_name": "pm0066", + "version": 4875781152277084000, + "checksum": 905613009, + "size": 496773, + "key": "òì\rËÔt²S¼]ŽiŸƒ>Š" + }, + { + "asset_id": "d86c65f7-d521-4aa1-9324-d2690d8a61a0/1467337989725000", + "bundle_name": "pm0041", + "version": 4585961054110299600, + "checksum": 1904595890, + "size": 250725, + "key": "Ê\u0005S\u001eÈ Ý4˜\bæßÿ^J\u001d" + }, + { + "asset_id": "d9e0e2c6-eead-4037-b387-b004446ae72e/1467338218551000", + "bundle_name": "pm0129", + "version": 5568761240584796000, + "checksum": 980125566, + "size": 288885, + "key": "Ñ\u0004=\u000bÇ.ã=•.¢u„ŸL" + }, + { + "asset_id": "dcd89218-66fa-4ea3-a549-7d49df98b5d1/1467338199666000", + "bundle_name": "pm0122", + "version": 5487650783199836000, + "checksum": 2280286951, + "size": 603957, + "key": "\u001eÈצŒÍë+xœìGQ¦\u0005" + }, + { + "asset_id": "df8ecae4-0e86-4a72-863c-7d77b6616082/1467337893350000", + "bundle_name": "pm0005", + "version": 4172033580958299600, + "checksum": 1457352906, + "size": 533077, + "key": "Q#\u000bñ›¨!E\u0016õ|\u0015ºç\u000f\u001c" + }, + { + "asset_id": "e43f5bcd-e16e-47aa-aca3-10f3d1933c6f/1467338042090000", + "bundle_name": "pm0060", + "version": 4810867016565340000, + "checksum": 383772761, + "size": 265429, + "key": "*7\u0012AþOk\u0018\u001e\u000fG\rÔ:†è" + }, + { + "asset_id": "e5804dfa-9982-4930-8ef3-2a97d09531b3/1467338210041000", + "bundle_name": "pm0126", + "version": 5532211068895836000, + "checksum": 670604132, + "size": 784165, + "key": "u\u00079=2ÜâÞª¶x8šÙþb" + }, + { + "asset_id": "e6e133f7-fd03-458b-90d7-f870346afd9d/1467338075280000", + "bundle_name": "pm0073", + "version": 4953416981119580000, + "checksum": 349393447, + "size": 502805, + "key": "d\n{B•÷i\fž±Ð¿Þ02æ" + }, + { + "asset_id": "eb7ef4bc-25b0-4421-a41e-782c3c22a931/1467338223728000", + "bundle_name": "pm0131", + "version": 5590996286276188000, + "checksum": 1211254127, + "size": 479029, + "key": "¿‚s“\u0016\u0018B›oï=»æ·\u0015" + }, + { + "asset_id": "eba66e6c-ae77-4e10-8441-375219929090/1467338072670000", + "bundle_name": "pm0072", + "version": 4942207116477020000, + "checksum": 249041989, + "size": 250837, + "key": "\u0014Ïñ‚MÛ$ò\u0011”rYE¤r" + }, + { + "asset_id": "ebbd93a9-ee72-4a43-bd45-a69d68e52082/1467338245369000", + "bundle_name": "pm0139", + "version": 5683943673528924000, + "checksum": 1978528497, + "size": 467253, + "key": "~v“­èÚ\u001a'¯\t°'’\u0018`J" + }, + { + "asset_id": "ecc76b6a-25de-4aa8-a5f0-2c1271986c9c/1467337938081000", + "bundle_name": "pm0022", + "version": 4364151763075675600, + "checksum": 3886647129, + "size": 694853, + "key": "µÙ/ZELŒÕ\u001b\báÜ\u001dã4ç" + }, + { + "asset_id": "ece95758-618b-40f4-92b8-97015de97e12/1467338083406000", + "bundle_name": "pm0076", + "version": 4988317885366876000, + "checksum": 1255437993, + "size": 582533, + "key": "Uu]ÈÞ\u0010Y&ÄF’¬ÿ×" + }, + { + "asset_id": "ed66ce66-3013-4a4e-99ea-564351cdddd1/1467338023538000", + "bundle_name": "pm0053", + "version": 4731186783289948000, + "checksum": 2415520234, + "size": 424917, + "key": "\u0004h@¬\u0019k¸ù\u0018çs†ª‰ó·" + }, + { + "asset_id": "ef4b7240-51a4-4e6a-aba2-c50b3db87e8a/1467338220999000", + "bundle_name": "pm0130", + "version": 5579275320525404000, + "checksum": 3564448918, + "size": 474165, + "key": "ƒ¯[D˧|õ*\u000ej!þiŠq" + }, + { + "asset_id": "f03b2196-af8b-48cc-b908-33726f87c2cb/1467338196940000", + "bundle_name": "pm0121", + "version": 5475942702350940000, + "checksum": 1945191842, + "size": 286293, + "key": "\rþx(†¬änylhÐ\u0018÷‹‘" + }, + { + "asset_id": "f1e99bfb-f316-473d-a587-88fbeed3c61d/1467337924726000", + "bundle_name": "pm0017", + "version": 4306792474837595600, + "checksum": 927906204, + "size": 472037, + "key": "Í\"£5¿Iï^ʧ’G?õn" + }, + { + "asset_id": "f2e3b179-4d37-493e-a5ee-2504d8cd4c7f/1467338059623000", + "bundle_name": "pm0067", + "version": 4886170678166108000, + "checksum": 409184053, + "size": 523733, + "key": "Œ\u0018ØUG¼,\u0002q¯©76¾\u0001™" + }, + { + "asset_id": "f3a3150a-9cf9-4adf-9b9c-1fc1dd88a31a/1467337890581000", + "bundle_name": "pm0004", + "version": 4160140816515675600, + "checksum": 2546864236, + "size": 471957, + "key": "\u0013§\u0015âWߒ\u001cýÚ^´ËZ'b" + }, + { + "asset_id": "f65cd1c3-d38c-4eaf-a6d0-731c679a51c9/1467338103657000", + "bundle_name": "pm0084", + "version": 5075295268078172000, + "checksum": 3074575148, + "size": 435141, + "key": "µ9q%eab›M<ÅÇ|,Û" + }, + { + "asset_id": "f9196986-24e0-4ed6-9ab4-da74c18df074/1467337956406000", + "bundle_name": "pm0029", + "version": 4442857038774875600, + "checksum": 3735682586, + "size": 376181, + "key": "ô\ržÚ\u0012̝ðQXS»FæÏö" + }, + { + "asset_id": "faab237d-cf8a-4c73-b5fe-4c04a7acb77e/1467338242729000", + "bundle_name": "pm0138", + "version": 5672604959867484000, + "checksum": 3838369959, + "size": 370773, + "key": "~ߝ²I*j¤Qùt\u0005,‘N<" + }, + { + "asset_id": "fc7d2574-7176-4c18-ba33-9090a0df84d0/1467338274036000", + "bundle_name": "pm0150", + "version": 5807067501003356000, + "checksum": 2612302599, + "size": 474229, + "key": "ó',[,òØ\u0006ÎoïòV®<È" + } +]; \ No newline at end of file diff --git a/src/response.js b/src/response.js index 3fee3a4..ae3d33a 100644 --- a/src/response.js +++ b/src/response.js @@ -26,7 +26,8 @@ import { NicknamePokemon, UpgradePokemon, EvolvePokemon, - SetFavoritePokemon + SetFavoritePokemon, + ClaimCodeName } from "./packets"; /** @@ -40,87 +41,102 @@ export function processResponse(request) { return new Promise((resolve) => { - switch (request.request_type) { - case REQUEST.GET_PLAYER: - this.forwardPlayer().then((res) => resolve(res)); - return void 0; - break; - case REQUEST.GET_HATCHED_EGGS: - buffer = GetHatchedEggs(); - break; - case REQUEST.GET_INVENTORY: - buffer = GetInventory(); - break; - case REQUEST.CHECK_AWARDED_BADGES: - buffer = CheckAwardedBadges(); - break; - case REQUEST.DOWNLOAD_SETTINGS: - buffer = DownloadSettings(); - break; - case REQUEST.DOWNLOAD_ITEM_TEMPLATES: - buffer = ItemTemplates(); - break; - case REQUEST.DOWNLOAD_REMOTE_CONFIG_VERSION: - buffer = DownloadRemoteConfigVersion(); + try { + switch (request.request_type) { + case REQUEST.GET_PLAYER: + this.forwardPlayer().then((res) => resolve(res)); + return void 0; break; - case REQUEST.GET_ASSET_DIGEST: - buffer = GetAssetDigest(); - break; - case REQUEST.GET_PLAYER_PROFILE: - buffer = GetPlayerProfile(); - break; - case REQUEST.GET_MAP_OBJECTS: - this.player.updatePosition(request); - buffer = GetMapObjects(request); - this.savePlayer(player); - break; - case REQUEST.GET_DOWNLOAD_URLS: - buffer = GetDownloadUrls(); - break; - case REQUEST.SET_AVATAR: - player.updateAvatar(request); - buffer = SetAvatar(player); - this.savePlayer(player); - break; - case REQUEST.SFIDA_ACTION_LOG: - buffer = SfidaActionLog(); - break; - case REQUEST.MARK_TUTORIAL_COMPLETE: - buffer = MarkTutorialComplete(player); - this.savePlayer(player); - break; - case REQUEST.LEVEL_UP_REWARDS: - buffer = LevelUpRewards(); - break; - case REQUEST.FORT_DETAILS: - buffer = FortDetails(request); - break; - case REQUEST.FORT_SEARCH: - buffer = FortSearch(); - break; - case REQUEST.SET_CONTACT_SETTINGS: - player.updateContactSettings(request); - buffer = SetContactSettings(player); - this.savePlayer(player); - break; - case REQUEST.ENCOUNTER: - buffer = Encounter(request); - break; - case REQUEST.NICKNAME_POKEMON: - buffer = NicknamePokemon(request); - break; - case REQUEST.UPGRADE_POKEMON: - buffer = UpgradePokemon(request); - break; - case REQUEST.EVOLVE_POKEMON: - buffer = EvolvePokemon(request); - break; - case REQUEST.SET_FAVORITE_POKEMON: - buffer = SetFavoritePokemon(request); - break; - default: - this.print(`Unknown request: ${this.getRequestType(request)}`, 31); - break; + case REQUEST.GET_HATCHED_EGGS: + buffer = GetHatchedEggs(); + break; + case REQUEST.GET_INVENTORY: + buffer = GetInventory(); + break; + case REQUEST.CHECK_AWARDED_BADGES: + buffer = CheckAwardedBadges(); + break; + case REQUEST.DOWNLOAD_SETTINGS: + buffer = DownloadSettings(); + break; + case REQUEST.DOWNLOAD_ITEM_TEMPLATES: + buffer = ItemTemplates(); + break; + case REQUEST.DOWNLOAD_REMOTE_CONFIG_VERSION: + buffer = DownloadRemoteConfigVersion(); + break; + case REQUEST.GET_ASSET_DIGEST: + buffer = GetAssetDigest(request); + break; + case REQUEST.GET_PLAYER_PROFILE: + buffer = GetPlayerProfile(); + break; + case REQUEST.GET_MAP_OBJECTS: + this.player.updatePosition(request); + buffer = GetMapObjects(request); + this.savePlayer(player); + break; + case REQUEST.GET_DOWNLOAD_URLS: + GetDownloadUrls(request, this.generateDownloadUrlByAssetId).then((res) => { + resolve(res); + }); + return void 0; + break; + case REQUEST.SET_AVATAR: + player.updateAvatar(request); + buffer = SetAvatar(player); + this.savePlayer(player); + break; + case REQUEST.SFIDA_ACTION_LOG: + buffer = SfidaActionLog(); + break; + case REQUEST.MARK_TUTORIAL_COMPLETE: + buffer = MarkTutorialComplete(player); + this.savePlayer(player); + break; + case REQUEST.CLAIM_CODENAME: + buffer = ClaimCodeName(request, player); + this.savePlayer(player); + break; + case REQUEST.LEVEL_UP_REWARDS: + buffer = LevelUpRewards(); + break; + case REQUEST.FORT_DETAILS: + buffer = FortDetails(request); + break; + case REQUEST.FORT_SEARCH: + buffer = FortSearch(); + break; + case REQUEST.SET_CONTACT_SETTINGS: + player.updateContactSettings(request); + buffer = SetContactSettings(player); + this.savePlayer(player); + break; + case REQUEST.ENCOUNTER: + buffer = Encounter(request); + break; + case REQUEST.NICKNAME_POKEMON: + buffer = NicknamePokemon(request); + break; + case REQUEST.UPGRADE_POKEMON: + buffer = UpgradePokemon(request); + break; + case REQUEST.EVOLVE_POKEMON: + buffer = EvolvePokemon(request); + break; + case REQUEST.SET_FAVORITE_POKEMON: + buffer = SetFavoritePokemon(request); + break; + case REQUEST.CATCH_POKEMON: + let data = proto.Networking.Requests.Messages.CatchPokemonMessage.decode(request.request_message.toBuffer()); + console.log(data); + break; + default: + this.print(`Unknown request: ${this.getRequestType(request)}`, 31); + break; + }; + } catch (e) { + console.log(e); }; resolve(buffer); diff --git a/src/setup.js b/src/setup.js index 1877d35..09fbc38 100644 --- a/src/setup.js +++ b/src/setup.js @@ -4,23 +4,26 @@ import * as CFG from "../cfg"; export function setup() { - this.print("Booting server...", 33); + this.print("Booting server..", 33); - this.setupMongo(() => { + this.createAssetDownloadSession().then(() => { + this.print("Created asset download session"); + this.setupMongo().then(() => { - this.print("Database connection established"); + this.print("Database connection established"); - if (CFG.SERVER_PORT < 1) { - this.print("Invalid port!", 31); - return void 0; - } + if (CFG.SERVER_PORT < 1) { + this.print("Invalid port!", 31); + return void 0; + } - this.socket = this.createHTTPServer(); + this.socket = this.createHTTPServer(); - setTimeout(this::this.cycle, 1); + setTimeout(this::this.cycle, 1); - this.print(`Server running at ${CFG.SERVER_HOST_IP}:${CFG.SERVER_PORT}`); + this.print(`Server running at ${CFG.SERVER_HOST_IP}:${CFG.SERVER_PORT}`); + }); }); } \ No newline at end of file diff --git a/src/utils.js b/src/utils.js index e726813..0faec1b 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,5 +1,8 @@ import Long from "long"; import proto from "./proto"; +import { DownloadUrls } from "./res"; + +import * as CFG from "../cfg"; /** * @param {Object} cls @@ -44,15 +47,74 @@ export function getHashCodeFrom(str) { }; /** - * @param {Number} hi - * @param {Number} lo - * @param {Boolean} unsigned + * @param {Long} long * @return {Number} */ -export function decodeLong(hi, lo, unsigned) { +export function decodeLong(long) { - let value = Long.fromBits(hi, lo, !!unsigned); + let value = Long.fromBits(long.high, long.low, !!long.unsigned); return (parseInt(value.toString())); +} + +/** + * @param {String} pm + * @return {Object} + */ +export function getDownloadUrl(pm) { + + let ii = 0; + let length = DownloadUrls.length; + + let node = null; + + for (; ii < length; ++ii) { + node = DownloadUrls[ii]; + if (node.bundle_name === pm) { + return (node); + } + }; + + return (null); + +} + +/** + * @param {String} pm + * @return {Object} + */ +export function getDownloadUrlByAssetId(id) { + + let ii = 0; + let length = DownloadUrls.length; + + let node = null; + let index = 0; + + for (; ii < length; ++ii) { + node = DownloadUrls[ii]; + if (node.asset_id.substring(index) === id) { + return (node); + } + }; + + return (null); + +} + +export function getGenerationIdByAssetId(asset_id) { + + let index = asset_id.lastIndexOf("/") + 1; + + return ( + parseInt(asset_id.substring(index)) + ); + +} + +export function randomRequestId() { + return ( + 1e18 - Math.floor(Math.random() * 1e18) + ); } \ No newline at end of file