From d6b4e82eb170984380e7ea9f125ea5d72777bef2 Mon Sep 17 00:00:00 2001 From: u9g Date: Wed, 4 Dec 2024 15:22:11 -0500 Subject: [PATCH] Add type to serverKey in server (#1349) * add types to serverKey in server * don't change dep order --- package.json | 1 + src/index.d.ts | 2 ++ src/server/login.js | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/package.json b/package.json index 2eee53d..11cbe1d 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "prismarine-registry": "^1.8.0" }, "dependencies": { + "@types/node-rsa": "^1.1.4", "@types/readable-stream": "^4.0.0", "aes-js": "^3.1.2", "buffer-equal": "^1.0.0", diff --git a/src/index.d.ts b/src/index.d.ts index 4230852..e61d540 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -7,6 +7,7 @@ import { Agent } from 'http' import { Transform } from "readable-stream"; import { BinaryLike, KeyObject } from 'crypto'; import { Realm } from "prismarine-realms" +import NodeRSA from 'node-rsa'; type PromiseLike = Promise | void @@ -166,6 +167,7 @@ declare module 'minecraft-protocol' { motd: string motdMsg?: Object favicon: string + serverKey: NodeRSA close(): void on(event: 'connection', handler: (client: ServerClient) => PromiseLike): this on(event: 'error', listener: (error: Error) => PromiseLike): this diff --git a/src/server/login.js b/src/server/login.js index ad143d3..858b952 100644 --- a/src/server/login.js +++ b/src/server/login.js @@ -8,6 +8,11 @@ const { concat } = require('../transforms/binaryStream') const { mojangPublicKeyPem } = require('./constants') const debug = require('debug')('minecraft-protocol') +/** + * @param {import('../index').Client} client + * @param {import('../index').Server} server + * @param {Object} options + */ module.exports = function (client, server, options) { const mojangPubKey = crypto.createPublicKey(mojangPublicKeyPem) const raise = (translatableError) => client.end(translatableError, JSON.stringify({ translate: translatableError }))