mowojang 0.3.0 → 0.3.1

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/README.md CHANGED
@@ -58,7 +58,6 @@ All Validator Functions are exported combined as `validate.x`.
58
58
  - `pnpm install`: Installs all required dependencies
59
59
  - `pnpm build`: Runs the TypeScript compiler
60
60
  - `pnpm test`: Runs tests for all Functions
61
- - `pnpm publish`: Publish the Package to NPM
62
61
 
63
62
  ## 📎 Credits
64
63
 
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mowojang",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "A simple JavaScript and TypeScript compatible wrapper for the Mowojang-API.",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -27,11 +27,11 @@
27
27
  "node": ">=20.0.0"
28
28
  },
29
29
  "dependencies": {
30
- "axios": "^1.7.2",
31
- "axios-cache-interceptor": "^1.5.3"
30
+ "axios": "^1.7.7",
31
+ "axios-cache-interceptor": "^1.6.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@types/node": "^20.14.9",
35
- "typescript": "^5.5.2"
34
+ "@types/node": "^22.7.3",
35
+ "typescript": "^5.6.2"
36
36
  }
37
37
  }
@@ -28,7 +28,7 @@ export default class Client {
28
28
  *
29
29
  * Players considered "INVALID" are excluded from the results
30
30
  */
31
- getSessions(players: Player[], config?: MowojangRequestConfig): MowojangResponse<MowojangSession[], "INVALID_PLAYER">;
31
+ getSessions(players: Player[], config?: MowojangRequestConfig): MowojangResponse<MowojangSession[], undefined>;
32
32
  /**
33
33
  * Returns a Player's Sessions consisting of their Username, UUID, Skin and Cape
34
34
  *
@@ -1,6 +1,6 @@
1
1
  import { isAxiosError } from "axios";
2
2
  import axiosInstance from "./axiosInstance.js";
3
- import { validateArray, validatePlayer, validateUUID, validateUsername } from "./validators.js";
3
+ import { validateArray, validatePlayer, validateUUID } from "./validators.js";
4
4
  import { undashUUID } from "./utils.js";
5
5
  export default class Client {
6
6
  axios;
@@ -14,13 +14,15 @@ export default class Client {
14
14
  */
15
15
  async getProfiles(players, config) {
16
16
  try {
17
- if (!validateArray(players, validatePlayer))
17
+ if (config?.validate !== false && !validateArray(players, validatePlayer))
18
18
  return { data: null, error: "INVALID_INPUT" };
19
- players = players.map((player) => {
19
+ players = players
20
+ .map((player) => {
20
21
  if (validateUUID(player))
21
22
  return undashUUID(player);
22
23
  return player.toLowerCase();
23
- });
24
+ })
25
+ .sort();
24
26
  const fetchResponse = await this.axios.post("https://mowojang.matdoes.dev/", players, {
25
27
  cache: config?.cache ?? { ttl: 15 * 60 * 1000 },
26
28
  });
@@ -45,7 +47,7 @@ export default class Client {
45
47
  *
46
48
  */
47
49
  async getProfile(player, config) {
48
- if (!validatePlayer(player))
50
+ if (config?.validate !== false && !validatePlayer(player))
49
51
  return { data: null, error: "INVALID_INPUT" };
50
52
  const profiles = await this.getProfiles([player], config);
51
53
  if (profiles.error)
@@ -59,8 +61,6 @@ export default class Client {
59
61
  *
60
62
  */
61
63
  async getUUID(username, config) {
62
- if (!validateUsername(username))
63
- return null;
64
64
  const profile = await this.getProfile(username, config);
65
65
  if (profile.error)
66
66
  return null;
@@ -71,8 +71,6 @@ export default class Client {
71
71
  *
72
72
  */
73
73
  async getUsername(UUID, config) {
74
- if (!validateUUID(UUID))
75
- return null;
76
74
  const profile = await this.getProfile(UUID, config);
77
75
  if (profile.error)
78
76
  return null;
@@ -85,7 +83,7 @@ export default class Client {
85
83
  */
86
84
  async getSessions(players, config) {
87
85
  try {
88
- if (!validateArray(players, validatePlayer))
86
+ if (config?.validate !== false && !validateArray(players, validatePlayer))
89
87
  return { data: null, error: "INVALID_INPUT" };
90
88
  players = players.map((player) => {
91
89
  if (validateUUID(player))
@@ -94,10 +92,11 @@ export default class Client {
94
92
  });
95
93
  const sessionsPromises = [];
96
94
  players.forEach((player) => {
95
+ // @ts-ignore
97
96
  sessionsPromises.push(this.getSession(player, config));
98
97
  });
99
98
  const sessions = (await Promise.all(sessionsPromises))
100
- .filter((session) => session.data)
99
+ .filter((session) => session.data !== null)
101
100
  .map((session) => session.data);
102
101
  return {
103
102
  // @ts-ignore
@@ -114,11 +113,11 @@ export default class Client {
114
113
  *
115
114
  */
116
115
  async getSession(player, config) {
117
- if (!validatePlayer(player))
116
+ if (config?.validate !== false && !validatePlayer(player))
118
117
  return { data: null, error: "INVALID_INPUT" };
119
118
  const UUID = await this.getUUID(player);
120
119
  if (!UUID)
121
- return { data: null, error: "INVALID_INPUT" };
120
+ return { data: null, error: "INVALID_PLAYER" };
122
121
  return await this.axios
123
122
  .get(`https://mowojang.matdoes.dev/session/minecraft/profile/${UUID}`, {
124
123
  cache: config?.cache ?? { ttl: 15 * 60 * 1000 },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mowojang",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "A simple JavaScript and TypeScript compatible wrapper for the Mowojang-API.",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -21,12 +21,12 @@
21
21
  "node": ">=20.0.0"
22
22
  },
23
23
  "dependencies": {
24
- "axios": "^1.7.2",
25
- "axios-cache-interceptor": "^1.5.3"
24
+ "axios": "^1.7.7",
25
+ "axios-cache-interceptor": "^1.6.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@types/node": "^20.14.9",
29
- "typescript": "^5.5.2"
28
+ "@types/node": "^22.7.3",
29
+ "typescript": "^5.6.2"
30
30
  },
31
31
  "scripts": {
32
32
  "build": "pnpm tsc",