Comparing version 1.0.0 to 1.1.0
@@ -32,3 +32,4 @@ 'use strict' | ||
password: options.pass, | ||
clientToken: options.token | ||
clientToken: options.token, | ||
requestUser: options.requestUser === true | ||
}, function (err, data) { | ||
@@ -35,0 +36,0 @@ cb(err, data) |
@@ -44,7 +44,8 @@ 'use strict' | ||
var hash = utils.mcHexDigest(crypto.createHash('sha1').update(serverid).update(sharedsecret).update(serverkey).digest()) | ||
utils.request({ | ||
method: 'GET', | ||
uri: host + '/session/minecraft/hasJoined?username=' + username + '&serverId=' + hash, | ||
json: true | ||
}, function (err, resp, body) { | ||
utils.phin(host + '/session/minecraft/hasJoined?username=' + username + '&serverId=' + hash, function (err, resp) { | ||
try { | ||
var body = JSON.parse(resp.body.toString()) | ||
} catch (caughtErr) { | ||
err = caughtErr | ||
} | ||
if (err || body && body.hasOwnProperty('id')) { | ||
@@ -51,0 +52,0 @@ cb(err, body) |
var version = require('../package.json').version | ||
var request = require('request').defaults({ | ||
headers: { | ||
'User-Agent': 'node-yggdrasil/' + version, | ||
'Content-Type': 'application/json' | ||
} | ||
}) | ||
var phin = require('phin') | ||
var headers = { | ||
'User-Agent': 'node-yggdrasil/' + version, | ||
'Content-Type': 'application/json' | ||
} | ||
var utils = {} | ||
utils.request = request | ||
utils.phin = phin | ||
@@ -17,7 +17,13 @@ /** | ||
utils.call = function (host, path, data, cb) { | ||
request({ | ||
phin({ | ||
method: 'POST', | ||
uri: host + '/' + path, | ||
json: data | ||
}, function (err, resp, body) { | ||
url: host + '/' + path, | ||
data: data, | ||
headers: headers | ||
}, function (err, resp) { | ||
try { | ||
var body = JSON.parse(resp.body) | ||
} catch (caughtErr) { | ||
err = caughtErr | ||
} | ||
if (body && body.error) { | ||
@@ -24,0 +30,0 @@ cb(new Error(body.errorMessage)) |
{ | ||
"name": "yggdrasil", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"author": "Zeke Sonxx <zeke@zekesonxx.com>", | ||
@@ -24,15 +24,15 @@ "description": "Mojang authentication (Yggdrasil) client", | ||
"dependencies": { | ||
"request": "^2.79.0", | ||
"uuid": "^3.0.1" | ||
"phin": "^2.2.1", | ||
"uuid": "^3.1.0" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"eslint": "^3.14.0", | ||
"eslint": "^4.4.1", | ||
"eslint-config-standard": "^6.2.1", | ||
"eslint-plugin-promise": "^3.4.0", | ||
"eslint-plugin-standard": "^2.0.1", | ||
"mocha": "~1.18.0", | ||
"nock": "~0.27.2", | ||
"should": "~3.1.3" | ||
"mocha": "^3.5.0", | ||
"nock": "^9.0.14", | ||
"should": "^11.2.1" | ||
} | ||
} |
@@ -81,3 +81,4 @@ /* eslint-env mocha */ | ||
password: 'hunter2', | ||
clientToken: 'bacon' | ||
clientToken: 'bacon', | ||
requestUser: false | ||
}).reply(200, { | ||
@@ -97,2 +98,27 @@ worked: true | ||
}) | ||
it('should work correctly with requestUser true', function (done) { | ||
cscope.post('/authenticate', { | ||
agent: { | ||
version: 1, | ||
name: 'Minecraft' | ||
}, | ||
username: 'cake', | ||
password: 'hunter2', | ||
clientToken: 'bacon', | ||
requestUser: true | ||
}).reply(200, { | ||
worked: true | ||
}) | ||
ygg.auth({ | ||
user: 'cake', | ||
pass: 'hunter2', | ||
token: 'bacon', | ||
requestUser: true | ||
}, function (err, data) { // eslint-disable-line handle-callback-err | ||
data.should.eql({ | ||
worked: true | ||
}) | ||
done() | ||
}) | ||
}) | ||
}) | ||
@@ -99,0 +125,0 @@ describe('refresh', function () { |
Sorry, the diff of this file is not supported yet
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
447
49206
+ Addedphin@^2.2.1
+ Addedphin@2.9.3(transitive)
- Removedrequest@^2.79.0
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.15.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removedverror@1.10.0(transitive)
Updateduuid@^3.1.0