mirror of
https://github.com/artegoser/pimi-launcher-core.git
synced 2024-11-22 04:06:21 +03:00
ForgeWrapper & Auth changes
This commit is contained in:
parent
3e276479cd
commit
6af7b10f86
7 changed files with 36 additions and 2143 deletions
11
README.md
11
README.md
|
@ -111,7 +111,14 @@ let opts = {
|
|||
defaultRepoForge: "https://libraries.minecraft.net/", // for Forge only, you need to redefine the library url
|
||||
// in the version json.
|
||||
fallbackMaven: "https://search.maven.org/remotecontent?filepath="
|
||||
}
|
||||
},
|
||||
// The following is options for which version of ForgeWrapper MCLC uses. This allows us to launch modern Forge.
|
||||
fw: {
|
||||
baseUrl: 'https://github.com/ZekerZhayard/ForgeWrapper/releases/download/',
|
||||
version: '1.5.1',
|
||||
sh1: '90104e9aaa8fbedf6c3d1f6d0b90cabce080b5a9',
|
||||
size: 29892,
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
@ -130,6 +137,7 @@ This runs an executable with specified launch arguments. Was used to support For
|
|||
|-----------|--------|--------------------------------------------------------------|----------|
|
||||
| `username`| String | Email or username | True |
|
||||
| `password`| String | Password for the Mojang account being used if online mode. | False |
|
||||
| `client_token`| String | Client token that will be used. If one is not specified, one will be generated | False |
|
||||
|
||||
##### validate
|
||||
|
||||
|
@ -144,7 +152,6 @@ This runs an executable with specified launch arguments. Was used to support For
|
|||
|--------------------|--------|-------------------------------------------------------------------------------------|----------|
|
||||
| `access_token` | String | Token being checked if it can be used to login with (online mode). | True |
|
||||
| `client_token` | String | Token being checked if it's the same client that the access_token was created from. | True |
|
||||
| `selected_profile` | Object | Json Object that was returned from Mojang's auth api. | True |
|
||||
|
||||
##### invalidate
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
const request = require('request')
|
||||
const uuid = require('uuid/v1')
|
||||
const uuid = require('uuid').v1
|
||||
let api_url = 'https://authserver.mojang.com'
|
||||
|
||||
module.exports.getAuth = function (username, password) {
|
||||
module.exports.getAuth = function (username, password, client_token = null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!password) {
|
||||
const user = {
|
||||
access_token: uuid(),
|
||||
client_token: uuid(),
|
||||
client_token: client_token || uuid(),
|
||||
uuid: uuid(),
|
||||
name: username,
|
||||
user_properties: '{}'
|
||||
|
@ -69,14 +69,13 @@ module.exports.validate = function (access_token, client_token) {
|
|||
})
|
||||
}
|
||||
|
||||
module.exports.refreshAuth = function (accessToken, clientToken, selectedProfile) {
|
||||
module.exports.refreshAuth = function (accessToken, clientToken) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const requestObject = {
|
||||
url: api_url + '/refresh',
|
||||
json: {
|
||||
accessToken: accessToken,
|
||||
clientToken: clientToken,
|
||||
selectedProfile: selectedProfile,
|
||||
requestUser: true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -320,7 +320,7 @@ class Handler {
|
|||
if (fs.existsSync(versionPath)) {
|
||||
try {
|
||||
json = JSON.parse(fs.readFileSync(versionPath))
|
||||
if (!json.forgeWrapperVersion || !(json.forgeWrapperVersion === this.options.fw.version)) {
|
||||
if (!json.forgeWrapperVersion || !(json.forgeWrapperVersion === this.options.overrides.fw.version)) {
|
||||
this.client.emit('debug', '[MCLC]: Old ForgeWrapper has generated this version JSON, re-generating')
|
||||
} else {
|
||||
// If forge is modern, add ForgeWrappers launch arguments and set forge to null so MCLC treats it as a custom json.
|
||||
|
@ -362,16 +362,16 @@ class Handler {
|
|||
// If forge is modern and above 1.12.2, we add ForgeWrapper to the libraries so MCLC includes it in the classpaths.
|
||||
if (json.inheritsFrom !== '1.12.2') {
|
||||
this.fwAddArgs()
|
||||
const fwName = `ForgeWrapper-${this.options.fw.version}.jar`
|
||||
const fwPathArr = ['io', 'github', 'zekerzhayard', 'ForgeWrapper', this.options.fw.version]
|
||||
const fwName = `ForgeWrapper-${this.options.overrides.fw.version}.jar`
|
||||
const fwPathArr = ['io', 'github', 'zekerzhayard', 'ForgeWrapper', this.options.overrides.fw.version]
|
||||
json.libraries.push({
|
||||
name: fwPathArr.join(':'),
|
||||
downloads: {
|
||||
artifact: {
|
||||
path: [...fwPathArr, fwName].join('/'),
|
||||
url: `${this.options.fw.baseUrl}${this.options.fw.version}/${fwName}`,
|
||||
sha1: this.options.fw.sh1,
|
||||
size: this.options.fw.size
|
||||
url: `${this.options.overrides.fw.baseUrl}${this.options.overrides.fw.version}/${fwName}`,
|
||||
sha1: this.options.overrides.fw.sh1,
|
||||
size: this.options.overrides.fw.size
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -20,14 +20,17 @@ class MCLCore extends EventEmitter {
|
|||
...this.options.overrides
|
||||
? this.options.overrides.url
|
||||
: undefined
|
||||
},
|
||||
fw: {
|
||||
baseUrl: 'https://github.com/ZekerZhayard/ForgeWrapper/releases/download/',
|
||||
version: '1.5.1',
|
||||
sh1: '90104e9aaa8fbedf6c3d1f6d0b90cabce080b5a9',
|
||||
size: 29892,
|
||||
...this.options.overrides
|
||||
? this.options.overrides.fw
|
||||
: undefined
|
||||
}
|
||||
}
|
||||
this.options.fw = {
|
||||
baseUrl: 'https://github.com/ZekerZhayard/ForgeWrapper/releases/download/',
|
||||
version: '1.4.2',
|
||||
sh1: '79ff9c1530e8743450c5c3ebc6e07b535437aa6e',
|
||||
size: 22346
|
||||
}
|
||||
|
||||
this.handler = new Handler(this)
|
||||
|
||||
|
|
7
index.d.ts
vendored
7
index.d.ts
vendored
|
@ -22,6 +22,12 @@ declare module "minecraft-launcher-core" {
|
|||
defaultRepoForge?: string;
|
||||
fallbackMaven?: string;
|
||||
};
|
||||
fw?: {
|
||||
baseUrl?: string;
|
||||
version?: string;
|
||||
sh1?: string;
|
||||
size?: number;
|
||||
};
|
||||
}
|
||||
|
||||
interface ILauncherOptions {
|
||||
|
@ -185,7 +191,6 @@ declare module "minecraft-launcher-core" {
|
|||
refreshAuth(
|
||||
access_token: string,
|
||||
client_token: string,
|
||||
selectedProfile: IProfile
|
||||
): Promise<IUser>;
|
||||
/**
|
||||
*
|
||||
|
|
2121
package-lock.json
generated
2121
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -1,13 +1,13 @@
|
|||
{
|
||||
"name": "minecraft-launcher-core",
|
||||
"version": "3.16.4",
|
||||
"version": "3.16.5",
|
||||
"description": "Lightweight module that downloads and runs Minecraft using javascript / NodeJS",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"adm-zip": "^0.4.13",
|
||||
"checksum": "^0.1.1",
|
||||
"request": "^2.88.0",
|
||||
"uuid": "^3.3.2"
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.0.27",
|
||||
|
|
Loading…
Add table
Reference in a new issue