yggdrasil 1.6.1 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/HISTORY.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## History
2
2
 
3
+ ## 1.7.0
4
+ * Add new endpoint to invalidate all accessTokens using current valid accessToken and clientToken
5
+ * Fixed "call" function throwing an empty error message
6
+
3
7
  ## 1.6.1
4
8
  * Properly escape the username
5
9
 
package/README.md CHANGED
@@ -46,6 +46,12 @@ ygg.validate(token).then(
46
46
  (error)=>{}
47
47
  );
48
48
 
49
+ //Invalidate all accessTokens using a current valid accessToken and clientToken.
50
+ ygg.invalidate(accessToken, clientToken).then(
51
+ (response)=>{},
52
+ (error)=>{}
53
+ );
54
+
49
55
  //Invalidate all accessTokens
50
56
  ygg.signout(username, password).then(
51
57
  (response)=>{},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yggdrasil",
3
- "version": "1.6.1",
3
+ "version": "1.7.0",
4
4
  "author": "Zeke Sonxx <zeke@zekesonxx.com>",
5
5
  "description": "Mojang authentication (Yggdrasil) client",
6
6
  "scripts": {
@@ -28,8 +28,8 @@
28
28
  },
29
29
  "license": "MIT",
30
30
  "devDependencies": {
31
- "@types/node": "^16.0.0",
32
- "@types/node-fetch": "^2.5.8",
31
+ "@types/node": "^17.0.4",
32
+ "@types/node-fetch": "^3.0.3",
33
33
  "@types/uuid": "^8.3.0",
34
34
  "mocha": "^9.0.0",
35
35
  "nock": "^13.0.2",
package/src/Client.js CHANGED
@@ -63,11 +63,21 @@ function loader (moduleOptions) {
63
63
  async function signout (username, password) {
64
64
  return await utils.call(moduleOptions?.host ?? defaultHost, 'signout', { username, password }, moduleOptions?.agent)
65
65
  }
66
+
67
+ /**
68
+ * Invalidates all access tokens using client/access token pair.
69
+ * @param {String} clientToken Client Token
70
+ * @param {String} accessToken Access Token
71
+ */
72
+ async function invalidate (accessToken, clientToken) {
73
+ return await utils.call(moduleOptions?.host ?? defaultHost, 'invalidate', { accessToken, clientToken }, moduleOptions?.agent)
74
+ }
66
75
  return {
67
76
  auth: utils.callbackify(auth, 1),
68
77
  refresh: utils.callbackify(refresh, 3),
69
78
  signout: utils.callbackify(signout, 1),
70
- validate: utils.callbackify(validate, 2)
79
+ validate: utils.callbackify(validate, 2),
80
+ invalidate: utils.callbackify(invalidate, 2)
71
81
  }
72
82
  }
73
83
 
package/src/utils.js CHANGED
@@ -32,7 +32,7 @@ async function call (host, path, data, agent) {
32
32
  throw e
33
33
  }
34
34
  }
35
- if (body?.error !== undefined) throw new Error(body?.errorMessage)
35
+ if (body?.error !== undefined) throw new Error(body?.errorMessage ?? body?.error)
36
36
  return body
37
37
  }
38
38
  /**