SkillAgentSearch skills...

MSMC

A bare bones login library for Minecraft based projects to authenticate individuals with a Microsoft account.

Install / Use

/learn @Hanro50/MSMC
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

MSMC

<a href="https://github.com/Hanro50/MSMC/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/msmc" alt="MIT license"/></a> <a href="https://www.npmjs.com/package/msmc"><img src="https://img.shields.io/npm/v/msmc" alt="Version Number"/></a> <a href="https://github.com/Hanro50/MSMC/"><img src="https://img.shields.io/github/stars/hanro50/msmc" alt="Github Stars"/></a>

A bare bones login library for Minecraft based projects to authenticate individuals with a Microsoft account.

Support

Please read the documentation at least once before asking for help. This is an AUTHENTICATION library, you need to own Minecraft to make use of it outside the context of launching the game in demo mode. No assistance will be provided to people who want to use MSMC for the sake of piracy.

<div> <a href="https://discord.gg/3hM8H7nQMA"> <img src="https://img.shields.io/discord/861839919655944213?logo=discord" alt="chat on Discord"></a> </div> At the moment you can get support via Discord (link above).

Examples

A basic ES6 example with MCLC

import { Client } from "minecraft-launcher-core";
const launcher = new Client();
//Import the Auth class
import { Auth } from "msmc";
//Create a new Auth manager
const authManager = new Auth("select_account");
//Launch using the 'raw' gui framework (can be 'electron' or 'nwjs')
const xboxManager = await authManager.launch("raw");
//Generate the Minecraft login token
const token = await xboxManager.getMinecraft();
// Pulled from the Minecraft Launcher core docs.
let opts = {
  clientPackage: null,
  // Simply call this function to convert the msmc minecraft object into a mclc authorization object
  authorization: token.mclc(),
  root: "./.minecraft",
  version: {
    number: "1.18.2",
    type: "release",
  },
  memory: {
    max: "6G",
    min: "4G",
  },
};
console.log("Starting!");
launcher.launch(opts);

launcher.on("debug", (e) => console.log(e));
launcher.on("data", (e) => console.log(e));

A basic commonJS example with MCLC

const { Client } = require("minecraft-launcher-core");
const launcher = new Client();
//Import the Auth class
const { Auth } = require("msmc");
//Create a new Auth manager
const authManager = new Auth("select_account");
//Launch using the 'raw' gui framework (can be 'electron' or 'nwjs')
authManager.launch("raw").then(async (xboxManager) => {
  //Generate the Minecraft login token
  const token = await xboxManager.getMinecraft();
  // Pulled from the Minecraft Launcher core docs.
  let opts = {
    clientPackage: null,
    // Simply call this function to convert the msmc Minecraft object into a mclc authorization object
    authorization: token.mclc(),
    root: "./.minecraft",
    version: {
      number: "1.18.2",
      type: "release",
    },
    memory: {
      max: "6G",
      min: "4G",
    },
  };
  console.log("Starting!");
  launcher.launch(opts);

  launcher.on("debug", (e) => console.log(e));
  launcher.on("data", (e) => console.log(e));
});

A basic commonJS example with GMLL

const gmll = require("gmll");
//Import the Auth class
const { Auth } = require("msmc");

gmll.init().then(async () => {
  //Create a new Auth manager
  const authManager = new Auth("select_account");
  //Launch using the 'raw' gui framework (can be 'electron' or 'nwjs')
  const xboxManager = await authManager.launch("raw");
  //Generate the Minecraft login token
  const token = await xboxManager.getMinecraft();

  var int = new gmll.instance();
  //Launch with the gmll token
  int.launch(token.gmll());
});

A basic ES6 example with GMLL

import { init, instance } from "gmll";
//Import the Auth class
import { Auth } from "msmc";

await init();
//Create a new Auth manager
const authManager = new Auth("select_account");
//Launch using the 'raw' gui framework (can be 'electron' or 'nwjs')
const xboxManager = await authManager.launch("raw");
//Generate the Minecraft login token
const token = await xboxManager.getMinecraft();

var int = new instance();
//Launch with the gmll token
int.launch(token.gmll());

Modules

Auth

This module is the starting point of msmc. It will be the first msmc object you create. It is also the object that'll handle all of msmc's events for you. Mainly the load event.

class Auth extends EventEmitter {
  token: MStoken;
  constructor(prompt?: prompt);
  constructor(token: MStoken);
  createLink(): string;
  login(code: string): Promise<Xbox>;
  refresh(MS: msAuthToken): Promise<Xbox>;
  refresh(refreshToken: string): Promise<Xbox>;
  launch(
    framework: framework,
    windowProperties?: windowProperties,
  ): Promise<Xbox>;
  server(port?: number): Promise<void>;

