Documentation ¶
Index ¶
- func Decode(requestString []byte) (IdentityData, ClientData, error)
- func Encode(loginChain string, data ClientData, key *ecdsa.PrivateKey) []byte
- func EncodeOffline(identityData IdentityData, data ClientData, key *ecdsa.PrivateKey) []byte
- func Verify(requestString []byte) (publicKey *ecdsa.PublicKey, authenticated bool, err error)
- type Chain
- type ClientData
- type IdentityData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶ added in v0.1.0
func Decode(requestString []byte) (IdentityData, ClientData, error)
Decode decodes the login request string passed into an IdentityData struct, which contains trusted identity data such as the UUID of the player, and ClientData, which contains user specific data such as the skin of a player. Decode does not verify the request passed. For that reason, login.Verify() should be called on that same string before login.Decode().
func Encode ¶
func Encode(loginChain string, data ClientData, key *ecdsa.PrivateKey) []byte
Encode encodes a login request using the encoded login chain passed and the client data. The request's client data token is signed using the private key passed. It must be the same as the one used to get the login chain.
func EncodeOffline ¶
func EncodeOffline(identityData IdentityData, data ClientData, key *ecdsa.PrivateKey) []byte
EncodeOffline creates a login request using the identity data and client data passed. The private key passed will be used to self sign the JWTs. Unlike Encode, EncodeOffline does not have a token signed by the Mojang key. It consists of only one JWT which holds the identity data of the player.
Types ¶
type Chain ¶ added in v0.1.0
type Chain []string
Chain holds a chain with claims, each with their own headers, payloads and signatures. Each claim holds a public key used to verify other claims.
type ClientData ¶
type ClientData struct { // AnimatedImageData is a list of image data for animations. Each of the elements in this slice holds the // image data of a single frame of the animation. AnimatedImageData []struct { // Frames is the amount of frames of the animation. The number of Frames here specifies how many // frames may be found in the Image data. Frames float64 // Image is a base64 encoded byte slice of ImageWidth * ImageHeight bytes. It is an RGBA ordered byte // representation of the animation image pixels. The ImageData contains FrameCount images in it, which // each represent one stage of the animation. The actual part of the skin that this field holds // depends on the Type, where SkinAnimationHead holds only the head and its hat, whereas the other // animations hold the entire body of the skin. Image string // ImageHeight and ImageWidth are the dimensions of the animated image. Note that the size of this // image is not always 32/64/128. ImageHeight, ImageWidth int // Type is the type of the animation, which defines what part of the body the Image data holds. It is // one of the following: // 0 -> 'None', doesn't typically occur. // 1 -> Face animation. // 2 -> 32x32 Body animation. // 3 -> 128x128 Body animation. Type int } // CapeData is a base64 encoded string of cape data. This is usually an empty string, as skins typically // don't carry capes themselves. CapeData string // CapeID is an ID which, like the SkinID, identifies a skin. Usually this is either empty for no skin or // some ID containing a UUID in it. CapeID string `json:"CapeId"` // CapeImageHeight and CapeImageWidth are the dimensions of the cape's image. CapeImageHeight, CapeImageWidth int // CapeOnClassicSkin specifies if the cape that the player has equipped is part of a classic skin, which // usually points to one of the older MineCon capes. CapeOnClassicSkin bool // ClientRandomID is a random client ID number generated for the client. It usually remains consistent // through sessions and through game restarts. ClientRandomID int64 `json:"ClientRandomId"` // CurrentInputMode is the input mode used by the client. It is 1 for mobile and win10, but is different // for console input. CurrentInputMode int // DefaultInputMode is the default input mode used by the device. DefaultInputMode int // DeviceModel is a string indicating the device model used by the player. At the moment, it appears that // this name is always '(Standard system devices) System devices'. DeviceModel string // DeviceOS is a numerical ID indicating the OS of the device. DeviceOS device.OS // DeviceID is a UUID specific to the device. A different user will have the same UUID for this. DeviceID string `json:"DeviceId"` // GameVersion is the game version of the player that attempted to join, for example '1.11.0'. GameVersion string // GUIScale is the GUI scale of the player. It is by default 0, and is otherwise -1 or -2 for a smaller // GUI scale than usual. GUIScale int `json:"GuiScale"` // LanguageCode is the language code of the player. It looks like 'en_UK'. It follows the ISO language // codes, but hyphens ('-') are replaced with underscores. ('_') LanguageCode string // PersonaSkin specifies if the skin was a persona skin, meaning that it was created through the in-game // skin creator. PersonaSkin bool // PlatformOfflineID is either a UUID or an empty string ... PlatformOfflineID string `json:"PlatformOfflineId"` // PlatformOnlineID is either a UUID or an empty string ... PlatformOnlineID string `json:"PlatformOnlineId"` // PlatformUserID holds a UUID which is only sent if the DeviceOS is of type device.XBOX. Its function // is not exactly clear. PlatformUserID string `json:"PlatformUserId,omitempty"` // PremiumSkin indicates if the skin the player held was a premium skin, meaning it was obtained through // payment. PremiumSkin bool // SelfSignedID is a UUID that remains consistent through restarts of the game and new game sessions. SelfSignedID string `json:"SelfSignedId"` // ServerAddress is the exact address the player used to join the server with. This may be either an // actual address, or a hostname. ServerAddress also has the port in it, in the shape of // 'address:port`. ServerAddress string // TODO: Find out what value SkinAnimationData holds and when it does hold something. SkinAnimationData string // SkinData is a base64 encoded byte slice of 64*32*4, 64*64*4 or 128*128*4 bytes. It is a RGBA ordered // byte representation of the skin colours. SkinData string // SkinGeometry is a base64 JSON encoded structure of the geometry data of a skin, containing properties // such as bones, uv, pivot etc. SkinGeometry string `json:"SkinGeometryData"` // SkinID is a unique ID produced for the skin, for example 'c18e65aa-7b21-4637-9b63-8ad63622ef01_Alex' // for the default Alex skin. SkinID string `json:"SkinId"` // SkinImageHeight and SkinImageWidth are the dimensions of the skin's image data. SkinImageHeight, SkinImageWidth int // SkinResourcePatch is a base64 encoded string which holds JSON data. The content of the JSON data seems // to point to the geometry of the skin, including the animated geometry, but I'm not sure on its exact // function. SkinResourcePatch string // ThirdPartyName is the username of the player. This username should not be used however. The DisplayName // sent in the IdentityData should be preferred over this. ThirdPartyName string // ThirdPartyNameOnly specifies if the user only has a third party name. It should always be assumed to be // false, because the third party name is not XBOX Live Auth protected, meaning it can be tempered with // and the username changed. // Although this field is obviously here for a reason, allowing this is too dangerous and should never be // done. ThirdPartyNameOnly bool // UIProfile is the UI profile used. For the 'Pocket' UI, this is 1. For the 'Classic' UI, this is 0. UIProfile int }
ClientData is a container of client specific data of a Login packet. It holds data such as the skin of a player, but also its language code and device information.
func (ClientData) Validate ¶
func (data ClientData) Validate() error
Validate validates the client data. It returns an error if any of the fields checked did not carry a valid value.
type IdentityData ¶
type IdentityData struct { // XUID is the XBOX Live user ID of the player, which will remain consistent as long as the player is // logged in with the XBOX Live account. XUID string // Identity is the UUID of the player, which will also remain consistent for as long as the user is logged // into its XBOX Live account. Identity string `json:"identity"` // DisplayName is the username of the player, which may be changed by the user. It should for that reason // not be used as a key to store information. DisplayName string `json:"displayName"` }
IdentityData contains identity data of the player logged in. It is found in one of the JWT claims signed by Mojang, and can thus be trusted.
func (IdentityData) Validate ¶
func (data IdentityData) Validate() error
Validate validates the identity data. It returns an error if any data contained in the IdentityData is invalid.