minecraft-protocol
Advanced tools
Comparing version
@@ -24,2 +24,3 @@ # Documentation | ||
* version : 1.8 or 1.9 : default to 1.8 | ||
* favicon (optional) : the favicon to set, base64 encoded | ||
* customPackets (optional) : an object index by version/state/direction/name, see client_custom_packet for an example | ||
@@ -92,4 +93,8 @@ * errorHandler : A way to override the default error handler for client errors. A function that takes a Client and an error. | ||
* host : default to localhost | ||
* clientToken : generated if a password is given | ||
* accessToken : generated if a password or microsoft account is given | ||
* session : An object holding clientToken, accessToken and selectedProfile. Generated after logging in using username + password with mojang auth or after logging in using microsoft auth. `clientToken`, `accessToken` and `selectedProfile: {name: '<username>', id: '<selected profile uuid>'}` can be set inside of `session` when using createClient to login with a client and access Token instead of a password. `session` is also emitted by the `Client` instance with the event 'session' after successful authentication. | ||
* clientToken : generated if a password is given or can be set when when using createClient | ||
* accessToken : generated if a password or microsoft account is given or can be set when using createBot | ||
* selectedProfile : generated if a password or microsoft account is given. Can be set as a object with property `name` and `id` that specifies the selected profile. | ||
* name : The selected profiles in game name needed for logging in with access and client Tokens. | ||
* id : The selected profiles uuid in short form (without `-`) needed for logging in with access and client Tokens. | ||
* authServer : auth server, default to https://authserver.mojang.com | ||
@@ -96,0 +101,0 @@ * sessionServer : session server, default to https://sessionserver.mojang.com |
# History | ||
## 1.30.0 | ||
* add reasons for client.end() & fix issues (@U5B) | ||
## 1.29.1 | ||
* Remove entitlement check in microsoftAuth (#929) | ||
@@ -5,0 +10,0 @@ |
{ | ||
"name": "minecraft-protocol", | ||
"version": "1.29.1", | ||
"version": "1.30.0", | ||
"description": "Parse and serialize minecraft packets, plus authentication and encryption.", | ||
@@ -36,3 +36,3 @@ "main": "src/index.js", | ||
"devDependencies": { | ||
"@types/node": "^16.0.0", | ||
"@types/node": "^17.0.4", | ||
"espower-loader": "^1.0.0", | ||
@@ -39,0 +39,0 @@ "intelli-espower-loader": "^1.0.0", |
@@ -145,3 +145,3 @@ 'use strict' | ||
this.socket.removeListener('timeout', endSocket) | ||
this.emit('end', this._endReason || 'SocketClosed') | ||
this.emit('end', this._endReason || 'socketClosed') | ||
} | ||
@@ -148,0 +148,0 @@ |
@@ -18,3 +18,3 @@ 'use strict' | ||
client.emit('error', err) | ||
client.end() | ||
client.end('encryptionSecretError') | ||
return | ||
@@ -34,3 +34,3 @@ } | ||
client.emit('error', err) | ||
client.end() | ||
client.end('encryptionLoginError') | ||
} else { | ||
@@ -37,0 +37,0 @@ sendEncryptionKeyResponse() |
@@ -17,3 +17,6 @@ 'use strict' | ||
if (timeout) { clearTimeout(timeout) } | ||
timeout = setTimeout(() => client.end(`client timed out after ${checkTimeoutInterval} milliseconds`), checkTimeoutInterval) | ||
timeout = setTimeout(() => { | ||
client.emit('error', new Error(`client timed out after ${checkTimeoutInterval} milliseconds`)) | ||
client.end('keepAliveError') | ||
}, checkTimeoutInterval) | ||
client.write('keep_alive', { | ||
@@ -20,0 +23,0 @@ keepAliveId: packet.keepAliveId |
@@ -15,6 +15,6 @@ module.exports = function (client, options) { | ||
if (!versionRequired) { return } | ||
client.end() | ||
client.emit('error', new Error('This server is version ' + versionRequired + | ||
', you are using version ' + client.version + ', please specify the correct version in the options.')) | ||
', you are using version ' + client.version + ', please specify the correct version in the options.')) | ||
client.end('differentVersionError') | ||
}) | ||
} |
@@ -18,3 +18,3 @@ /// <reference types="node" /> | ||
username: string | ||
session?: any | ||
session?: SessionOption | ||
profile?: any | ||
@@ -38,3 +38,3 @@ latency: number | ||
on(event: 'raw', handler: (buffer: Buffer, packetMeta: PacketMeta) => PromiseLike): this | ||
on(event: 'session', handler: (session: any) => PromiseLike): this | ||
on(event: 'session', handler: (session: SessionObject) => PromiseLike): this | ||
on(event: 'state', handler: (newState: States, oldState: States) => PromiseLike): this | ||
@@ -56,2 +56,28 @@ on(event: 'end', handler: (reason: string) => PromiseLike): this | ||
export interface SessionOption { | ||
accessToken: string, | ||
/** My be needed for mojang auth. Is send by mojang on username + password auth */ | ||
clientToken?: string, | ||
selectedProfile: SessionProfile | ||
} | ||
export interface SessionObject { | ||
accessToken: string, | ||
/** My be needed for mojang auth. Is send by mojang on username + password auth */ | ||
clientToken?: string, | ||
selectedProfile: { | ||
name: string | ||
id: string | ||
} | ||
availableProfiles?: SessionProfile[] | ||
availableProfile?: SessionProfile[] | ||
} | ||
interface SessionProfile { | ||
/** Character in game name */ | ||
name: string | ||
/** Character UUID in short form */ | ||
id: string | ||
} | ||
export interface ClientOptions { | ||
@@ -83,3 +109,3 @@ username: string | ||
id?: number | ||
session?: SessionOption | ||
} | ||
@@ -123,2 +149,3 @@ | ||
version?: string | ||
favicon?: string | ||
customPackets?: any | ||
@@ -125,0 +152,0 @@ errorHandler?: (client: Client, error: Error) => void |
@@ -37,2 +37,3 @@ 'use strict' | ||
clearTimeout(closeTimer) | ||
client.end() | ||
reject(err) | ||
@@ -39,0 +40,0 @@ }) |
Sorry, the diff of this file is not supported yet
199817
0.97%4060
0.72%