  on(event: "load", listener: (asset: lexcodes, message: string) => void): this;
  once(
    event: "load",
    listener: (asset: lexcodes, message: string) => void,
  ): this;
}

constructor(prompt?: prompt)

This version of the constructor will generate an Auth object with the vanilla Minecraft launcher token. The prompt variable is a string that provides the prompt field in the vanilla token as that is not provided by default.

type prompt = "login" | "none" | "consent" | "select_account";

To learn more about the prompt type, check out <a href="https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow#request-an-authorization-code">Microsoft's support page</a>. It will provide more details for the possible value of this field.

constructor(token: MStoken) <advanced>

This version of the constructor is for use with custom Microsoft tokens.

interface MStoken {
  client_id: string;
  redirect: string;
  clientSecret?: string;
  prompt?: prompt;
}

The Oauth2 token details needed for you to log people in with Microsoft's service.

Resources:

  1. https://docs.microsoft.com/en-us/graph/auth-register-app-v2
  2. https://docs.microsoft.com/en-us/graph/auth-v2-user#1-register-your-app
  3. https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps

    createLink(): string <advance>

    Creates a login link using the given Token. Can be used if you're forgoing msmc's default gui based login flow for something custom. In essence you should use this link as a redirect, then capture the returning code url-parameter and feed it into the login function

    login(code: string): Promise<Xbox> <advance>

    The low level login function msmc uses. The returning promise is for the next stage in the login chain. Mainly the Xbox module. I'd refer you to the next module to learn more!

returns an instance of the Xbox module or throws an error

refresh(MS: msAuthToken): Promise<Xbox>

The low level refresh function msmc uses. This will attempt to refresh the Microsoft token at the core of msmc and return an Xbox object as a result. Please see the msToken variable under the Xbox module.

interface msAuthToken {
  token_type: string;
  expires_in: number;
  scope: string;
  access_token: string;
  refresh_token: string;
  user_id: string;
  foci: string;
}

The 'refresh_token' and the 'access_token' are the only two fields of note to this project.

returns an instance of the Xbox module or throws an error

refresh(refreshToken: string): Promise<Xbox>

Refreshes a user solely based on the refresh token of a set user's refresh_token. See the save function in the Xbox for more information.

returns an instance of the Xbox module or throws an error

launch(framework: framework, windowProperties?: windowProperties): Promise<Xbox>

Launches a pop-up window prompting the user to login to their Microsoft account.

type framework = "electron" | "nwjs" | "raw";

The supported frameworks are <a title="Build cross-platform desktop apps with JavaScript, HTML, and CSS" src="https://www.electronjs.org/">electron</a>, <a title="NW.js (previously known as node-webkit) lets you call all Node.js modules directly from DOM and enables a new way of writing applications with all Web technologies." src="https://nwjs.io/">nwjs</a> and <a title="Uses a user's native (chromium based) browser. For example the new Microsoft edge. Can be used with launchers written purely in plain vanilla nodejs">raw</a>.

interface windowProperties {
  width: number;
  height: number;
  /**Raw ignores this property!*/
  resizable?: boolean;
  /**Raw only: Stops MSMC from passing through the browser console log*/
  suppress?: boolean;
  [key: string]: any;
}

This is the properties msmc passes through to the function of a set framework that spawns a pop-up. For more information of which properties are available depending on your preferred GUI framework of choice. Click <a href="https://nwjs.readthedocs.io/en/latest/References/Window/#windowopenurl-options-callback">here</a> for nwjs and <a href="https://www.electronjs.org/docs/latest/api/browser-window#class-browserwindow">here</a> for electron. The raw framework only uses the properties "width","height" and "suppress"

returns an instance of the Xbox module or throws an error

server(port?: number): Promise<void> <placeholder>

WIP, not implemented yet

returns an instance of the Xbox module or throws an error

on(event: "load", listener: (asset: lexcodes, message: string) => void): this

Event handler. Fires on a load event. Can be used for loading indicators similar to the update function in previous versions on msmc.

once(event: "load", listener: (asset: lexcodes, message: string) => void): this

The same as the "on" function, but only fires once.

<hr>

Xbox

The second stage of the authentication phase. In this phase the user has been logged in w

Related Skills

View on GitHub
GitHub Stars60
CategoryDevelopment
Updated22d ago
Forks9

Languages

TypeScript

Security Score

95/100

Audited on Mar 4, 2026

No findings