Socket
Socket
Sign inDemoInstall

minecraft-auth

Package Overview
Dependencies
3
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.1 to 2.0.2

43

dist/MicrosoftAuth/MicrosoftAuth.js

@@ -12,6 +12,13 @@ "use strict";

scope: "XboxLive.signin offline_access",
redirectURL: "http://localhost:8080/token"
redirectURL: "http://localhost:8080/token",
appID: "747bf062-ab9c-4690-842d-a77d18d4cf82",
mode: "SPA"
};
function setup(_config) {
config = { ...config, ..._config };
if (_config.appSecret) {
config = { ...config, mode: "Web", ..._config };
}
else {
config = { ...config, mode: "SPA", ..._config };
}
}

@@ -101,10 +108,16 @@ exports.setup = setup;

async function getToken(authCode) {
let encodedID = encodeURIComponent(config.appID ?? "");
let encodedID = encodeURIComponent(config.appID);
let encodedUrl = encodeURIComponent(config.redirectURL);
const url = 'https://login.live.com/oauth20_token.srf';
const body = `client_id=${encodedID}&code=${authCode}&grant_type=authorization_code&redirect_uri=${encodedUrl}`;
const response = await (0, http_client_methods_1.HttpPost)(url, body, {
'Content-Type': 'application/x-www-form-urlencoded',
});
const jsonResponse = JSON.parse(response);
let url = 'https://login.live.com/oauth20_token.srf';
let body = `client_id=${encodedID}&code=${authCode}&grant_type=authorization_code&redirect_uri=${encodedUrl}`;
if (config.mode === "Web") {
if (!config.appSecret) {
throw new types_1.AuthenticationError("App secret was not provided", "App secret was not provided in getToken");
}
let encodedSecret = encodeURIComponent(config.appSecret);
url = "https://login.live.com/oauth20_token.srf";
body = `client_id=${encodedID}&client_secret=${encodedSecret}&code=${authCode}&grant_type=authorization_code&redirect_uri=${encodedUrl}`;
}
let response = await (0, http_client_methods_1.HttpPost)(url, body, { "Content-Type": "application/x-www-form-urlencoded" });
let jsonResponse = JSON.parse(response);
if (jsonResponse.error) {

@@ -119,4 +132,12 @@ throw new types_1.AuthenticationError(jsonResponse.error, jsonResponse.error_description, jsonResponse.correlation_id);

let encodedUrl = encodeURIComponent(config.redirectURL);
const url = 'https://login.live.com/oauth20_token.srf';
const body = `client_id=${encodedID}&refresh_token=${refreshToken}&grant_type=refresh_token&redirect_uri=${encodedUrl}`;
let url = 'https://login.live.com/oauth20_token.srf';
let body = `client_id=${encodedID}&refresh_token=${refreshToken}&grant_type=refresh_token&redirect_uri=${encodedUrl}`;
if (config.mode === "Web") {
if (!config.appSecret) {
throw new types_1.AuthenticationError("App secret was not provided", "App secret was not provided in getToken");
}
let encodedSecret = encodeURIComponent(config.appSecret);
url = "https://login.live.com/oauth20_token.srf";
body = `client_id=${encodedID}&client_secret=${encodedSecret}&refresh_token=${refreshToken}&grant_type=refresh_token&redirect_uri=${encodedUrl}`;
}
const response = await (0, http_client_methods_1.HttpPost)(url, body, {

@@ -123,0 +144,0 @@ 'Content-Type': 'application/x-www-form-urlencoded',

export declare type MSConfigType = {
appID?: string;
appID: string;
appSecret?: string;
redirectURL: string;
scope: string;
mode: "SPA" | "Web";
};

@@ -6,0 +8,0 @@ export declare type ServerConfigType = {

{
"name": "minecraft-auth",
"version": "2.0.1",
"version": "2.0.2",
"description": "Package to authenticate with minecraft using traditional yggdrasil, new microsoft authentication and non-premium.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -40,9 +40,17 @@ # Minecraft-auth package

### Authentication Examples:
* Mojang Authentication:
* Microsoft Authentication (public client, [valid for 24h](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow#refresh-the-access-token)):
```javascript
let account = new minecraftAuth.MojangAccount();
await account.Login("email","password");
```
* Microsoft Authentication:
const MicrosoftAuth = minecraftAuth.MicrosoftAuth;
let account = new minecraftAuth.MicrosoftAccount();
MicrosoftAuth.setup({appID:"747bf062-ab9c-4690-842d-a77d18d4cf82"}); //https://github.com/dommilosz/minecraft-auth/wiki/How-to-setup-Microsoft-Auth
let code = await MicrosoftAuth.listenForCode();
if(code !== undefined){
await account.authFlow(code);
}
```
* Microsoft Authentication ([don't have specified lifetimes](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow#refresh-the-access-token)):
```javascript

@@ -52,3 +60,3 @@ const MicrosoftAuth = minecraftAuth.MicrosoftAuth;

let account = new minecraftAuth.MicrosoftAccount();
MicrosoftAuth.setup({appID:"747bf062-ab9c-4690-842d-a77d18d4cf82"});
MicrosoftAuth.setup({appID:"YOUR APP ID", appSecret:"YOUR APP SECRET"}); //https://github.com/dommilosz/minecraft-auth/wiki/How-to-setup-Microsoft-Auth
let code = await MicrosoftAuth.listenForCode();

@@ -61,2 +69,9 @@

* Mojang Authentication (obsolete due to migration):
```javascript
let account = new minecraftAuth.MojangAccount();
await account.Login("email","password");
```
* Cracked Authentication:

@@ -63,0 +78,0 @@ ```javascript

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc