Skip to content

Commit

Permalink
Decode the JWT
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim203 committed Aug 27, 2024
1 parent e53262a commit 4dc8431
Showing 1 changed file with 22 additions and 28 deletions.
50 changes: 22 additions & 28 deletions lib/global_api/skins/skin_storage.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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!()

Expand Down

0 comments on commit 4dc8431

Please sign in to comment.