Add basic deserializer and serializer typings (#975)

This commit is contained in:
IceTank 2022-04-10 15:16:18 +02:00 committed by GitHub
parent 68e6400e30
commit 5e3196b2de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

21
src/index.d.ts vendored
View file

@ -4,6 +4,7 @@ import { EventEmitter } from 'events';
import { Socket } from 'net'
import * as Stream from 'stream'
import { Agent } from 'http'
import { Transform } from "readable-stream";
type PromiseLike = Promise<void> | void
@ -17,6 +18,8 @@ declare module 'minecraft-protocol' {
username: string
session?: SessionOption
profile?: any
deserializer: FullPacketParser
serializer: Serializer
latency: number
customPackets: any
protocolVersion: number
@ -51,6 +54,24 @@ declare module 'minecraft-protocol' {
once(event: `raw.${string}`, handler: (buffer: Buffer, packetMeta: PacketMeta) => PromiseLike): this
}
class FullPacketParser extends Transform {
proto: any
mainType: any
noErrorLogging: boolean
constructor (proto: any, mainType: any, noErrorLogging?: boolean)
parsePacketBuffer(buffer: Buffer): any
}
class Serializer extends Transform {
proto: any
mainType: any
queue: Buffer
constructor(proto: any, mainType: any)
createPacketBuffer(packet: any): any
}
export interface SessionOption {
accessToken: string,
/** My be needed for mojang auth. Is send by mojang on username + password auth */