Git Product home page Git Product logo

node-yggdrasil's Introduction

yggdrasil

NPM version Build Status Discord Gitter Irc

Try it on gitpod

A Node.js client for doing requests to yggdrasil, the Mojang authentication system, used for Minecraft and Scrolls.

Usage

$ npm install yggdrasil

Client

//init
const ygg = require('yggdrasil')({
  //Optional settings object
  host: 'https://authserver.mojang.com' //Optional custom host. No trailing slash.
});

//Authenticate a user
ygg.auth({
  token: '', //Optional. Client token.
  agent: '', //Agent name. Defaults to 'Minecraft'
  version: 1, //Agent version. Defaults to 1
  user: '', //Username
  pass: '' //Password
}, function(err, data){});

//Refresh an accessToken
ygg.refresh(oldtoken, clienttoken, function(err, newtoken, response body){});

//Validate an accessToken
ygg.validate(token, function(err){});

//Invalidate all accessTokens
ygg.signout(username, password, function(err));

Server

const yggserver = require('yggdrasil').server({
  //Optional settings object
  host: 'https://authserver.mojang.com' //Optional custom host. No trailing slash.
});

//Join a server (clientside)
yggserver.join(token, profile, serverid, sharedsecret, serverkey, function(err, response body){});

//Join a server (serverside)
yggserver.hasJoined(username, serverid, sharedsecret, serverkey, function(err, client info){});

Proxy Support

const ProxyAgent = require('proxy-agent');

const ygg = require('yggdrasil')({
  //Any type of HTTP Agent 
  agent: new ProxyAgent('https://example.com:8080')
});

With ES6 Named Exports

/**
 * Import Client or Server from 'yggdrasil/es6'.
 * Note that the library is stateless when imported this way vs the CommonJS way.
 */
import { Client as ygg, Server as yggServ } from 'yggdrasil/es6'

// Use it like you normally would.

ygg.validate(token, function(err){})

yggServ.join(token, profile, serverid, sharedsecret, serverkey, function(err, response body){});

Further Reading

node-yggdrasil's People

Contributors

bdsomer avatar comp500 avatar dependabot-preview[bot] avatar idanho avatar insanity54 avatar jonathanperret avatar luminess avatar roblabla avatar rom1504 avatar wvffle avatar yariplus avatar zekesonxx avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.