mirror of
https://github.com/artegoser/pimi-launcher-core.git
synced 2024-11-22 12:16:21 +03:00
better way to auth, prepping for client use
github scares me ;-;
This commit is contained in:
parent
9362fe25df
commit
d4a3f9b90b
2 changed files with 15 additions and 23 deletions
|
@ -3,8 +3,20 @@ const uuid = require('uuid/v1');
|
||||||
const api_url = "https://authserver.mojang.com";
|
const api_url = "https://authserver.mojang.com";
|
||||||
|
|
||||||
|
|
||||||
function login(username, password) {
|
function getAuth(username, password) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
|
if(!password) {
|
||||||
|
const user = {
|
||||||
|
access_token: uuid(),
|
||||||
|
client_token: uuid(),
|
||||||
|
uuid: uuid(),
|
||||||
|
name: username,
|
||||||
|
user_object: JSON.stringify({})
|
||||||
|
};
|
||||||
|
|
||||||
|
resolve(user);
|
||||||
|
}
|
||||||
|
|
||||||
const requestObject = {
|
const requestObject = {
|
||||||
url: api_url + "/authenticate",
|
url: api_url + "/authenticate",
|
||||||
json: {
|
json: {
|
||||||
|
@ -37,23 +49,6 @@ function login(username, password) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function offline(username) {
|
module.exports = async function(username, password) {
|
||||||
let user = {
|
return await getAuth(username, password);
|
||||||
access_token: uuid(),
|
|
||||||
client_token: uuid(),
|
|
||||||
uuid: uuid(),
|
|
||||||
name: username,
|
|
||||||
user_object: JSON.stringify({})
|
|
||||||
};
|
|
||||||
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = async function(_offline, username, password) {
|
|
||||||
if(_offline) {
|
|
||||||
return offline(username);
|
|
||||||
}
|
|
||||||
|
|
||||||
return await login(username, password);
|
|
||||||
};
|
};
|
|
@ -1,6 +1,5 @@
|
||||||
const child = require('child_process');
|
const child = require('child_process');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const ygg = require('./authenticator');
|
|
||||||
const handler = require('./handler');
|
const handler = require('./handler');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const shelljs = require('shelljs');
|
const shelljs = require('shelljs');
|
||||||
|
@ -9,8 +8,6 @@ const shelljs = require('shelljs');
|
||||||
module.exports = async function (options) {
|
module.exports = async function (options) {
|
||||||
if (!fs.existsSync(options.root)) fs.mkdirSync(options.root);
|
if (!fs.existsSync(options.root)) fs.mkdirSync(options.root);
|
||||||
|
|
||||||
options.authorization = await ygg(options.login.offline, options.login.username, options.login.password);
|
|
||||||
|
|
||||||
const versionFile = await handler.getVersion(options.version.number);
|
const versionFile = await handler.getVersion(options.version.number);
|
||||||
const directory = path.join(options.root, 'versions', options.version.number);
|
const directory = path.join(options.root, 'versions', options.version.number);
|
||||||
options.directory = directory;
|
options.directory = directory;
|
||||||
|
|
Loading…
Add table
Reference in a new issue