From 4dc8431dcb262aee1ed74241e7a541d9645063a9 Mon Sep 17 00:00:00 2001 From: Tim203 Date: Tue, 27 Aug 2024 15:53:11 +0200 Subject: [PATCH] Decode the JWT --- lib/global_api/skins/skin_storage.ex | 50 ++++++++++++---------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/lib/global_api/skins/skin_storage.ex b/lib/global_api/skins/skin_storage.ex index 18cef96..ae3bece 100644 --- a/lib/global_api/skins/skin_storage.ex +++ b/lib/global_api/skins/skin_storage.ex @@ -4,36 +4,30 @@ defmodule GlobalApi.Skins.SkinStorage do alias GlobalApi.Schema.SkinStorage, as: Schema def store(client_data, convert_code) do - # Keep: SkinImageHeight, SkinImageWidth, SkinResourcePatch, SkinGeometryDataEngineVersion, SkinGeometryData, SkinData, SkinAnimationData, - # PremiumSkin, PersonaSkin, CapeOnClassicSkin, CapeImageWidth, CapeImageHeight, CapeData, ArmSize, AnimatedImageData. - # The other keys will only result in storing duplicate data + # Only keep the payload of the JWT + [_, payload, _] = String.split(client_data, ".") + + # Keep only specific keys, the other keys will only result in storing duplicate data final_data = - client_data + payload + |> Base.url_decode64!(padding: false) |> Jason.decode!() - |> Map.drop([ - :CapeId, - :ClientRandomId, - :CurrentInputMode, - :DefaultInputMode, - :DeviceId, - :DeviceModel, - :DeviceOS, - :GameVersion, - :GuiScale, - :IsEditorMode, - :LanguageCode, - :PersonaPieces, - :PieceTintColors, - :PlatformOfflineId, - :PlatformOnlineId, - :PlayFabId, - :SelfSignedId, - :ServerAddress, - :SkinColor, - :SkinId, - :ThirdPartyName, - :ThirdPartyNameOnly, - :UIProfile + |> Map.take([ + :SkinResourcePatch, + :SkinGeometryData, + :SkinGeometryDataEngineVersion, + :SkinImageWidth, + :SkinImageHeight, + :SkinData, + :SkinAnimationData, + :AnimatedImageData, + :ArmSize, + :CapeOnClassicSkin, + :CapeImageWidth, + :CapeImageHeight, + :CapeData, + :PremiumSkin, + :PersonaSkin ]) |> Jason.encode!()