Comparing version 1.3.0 to 1.4.0
## History | ||
## 1.4.0 | ||
* Add ability to request user from token refresh (thanks @ph0t0shop) | ||
## 1.3.0 | ||
@@ -4,0 +7,0 @@ - improve code (@IdanHo) |
@@ -43,9 +43,15 @@ 'use strict' | ||
* @param {String} client Client Token | ||
* @param {String=false} requestUser Whether to request the user object | ||
* @param {Function} cb (err, new token, full response body) | ||
*/ | ||
Client.refresh = function (access, client, cb) { | ||
Client.refresh = function (access, client, requestUser, cb) { | ||
if (typeof requestUser === 'function') { | ||
cb = requestUser | ||
requestUser = false | ||
} | ||
const host = this.host || defaultHost | ||
utils.call(host, 'refresh', { | ||
accessToken: access, | ||
clientToken: client | ||
clientToken: client, | ||
requestUser: !!requestUser | ||
}, this.agent, function (err, data) { | ||
@@ -52,0 +58,0 @@ if (data && data.clientToken !== client) { |
{ | ||
"name": "yggdrasil", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"author": "Zeke Sonxx <zeke@zekesonxx.com>", | ||
@@ -8,3 +8,5 @@ "description": "Mojang authentication (Yggdrasil) client", | ||
"test": "mocha -R spec", | ||
"lint": "standard" | ||
"pretest": "npm run lint", | ||
"lint": "standard", | ||
"fix": "standard --fix" | ||
}, | ||
@@ -26,3 +28,3 @@ "main": "./lib/index", | ||
"phin": "^3.4.1", | ||
"uuid": "^3.4.0" | ||
"uuid": "^8.2.0" | ||
}, | ||
@@ -32,5 +34,5 @@ "license": "MIT", | ||
"mocha": "^7.0.1", | ||
"nock": "^11.7.2", | ||
"standard": "^14.3.1" | ||
"nock": "^13.0.2", | ||
"standard": "^16.0.1" | ||
} | ||
} |
# yggdrasil | ||
[![NPM Link](https://img.shields.io/npm/v/yggdrasil.svg?style=plastic)](https://www.npmjs.com/package/yggdrasil) | ||
[![Build Status](http://img.shields.io/travis/zekesonxx/node-yggdrasil.svg?style=plastic)](https://travis-ci.org/zekesonxx/node-yggdrasil) | ||
[![NPM version](https://img.shields.io/npm/v/yggdrasil.svg)](http://npmjs.com/package/yggdrasil) | ||
[![Build Status](https://github.com/PrismarineJS/node-yggdrasil/workflows/CI/badge.svg)](https://github.com/PrismarineJS/node-yggdrasil/actions?query=workflow%3A%22CI%22) | ||
[![Discord](https://img.shields.io/badge/chat-on%20discord-brightgreen.svg)](https://discord.gg/GsEFRM8) | ||
[![Gitter](https://img.shields.io/badge/chat-on%20gitter-brightgreen.svg)](https://gitter.im/PrismarineJS/general) | ||
[![Irc](https://img.shields.io/badge/chat-on%20irc-brightgreen.svg)](https://irc.gitter.im/) | ||
[![Try it on gitpod](https://img.shields.io/badge/try-on%20gitpod-brightgreen.svg)](https://gitpod.io/#https://github.com/PrismarineJS/node-yggdrasil) | ||
A Node.js client for doing requests to yggdrasil, the Mojang authentication system, used for Minecraft and Scrolls. | ||
There's already one other client out there (at the time of writing) but I don't like it, so I wrote this one. | ||
node-yggdrasil was originally made because I was messing around with trying to make a Minecraft server in JS. Never really got anywhere with it. | ||
However, the folks over at [PrismarineJS](https://github.com/PrismarineJS/) have gotten quite far with it, and use this library in their project. | ||
# Usage | ||
@@ -28,7 +29,9 @@ $ npm install yggdrasil | ||
user: '', //Username | ||
pass: '' //Password | ||
pass: '', //Password | ||
requestUser: false //Optional. Request the user object to be included in response | ||
}, function(err, data){}); | ||
//Refresh an accessToken | ||
ygg.refresh(oldtoken, clienttoken, function(err, newtoken, response body){}); | ||
ygg.refresh(oldtoken, clienttoken, true, function(err, newtoken, response body){}); | ||
// Note that requestUser is an optional parameter. If set to true, it requests the user object from Mojang's authentication servers as well. | ||
@@ -83,2 +86,1 @@ //Validate an accessToken | ||
* [node-minecraft-protocol](https://github.com/PrismarineJS/node-minecraft-protocol), a Minecraft client and server in Node.js | ||
* [prismarine-yggdrasil](https://github.com/PrismarineJS/prismarine-yggdrasil), another yggdrasil client that node-yggdrasil replaced (issue links: [prismarine-yggdrasil #2](https://github.com/PrismarineJS/prismarine-yggdrasil/issues/2), [node-minecraft-protocol #117](https://github.com/PrismarineJS/node-minecraft-protocol/issues/117)). |
@@ -93,2 +93,6 @@ /* eslint-env mocha */ | ||
}, function (err, data) { // eslint-disable-line handle-callback-err | ||
if (err) { | ||
done(err) | ||
return | ||
} | ||
assert.deepStrictEqual(data, { | ||
@@ -119,2 +123,6 @@ worked: true | ||
}, function (err, data) { // eslint-disable-line handle-callback-err | ||
if (err) { | ||
done(err) | ||
return | ||
} | ||
assert.deepStrictEqual(data, { | ||
@@ -131,3 +139,4 @@ worked: true | ||
accessToken: 'bacon', | ||
clientToken: 'not bacon' | ||
clientToken: 'not bacon', | ||
requestUser: false | ||
}).reply(200, { | ||
@@ -143,6 +152,29 @@ accessToken: 'different bacon', | ||
}) | ||
it('should work correctly with requestUser true', function (done) { | ||
cscope.post('/refresh', { | ||
accessToken: 'bacon', | ||
clientToken: 'not bacon', | ||
requestUser: true | ||
}).reply(200, { | ||
accessToken: 'different bacon', | ||
clientToken: 'not bacon', | ||
user: { | ||
id: '4ed1f46bbe04bc756bcb17c0c7ce3e4632f06a48', | ||
properties: [] | ||
} | ||
}) | ||
ygg.refresh('bacon', 'not bacon', true, function (err, token, data) { | ||
assert.ifError(err) | ||
assert.strictEqual(token, 'different bacon') | ||
assert.ok(data.user) | ||
assert.ok(data.user.properties) | ||
assert.strictEqual(data.user.id, '4ed1f46bbe04bc756bcb17c0c7ce3e4632f06a48') | ||
done() | ||
}) | ||
}) | ||
it('should error on invalid clientToken', function (done) { | ||
cscope.post('/refresh', { | ||
accessToken: 'bacon', | ||
clientToken: 'not bacon' | ||
clientToken: 'not bacon', | ||
requestUser: false | ||
}).reply(200, { | ||
@@ -204,2 +236,6 @@ accessToken: 'different bacon', | ||
yggserver.join('anAccessToken', 'aSelectedProfile', 'cat', 'cat', 'cat', function (err, data) { // eslint-disable-line handle-callback-err | ||
if (err) { | ||
done(err) | ||
return | ||
} | ||
assert.deepStrictEqual(data, { | ||
@@ -206,0 +242,0 @@ worked: true |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
22170
14
505
85
0
+ Addeduuid@8.3.2(transitive)
- Removeduuid@3.4.0(transitive)
Updateduuid@^8.2.0