As a response to C2S::LOGIN message server sends S2C::SIGN_REQUEST to confirm identity with message signing.
struct s2c_sign_request_t {
char type; // MSG_S2C_SIGN_REQUEST
char msg_length; // Length of the message to sign
char msg[msg_length]; // Message to sign
};
Client has to reply with C2S::SIGNATURE message to successfully login on a server. Bots may calculate the signature automatically based on private keys, game in a browser may use wallet APIs to request signing of the message. Alternatively, user may be provided with a plain message to sign and to sign it manually with any other tools available.
socket.onmessage = function(event) {
const view = new Uint8Array(event.data);
switch (view[0]) {
case MSG_S2C_SIGN_REQUEST:
{
let msg = "";
for (let i = 0; i < view[1]; i++) {
msg += String.fromCharCode(view[i + 2]);
}
console.log("To sign: " + msg);
}
...