NexusN
Denoβ€’15mo agoβ€’
2 replies
Nexus

PEM Base64 Error while using mineflayer NPM Package

Hello.

I am interested in using Deno to build a Minecraft player bot. I used the minelayer package and the Deno runtime. I wrote simple code that should log in to the player using Microsoft authentication.
I am using Deno version 2.0.3, which is running on aarch64 Linux.
I am also running mineflayer version 4.23.0.

I am currently attempting to run this code:
I put placeholders for privacy sake, however I don't believe that should matter too much.

import mineflayer from "mineflayer";

console.log("Hello, world!");
const bot = mineflayer.createBot({
    host: "[remote ip]",
    port: 25565,
    username: "[username]",
    auth: "microsoft",
    version: "1.20.4",
});

bot.on("login", () => {
    bot.chat("Hello, world!");
});


After authenticating with a Microsoft account. I get this strange error:
error: Uncaught (in promise) Error: ASN.1 error: PEM error: PEM Base64 error: invalid Base64 encoding
    at Object.publicEncrypt (ext:deno_node/internal/crypto/cipher.ts:221:10)
    at sendEncryptionKeyResponse (file:///home/[username]/.cache/deno/npm/registry.npmjs.org/minecraft-protocol/1.50.0/src/client/encrypt.js:49:52)
    at onJoinServerResponse (file:///home/[username]/.cache/deno/npm/registry.npmjs.org/minecraft-protocol/1.50.0/src/client/encrypt.js:36:11)
    at file:///home/[username]/.cache/deno/npm/registry.npmjs.org/yggdrasil/1.7.0/src/utils.js:73:15
    at Object.runMicrotasks (ext:core/01_core.js:672:26)
    at processTicksAndRejections (ext:deno_node/_next_tick.ts:57:10)
    at runNextTicks (ext:deno_node/_next_tick.ts:74:3)
    at eventLoopTick (ext:core/01_core.js:182:21)


This code works as intended using the latest version of node js, which is 23.0.0-1.
Steps to reproduce:
1. Install mineflayer package. deno add npm:mineflayer
2. Write above code.
3. Run script and authenticate. deno run main.ts
4. Observe error.
Was this page helpful?