mowojang 0.4.8 → 0.4.9
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 +10 -4
- package/dist/index.d.ts +73 -0
- package/dist/index.js +61 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|

|
|
4
4
|

|
|
5
5
|

|
|
6
|
+

|
|
7
|
+

|
|
6
8
|
|
|
7
9
|
> [!IMPORTANT]
|
|
8
|
-
> This is a third party wrapper for the [Mowojang
|
|
10
|
+
> This is a third party wrapper for the [Mowojang](https://mowojang.matdoes.dev/) API!
|
|
9
11
|
|
|
10
12
|
## ✨ Quick Start
|
|
11
13
|
|
|
@@ -69,13 +71,17 @@ All Validator Functions are exported combined as `validate.x`.
|
|
|
69
71
|
|
|
70
72
|
- `UUID()`: Returns whether the provided String is an valid UUID (Accepts both undashed and dashed UUIDv4 Strings)
|
|
71
73
|
- `username()`: Returns whether the provided String is an valid Username (Accepts a second argument stating the minimum length required to pass the validation)
|
|
72
|
-
- `player()
|
|
74
|
+
- `player()`: Combines the above
|
|
75
|
+
|
|
76
|
+
## 📦 CLI
|
|
77
|
+
|
|
78
|
+
You can also use this package from the CLI using [mowojang-cli](https://www.npmjs.com/package/mowojang-cli). ([Repository](https://github.com/Pixelicc/mowojang-cli))
|
|
73
79
|
|
|
74
80
|
## ⚙️ Development
|
|
75
81
|
|
|
76
82
|
- `pnpm install`: Installs all required dependencies
|
|
77
|
-
- `pnpm build`: Runs the
|
|
78
|
-
- `pnpm test`: Runs tests for all
|
|
83
|
+
- `pnpm build`: Runs the compiler
|
|
84
|
+
- `pnpm test`: Runs tests for all functions
|
|
79
85
|
|
|
80
86
|
## 📎 Credits
|
|
81
87
|
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,19 @@ type Username = string;
|
|
|
20
20
|
*/
|
|
21
21
|
type UUID = string;
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Options for the Mowojang Client Instance
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```TS
|
|
28
|
+
* const options: ClientOptions = {
|
|
29
|
+
* timeout: 5000,
|
|
30
|
+
* validation: {
|
|
31
|
+
* enabled: true
|
|
32
|
+
* }
|
|
33
|
+
* };
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
23
36
|
type ClientOptions = {
|
|
24
37
|
logger?: LoggerConfig;
|
|
25
38
|
validation?: ValidationOptions;
|
|
@@ -78,6 +91,24 @@ declare class Client {
|
|
|
78
91
|
private axios;
|
|
79
92
|
private validation;
|
|
80
93
|
private baseURL;
|
|
94
|
+
/**
|
|
95
|
+
* Creates a new Mowojang Client Instance
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```TS
|
|
99
|
+
* const client = new Client();
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```TS
|
|
104
|
+
* const client = new Client({
|
|
105
|
+
* timeout: 5000,
|
|
106
|
+
* validation: {
|
|
107
|
+
* enabled: true
|
|
108
|
+
* }
|
|
109
|
+
* });
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
81
112
|
constructor(clientOptions?: ClientOptions);
|
|
82
113
|
private shouldValidate;
|
|
83
114
|
private getValidationMinLength;
|
|
@@ -85,6 +116,11 @@ declare class Client {
|
|
|
85
116
|
* Returns an Array of Player Profiles consisting of their Usernames and UUIDs
|
|
86
117
|
*
|
|
87
118
|
* Players considered "INVALID" are excluded from the results
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```TS
|
|
122
|
+
* const profiles = await client.getProfiles(["Pixelic", "14727faefbdc4aff848cd2713eb9939e"]);
|
|
123
|
+
* ```
|
|
88
124
|
*/
|
|
89
125
|
getProfiles(players: Player[], config?: MowojangRequestConfig & {
|
|
90
126
|
usePost?: boolean;
|
|
@@ -92,47 +128,84 @@ declare class Client {
|
|
|
92
128
|
/**
|
|
93
129
|
* Returns a Player's Profile consisting of their Username and UUID
|
|
94
130
|
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```TS
|
|
133
|
+
* const profile = await client.getProfile("Pixelic");
|
|
134
|
+
* ```
|
|
95
135
|
*/
|
|
96
136
|
getProfile(player: Player, config?: MowojangRequestConfig): MowojangResponse<MowojangProfile, "INVALID_PLAYER">;
|
|
97
137
|
/**
|
|
98
138
|
* A simple Wrapper to retrieve only the UUID of a Player's Profile
|
|
99
139
|
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```TS
|
|
142
|
+
* const uuid = await client.getUUID("Pixelic");
|
|
143
|
+
* ```
|
|
100
144
|
*/
|
|
101
145
|
getUUID(username: Username, config?: MowojangRequestConfig): Promise<null | UUID>;
|
|
102
146
|
/**
|
|
103
147
|
* A simple Wrapper to retrieve only the Username of a Player's Profile
|
|
104
148
|
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```TS
|
|
151
|
+
* const username = await client.getUsername("14727faefbdc4aff848cd2713eb9939e");
|
|
152
|
+
* ```
|
|
105
153
|
*/
|
|
106
154
|
getUsername(UUID: UUID, config?: MowojangRequestConfig): Promise<null | Username>;
|
|
107
155
|
/**
|
|
108
156
|
* Returns an Array of Player Sessions consisting of their Usernames, UUIDs, Skins and Capes
|
|
109
157
|
*
|
|
110
158
|
* Players considered "INVALID" are excluded from the results
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```TS
|
|
162
|
+
* const sessions = await client.getSessions(["Pixelic", "14727faefbdc4aff848cd2713eb9939e"]);
|
|
163
|
+
* ```
|
|
111
164
|
*/
|
|
112
165
|
getSessions(players: Player[], config?: MowojangRequestConfig): MowojangResponse<MowojangSession[], undefined>;
|
|
113
166
|
/**
|
|
114
167
|
* Returns a Player's Sessions consisting of their Username, UUID, Skin and Cape
|
|
115
168
|
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```TS
|
|
171
|
+
* const session = await client.getSession("Pixelic");
|
|
172
|
+
* ```
|
|
116
173
|
*/
|
|
117
174
|
getSession(player: Player, config?: MowojangRequestConfig): MowojangResponse<MowojangSession, "INVALID_PLAYER">;
|
|
118
175
|
/**
|
|
119
176
|
* A simple Wrapper to retrieve only the Skin from a Player's Session
|
|
120
177
|
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```TS
|
|
180
|
+
* const skin = await client.getSkin("Pixelic");
|
|
181
|
+
* ```
|
|
121
182
|
*/
|
|
122
183
|
getSkin(player: Player, config?: MowojangRequestConfig): Promise<null | MowojangSkin>;
|
|
123
184
|
/**
|
|
124
185
|
* A simple Wrapper to retrieve only the Player's Skin from their Session Data loaded into a Buffer
|
|
125
186
|
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```TS
|
|
189
|
+
* const skinBuffer = await client.getSkinBuffer("Pixelic");
|
|
190
|
+
* ```
|
|
126
191
|
*/
|
|
127
192
|
getSkinBuffer(player: Player, config?: MowojangRequestConfig): Promise<null | Buffer>;
|
|
128
193
|
/**
|
|
129
194
|
* A simple Wrapper to retrieve only the Cape Data from a Player's Session
|
|
130
195
|
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```TS
|
|
198
|
+
* const cape = await client.getCape("Pixelic");
|
|
199
|
+
* ```
|
|
131
200
|
*/
|
|
132
201
|
getCape(player: Player, config?: MowojangRequestConfig): Promise<null | MowojangCape>;
|
|
133
202
|
/**
|
|
134
203
|
* A simple Wrapper to retrieve only the Player's Cape from their Session Data loaded into a Buffer
|
|
135
204
|
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```TS
|
|
207
|
+
* const capeBuffer = await client.getCapeBuffer("Pixelic");
|
|
208
|
+
* ```
|
|
136
209
|
*/
|
|
137
210
|
getCapeBuffer(player: Player, config?: MowojangRequestConfig): Promise<null | Buffer>;
|
|
138
211
|
}
|
package/dist/index.js
CHANGED
|
@@ -37,7 +37,7 @@ import { setupCache } from "axios-cache-interceptor";
|
|
|
37
37
|
// package.json
|
|
38
38
|
var package_default = {
|
|
39
39
|
name: "mowojang",
|
|
40
|
-
version: "0.4.
|
|
40
|
+
version: "0.4.9",
|
|
41
41
|
description: "A simple JavaScript and TypeScript compatible wrapper for the Mowojang-API.",
|
|
42
42
|
exports: {
|
|
43
43
|
".": {
|
|
@@ -288,6 +288,24 @@ var Client = class {
|
|
|
288
288
|
axios;
|
|
289
289
|
validation;
|
|
290
290
|
baseURL;
|
|
291
|
+
/**
|
|
292
|
+
* Creates a new Mowojang Client Instance
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```TS
|
|
296
|
+
* const client = new Client();
|
|
297
|
+
* ```
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* ```TS
|
|
301
|
+
* const client = new Client({
|
|
302
|
+
* timeout: 5000,
|
|
303
|
+
* validation: {
|
|
304
|
+
* enabled: true
|
|
305
|
+
* }
|
|
306
|
+
* });
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
291
309
|
constructor(clientOptions) {
|
|
292
310
|
this.logger = new Logger(clientOptions?.logger);
|
|
293
311
|
this.validation = clientOptions?.validation ?? {};
|
|
@@ -308,6 +326,11 @@ var Client = class {
|
|
|
308
326
|
* Returns an Array of Player Profiles consisting of their Usernames and UUIDs
|
|
309
327
|
*
|
|
310
328
|
* Players considered "INVALID" are excluded from the results
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```TS
|
|
332
|
+
* const profiles = await client.getProfiles(["Pixelic", "14727faefbdc4aff848cd2713eb9939e"]);
|
|
333
|
+
* ```
|
|
311
334
|
*/
|
|
312
335
|
async getProfiles(players, config) {
|
|
313
336
|
try {
|
|
@@ -349,6 +372,10 @@ var Client = class {
|
|
|
349
372
|
/**
|
|
350
373
|
* Returns a Player's Profile consisting of their Username and UUID
|
|
351
374
|
*
|
|
375
|
+
* @example
|
|
376
|
+
* ```TS
|
|
377
|
+
* const profile = await client.getProfile("Pixelic");
|
|
378
|
+
* ```
|
|
352
379
|
*/
|
|
353
380
|
async getProfile(player, config) {
|
|
354
381
|
try {
|
|
@@ -371,6 +398,10 @@ var Client = class {
|
|
|
371
398
|
/**
|
|
372
399
|
* A simple Wrapper to retrieve only the UUID of a Player's Profile
|
|
373
400
|
*
|
|
401
|
+
* @example
|
|
402
|
+
* ```TS
|
|
403
|
+
* const uuid = await client.getUUID("Pixelic");
|
|
404
|
+
* ```
|
|
374
405
|
*/
|
|
375
406
|
async getUUID(username, config) {
|
|
376
407
|
const profile = await this.getProfile(username, config);
|
|
@@ -380,6 +411,10 @@ var Client = class {
|
|
|
380
411
|
/**
|
|
381
412
|
* A simple Wrapper to retrieve only the Username of a Player's Profile
|
|
382
413
|
*
|
|
414
|
+
* @example
|
|
415
|
+
* ```TS
|
|
416
|
+
* const username = await client.getUsername("14727faefbdc4aff848cd2713eb9939e");
|
|
417
|
+
* ```
|
|
383
418
|
*/
|
|
384
419
|
async getUsername(UUID, config) {
|
|
385
420
|
const profile = await this.getProfile(UUID, config);
|
|
@@ -390,6 +425,11 @@ var Client = class {
|
|
|
390
425
|
* Returns an Array of Player Sessions consisting of their Usernames, UUIDs, Skins and Capes
|
|
391
426
|
*
|
|
392
427
|
* Players considered "INVALID" are excluded from the results
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* ```TS
|
|
431
|
+
* const sessions = await client.getSessions(["Pixelic", "14727faefbdc4aff848cd2713eb9939e"]);
|
|
432
|
+
* ```
|
|
393
433
|
*/
|
|
394
434
|
async getSessions(players, config) {
|
|
395
435
|
try {
|
|
@@ -415,6 +455,10 @@ var Client = class {
|
|
|
415
455
|
/**
|
|
416
456
|
* Returns a Player's Sessions consisting of their Username, UUID, Skin and Cape
|
|
417
457
|
*
|
|
458
|
+
* @example
|
|
459
|
+
* ```TS
|
|
460
|
+
* const session = await client.getSession("Pixelic");
|
|
461
|
+
* ```
|
|
418
462
|
*/
|
|
419
463
|
async getSession(player, config) {
|
|
420
464
|
if (this.shouldValidate(config) && !validatePlayer(player, this.getValidationMinLength(config)))
|
|
@@ -465,6 +509,10 @@ var Client = class {
|
|
|
465
509
|
/**
|
|
466
510
|
* A simple Wrapper to retrieve only the Skin from a Player's Session
|
|
467
511
|
*
|
|
512
|
+
* @example
|
|
513
|
+
* ```TS
|
|
514
|
+
* const skin = await client.getSkin("Pixelic");
|
|
515
|
+
* ```
|
|
468
516
|
*/
|
|
469
517
|
async getSkin(player, config) {
|
|
470
518
|
const session = await this.getSession(player, config);
|
|
@@ -474,6 +522,10 @@ var Client = class {
|
|
|
474
522
|
/**
|
|
475
523
|
* A simple Wrapper to retrieve only the Player's Skin from their Session Data loaded into a Buffer
|
|
476
524
|
*
|
|
525
|
+
* @example
|
|
526
|
+
* ```TS
|
|
527
|
+
* const skinBuffer = await client.getSkinBuffer("Pixelic");
|
|
528
|
+
* ```
|
|
477
529
|
*/
|
|
478
530
|
async getSkinBuffer(player, config) {
|
|
479
531
|
const session = await this.getSession(player, config);
|
|
@@ -487,6 +539,10 @@ var Client = class {
|
|
|
487
539
|
/**
|
|
488
540
|
* A simple Wrapper to retrieve only the Cape Data from a Player's Session
|
|
489
541
|
*
|
|
542
|
+
* @example
|
|
543
|
+
* ```TS
|
|
544
|
+
* const cape = await client.getCape("Pixelic");
|
|
545
|
+
* ```
|
|
490
546
|
*/
|
|
491
547
|
async getCape(player, config) {
|
|
492
548
|
const session = await this.getSession(player, config);
|
|
@@ -496,6 +552,10 @@ var Client = class {
|
|
|
496
552
|
/**
|
|
497
553
|
* A simple Wrapper to retrieve only the Player's Cape from their Session Data loaded into a Buffer
|
|
498
554
|
*
|
|
555
|
+
* @example
|
|
556
|
+
* ```TS
|
|
557
|
+
* const capeBuffer = await client.getCapeBuffer("Pixelic");
|
|
558
|
+
* ```
|
|
499
559
|
*/
|
|
500
560
|
async getCapeBuffer(player, config) {
|
|
501
561
|
const session = await this.getSession(player, config);
|