2.0.9 • Published 26 days ago

minecraft-auth v2.0.9

Weekly downloads
-
License
ISC
Repository
github
Last release
26 days ago

Minecraft-auth package

npm bundle size GitHub package.json version GitHub top language npm

Minecraft-auth is a package to authenticate and get minecraft access tokens.

Authentication Types:

  • Mojang Authentication - standard mojang authentication using username and password
  • Microsoft Authentication - new Microsoft oauth authentication to login to new accounts / migrated to microsoft. Read how to setup it here
  • Cracked Authentication - non premium offline mode authentication. Requires only username.

Mojang API:

Package contains MojangApi class which can be used to fetch other users skins, uuids, check server status and more.

2.0.0 migration

Version 2.0.0 changes how Microsoft Authentication works.

  • Azure application should be registered with Mobile and desktop applications type
  • parameters in Setup and listenForCode functions changed

Error handling:

All authentication errors are thrown by using AuthenticationError or OwnershipError classes they all extend Error class. AuthenticationError also contains additionalInfo: string

Installation:

npm i --save minecraft-auth

Importing:

import * as minecraftAuth from "./src/index";
//or
const minecraftAuth = require("./src/index.ts");

Authentication Examples:

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);
}

let account = new minecraftAuth.MicrosoftAccount(); 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();

if(code !== undefined){ await account.authFlow(code); }

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

Usage example

//any type of authentication eg. from above examples
        
console.log(account.accessToken);
await account.getProfile();
console.log(account.username);            //Username of the account
console.log(account.uuid);                //UUID of the account (without dashes)
console.log(account.ownership);           //Does account even have minecraft
console.log(account.profile)              //User profile - skins, capes, uuid, username
console.log(account.profile.skins[0].url) //URL of the 1st skin.

accountsStorage:

AccountsStorage is a storage for your accounts.

Adding accounts:

You can add new account with AccountsStorage::addAccount(account)

Removing accounts:

You can remove account with AccountsStorage::removeAccount(account)

Getting accounts:

You can get accounts with:

  • getAccount(index)
  • getAccountByName(name)
  • getAccountByUUID(uuid)
Saving/Reading accounts:
  • serialize converts storage to JSON string to save in file
  • deserialize converts string to AccountStorage object
2.0.7

26 days ago

2.0.9

26 days ago

2.0.8

26 days ago

2.0.6

4 months ago

2.0.5

5 months ago

2.0.3

8 months ago

2.0.4

7 months ago

2.0.2

9 months ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.33

2 years ago

1.0.34

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago