New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

minecraft-protocol

Package Overview
Dependencies
Maintainers
7
Versions
176
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minecraft-protocol - npm Package Compare versions

Comparing version 1.27.2 to 1.28.0

7

docs/API.md

@@ -107,2 +107,3 @@ # Documentation

* agent : a http agent that can be used to set proxy settings for yggdrasil authentication (see proxy-agent on npm)
* fakeHost : (optional) hostname to send to the server in the set_protocol packet
* profilesFolder : optional

@@ -279,5 +280,5 @@ * (mojang account) the path to the folder that contains your `launcher_profiles.json`. defaults to your minecraft folder if it exists, otherwise the local directory. set to `false` to disable managing profiles

`options` is an object containing the following:
* host : default too locahost
* port : default too 25565
* version: default too most recent version
* host : default to localhost
* port : default to 25565
* version: default to most recent version

@@ -284,0 +285,0 @@ Ping a minecraft server and return a promise or use an optional callback containing the information about it

# History
## 1.28.0
* Fixed TypeScript error TS2769 when authenticating with mojang (#922) (@liquiddevelopmentnet)
* Update prismarine-auth usage (#923) (@extremeheat)
* types(Client): fix events (#918) (@muchnameless and Robert Hartmann)
* add default for authTitle (#920) (@U5B)
* Update ping function return type and make callback optional (#909) (@ShayBox)
* Fixed typo's (#915) (@OscarNOW)
* Add the ability to send a fake hostname in set_protocol (#913) (@GhqstMC and u9g)
## 1.27.2

@@ -4,0 +13,0 @@

@@ -5,4 +5,5 @@ 'use strict'

if (process.argv.length < 4 || process.argv.length > 6) {
console.log('Usage : node echo.js <host> <port> [<email>] [<password>]')
const [,, host, port, userOrEmail, password] = process.argv
if (!userOrEmail) {
console.log('Usage : node client_microsoft_auth.js <host> <port> <username/email> [<password>]')
process.exit(1)

@@ -12,6 +13,6 @@ }

const client = mc.createClient({
host: process.argv[2],
port: parseInt(process.argv[3]),
username: process.argv[4], // your microsoft account email
password: process.argv[5], // your microsoft account password
host,
port: parseInt(port),
username: userOrEmail, // your microsoft account email
password: password, // your microsoft account password
auth: 'microsoft' // This option must be present and set to 'microsoft' to use Microsoft Account Authentication. Failure to do so will result in yggdrasil throwing invalid account information.

@@ -18,0 +19,0 @@ })

{
"name": "minecraft-protocol",
"version": "1.27.2",
"version": "1.28.0",
"description": "Parse and serialize minecraft packets, plus authentication and encryption.",

@@ -58,3 +58,3 @@ "main": "src/index.js",

"prismarine-auth": "^1.1.0",
"prismarine-nbt": "^1.3.0",
"prismarine-nbt": "^2.0.0",
"protodef": "^1.8.0",

@@ -61,0 +61,0 @@ "readable-stream": "^3.0.6",

const path = require('path')
const { Authflow: PrismarineAuth } = require('prismarine-auth')
const { Authflow: PrismarineAuth, Titles } = require('prismarine-auth')
const minecraftFolderPath = require('minecraft-folder-path')

@@ -11,11 +11,21 @@ const debug = require('debug')('minecraft-protocol')

if (options.authTitle === undefined) {
options.authTitle = Titles.MinecraftNintendoSwitch
options.deviceType = 'Nintendo'
}
const Authflow = new PrismarineAuth(options.username, options.profilesFolder, options, options.onMsaCode)
const { token, entitlements, profile } = await Authflow.getMinecraftJavaToken({ fetchEntitlements: true, fetchProfile: true })
const { token, entitlements, profile } = await Authflow.getMinecraftJavaToken({ fetchEntitlements: true, fetchProfile: true }).catch(e => {
if (options.password) console.warn('Sign in failed, try removing the password field\n')
if (e.toString().includes('Not Found')) console.warn(`Please verify that the account ${options.username} owns Minecraft\n`)
throw e
})
if (entitlements.items.length === 0) throw Error('This user does not possess any entitlements on this account according to minecraft services.')
debug('[mc] entitlements', entitlements)
debug('[mc] profile', profile)
if (!entitlements?.items) throw Error(`Signed in account ${options.username} doesn't appear to own Minecraft`)
if (profile?.error) throw Error(`Failed to obtain profile data for ${options.username}, does the account own minecraft?`)
options.haveCredentials = token !== null
if (profile.error) throw Error(`Failed to obtain profile data for ${options.username}, does the account own minecraft?\n${profile}`)
debug('[mc] profile', profile)

@@ -22,0 +32,0 @@ const session = {

@@ -18,2 +18,3 @@ 'use strict'

if (client.tagHost) taggedHost += client.tagHost
if (client.fakeHost) taggedHost = options.fakeHost

@@ -20,0 +21,0 @@ client.write('set_protocol', {

@@ -34,11 +34,2 @@ /// <reference types="node" />

writeChannel(channel: any, params: any): void
on(event: 'packet', handler: (data: any, packetMeta: PacketMeta, buffer: Buffer, fullBuffer: Buffer) => void): this
on(event: 'raw', handler: (buffer: Buffer, packetMeta: PacketMeta) => void): this
on(event: 'connect', handler: () => unknown): this
on(event: 'end', handler: (reason: string) => void): this
on(event: 'session', handler: (session: any) => void): this
on(event: 'state', handler: (newState: States, oldState: States) => void): this
on(event: 'error', listener: (error: Error) => void): this
on(event: string, handler: (data: any, packetMeta: PacketMeta) => unknown): this
on(event: `raw.${string}`, handler: (buffer: Buffer, packetMeta: PacketMeta) => unknown): this
on(event: 'error', listener: (error: Error) => PromiseLike): this

@@ -53,2 +44,11 @@ on(event: 'packet', handler: (data: any, packetMeta: PacketMeta, buffer: Buffer, fullBuffer: Buffer) => PromiseLike): this

on(event: `raw.${string}`, handler: (buffer: Buffer, packetMeta: PacketMeta) => PromiseLike): this
once(event: 'error', listener: (error: Error) => PromiseLike): this
once(event: 'packet', handler: (data: any, packetMeta: PacketMeta, buffer: Buffer, fullBuffer: Buffer) => PromiseLike): this
once(event: 'raw', handler: (buffer: Buffer, packetMeta: PacketMeta) => PromiseLike): this
once(event: 'sessionce', handler: (sessionce: any) => PromiseLike): this
once(event: 'state', handler: (newState: States, oldState: States) => PromiseLike): this
once(event: 'end', handler: (reasonce: string) => PromiseLike): this
once(event: 'concenect', handler: () => PromiseLike): this
once(event: string, handler: (data: any, packetMeta: PacketMeta) => PromiseLike): this
once(event: `raw.${string}`, handler: (buffer: Buffer, packetMeta: PacketMeta) => PromiseLike): this
}

@@ -65,2 +65,3 @@

authServer?: string
authTitle?: string
sessionServer?: string

@@ -78,5 +79,7 @@ keepAlive?: boolean

agent?: Agent
fakeHost?: string
profilesFolder?: string
onMsaCode?: (data: MicrosoftDeviceAuthorizationResponse) => void
id?: number
}

@@ -164,2 +167,4 @@

version?: string
closeTimeout?: number
noPongTimeout?: number
}

@@ -172,3 +177,3 @@

prefix: string
protocol: string
protocol: number
version: string

@@ -178,7 +183,10 @@ }

export interface NewPingResult {
description: string
description: {
text?: string
extra?: any[]
} | string
players: {
max: number
online: number
sample: {
sample?: {
id: string

@@ -190,5 +198,5 @@ name: string

name: string
protocol: string
protocol: number
}
favicon: string
favicon?: string
latency: number

@@ -207,3 +215,3 @@ }

export function ping(options: PingOptions, callback: (error: Error, result: OldPingResult | NewPingResult) => void): void
}
export function ping(options: PingOptions, callback?: (error: Error, result: OldPingResult | NewPingResult) => void): Promise<OldPingResult | NewPingResult>
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc