From 3e276479cd231cc7fc570c5666d1aba0e054edde Mon Sep 17 00:00:00 2001 From: Hanro Date: Thu, 15 Jul 2021 00:37:30 +0200 Subject: [PATCH] Added launch hooks needed by Microsoft authentication (#77) * Added launch hooks needed by Microsoft authentication Added a meta field to the interface IUser that implements a new interface called IMeta IMeta contains information about if the account is a mojang or microsoft account. It also contains information stating if a set account is a demo account (I just thought it could be useful) I also added checks to components/handler.js to use the new field. If the field is absent, a filler value will be used that will make mclc behave as it did before this change. * Moved the meta field inline Just a typescript change for better consistency with the rest of the type files. * Update index.d.ts Properly managed to debug the vanilla launcher and fixed this oversight It marks it with xbox as the type in the vanilla launcher's files, but the real arg pushed is msa. --- components/handler.js | 8 ++++++-- index.d.ts | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/components/handler.js b/components/handler.js index f0d17fc..ef1d4c4 100644 --- a/components/handler.js +++ b/components/handler.js @@ -551,14 +551,14 @@ class Handler { if (args.length < minArgs) args = args.concat(this.version.minecraftArguments ? this.version.minecraftArguments.split(' ') : this.version.arguments.game) this.options.authorization = await Promise.resolve(this.options.authorization) - + this.options.authorization.meta = this.options.authorization.meta ? this.options.authorization.meta : { type: 'mojang' } const fields = { '${auth_access_token}': this.options.authorization.access_token, '${auth_session}': this.options.authorization.access_token, '${auth_player_name}': this.options.authorization.name, '${auth_uuid}': this.options.authorization.uuid, '${user_properties}': this.options.authorization.user_properties, - '${user_type}': 'mojang', + '${user_type}': this.options.authorization.meta.type, '${version_name}': this.options.version.number, '${assets_index_name}': this.version.assetIndex.id, '${game_directory}': this.options.overrides.gameDirectory || this.options.root, @@ -567,6 +567,10 @@ class Handler { '${version_type}': this.options.version.type } + if (this.options.authorization.meta.demo) { + args.push('--demo') + } + for (let index = 0; index < args.length; index++) { if (typeof args[index] === 'object') args.splice(index, 2) if (Object.keys(fields).includes(args[index])) { diff --git a/index.d.ts b/index.d.ts index bb5391e..19c55cc 100644 --- a/index.d.ts +++ b/index.d.ts @@ -143,12 +143,18 @@ declare module "minecraft-launcher-core" { authorization: Promise; } + + interface IUser { access_token: string; client_token: string; uuid: string; name: string; user_properties: Partial; + meta?: { + type: "mojang" | "msa", + demo?: boolean + }; } interface IProfile {