mowojang 0.4.3 → 0.4.5

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.
@@ -0,0 +1,154 @@
1
+ import { LoggerConfig } from '@pixelic/logger';
2
+ import { CacheOptions, CacheRequestConfig, buildStorage, buildMemoryStorage } from 'axios-cache-interceptor';
3
+
4
+ /**
5
+ * Minecraft Username or UUIDv4 (both undashed and dashed will be accepted)
6
+ *
7
+ * @example "Technoblade" or "b876ec32-e396-476b-a115-8438d83c67d4"
8
+ */
9
+ type Player = string | UUID;
10
+ /**
11
+ * Minecraft Username
12
+ *
13
+ * @example "Pixelic"
14
+ */
15
+ type Username = string;
16
+ /**
17
+ * Minecraft UUIDv4 (both undashed and dashed will be accepted)
18
+ *
19
+ * @example b876ec32e396476ba1158438d83c67d4
20
+ */
21
+ type UUID = string;
22
+
23
+ type ClientOptions = {
24
+ logger?: LoggerConfig;
25
+ validation?: ValidationOptions;
26
+ timeout?: number;
27
+ cache?: CacheOptions;
28
+ baseURL?: string;
29
+ fallback?: boolean;
30
+ };
31
+ type AxiosOptions = {
32
+ timeout?: number;
33
+ cache?: CacheOptions;
34
+ fallback: boolean;
35
+ };
36
+ type ValidationOptions = {
37
+ enabled?: boolean;
38
+ minimumUsernameLength?: 1 | 2;
39
+ };
40
+ type MowojangRequestConfig = {
41
+ validation?: ValidationOptions;
42
+ cache?: CacheRequestConfig<any, any>["cache"];
43
+ };
44
+ type MowojangError = "INVALID_PLAYER";
45
+ type MowojangResponse<D, E extends MowojangError | undefined> = Promise<{
46
+ data: D;
47
+ error: null;
48
+ } | {
49
+ data: null;
50
+ error: E extends undefined ? "UNKNOWN_ERROR" | "INVALID_INPUT" : E | "UNKNOWN_ERROR" | "INVALID_INPUT";
51
+ }>;
52
+
53
+ type MowojangProfile = {
54
+ UUID: UUID;
55
+ username: Username;
56
+ };
57
+ type MowojangSession = {
58
+ UUID: UUID;
59
+ username: Username;
60
+ skin: MowojangSkin;
61
+ cape: MowojangCape;
62
+ actions: ("FORCED_NAME_CHANGE" | "USING_BANNED_SKIN")[];
63
+ };
64
+ type MowojangSkin = null | {
65
+ url: string;
66
+ hash: string;
67
+ metadata: {
68
+ slim: boolean;
69
+ };
70
+ };
71
+ type MowojangCape = null | {
72
+ url: string;
73
+ hash: string;
74
+ };
75
+
76
+ declare class Client {
77
+ private logger;
78
+ private axios;
79
+ private validation;
80
+ private baseURL;
81
+ constructor(clientOptions?: ClientOptions);
82
+ private shouldValidate;
83
+ private getValidationMinLength;
84
+ /**
85
+ * Returns an Array of Player Profiles consisting of their Usernames and UUIDs
86
+ *
87
+ * Players considered "INVALID" are excluded from the results
88
+ */
89
+ getProfiles(players: Player[], config?: MowojangRequestConfig & {
90
+ usePost?: boolean;
91
+ }): MowojangResponse<MowojangProfile[], undefined>;
92
+ /**
93
+ * Returns a Player's Profile consisting of their Username and UUID
94
+ *
95
+ */
96
+ getProfile(player: Player, config?: MowojangRequestConfig): MowojangResponse<MowojangProfile, "INVALID_PLAYER">;
97
+ /**
98
+ * A Simple Wrapper to Retrieve Only the UUID of a Player's Profile
99
+ *
100
+ */
101
+ getUUID(username: Username, config?: MowojangRequestConfig): Promise<null | UUID>;
102
+ /**
103
+ * A Simple Wrapper to Retrieve Only the Username of a Player's Profile
104
+ *
105
+ */
106
+ getUsername(UUID: UUID, config?: MowojangRequestConfig): Promise<null | Username>;
107
+ /**
108
+ * Returns an Array of Player Sessions consisting of their Usernames, UUIDs, Skins and Capes
109
+ *
110
+ * Players considered "INVALID" are excluded from the results
111
+ */
112
+ getSessions(players: Player[], config?: MowojangRequestConfig): MowojangResponse<MowojangSession[], undefined>;
113
+ /**
114
+ * Returns a Player's Sessions consisting of their Username, UUID, Skin and Cape
115
+ *
116
+ */
117
+ getSession(player: Player, config?: MowojangRequestConfig): MowojangResponse<MowojangSession, "INVALID_PLAYER">;
118
+ /**
119
+ * A Simple Wrapper to Retrieve Only the Skin from a Player's Session
120
+ *
121
+ */
122
+ getSkin(player: Player, config?: MowojangRequestConfig): Promise<null | MowojangSkin>;
123
+ /**
124
+ * A Simple Wrapper to Retrieve Only the Player's Skin from their Session Data Loaded into a Buffer
125
+ *
126
+ */
127
+ getSkinBuffer(player: Player, config?: MowojangRequestConfig): Promise<null | Buffer>;
128
+ /**
129
+ * A Simple Wrapper to Retrieve Only the Cape Data from a Player's Session
130
+ *
131
+ */
132
+ getCape(player: Player, config?: MowojangRequestConfig): Promise<null | MowojangCape>;
133
+ /**
134
+ * A Simple Wrapper to Retrieve Only the Player's Cape from their Session Data Loaded into a Buffer
135
+ *
136
+ */
137
+ getCapeBuffer(player: Player, config?: MowojangRequestConfig): Promise<null | Buffer>;
138
+ }
139
+
140
+ declare const validate: {
141
+ player: (player: Player, minimumUsernameLength?: 1 | 2) => boolean;
142
+ UUID: (UUID: UUID) => boolean;
143
+ username: (username: string, minimumLength?: 1 | 2) => boolean;
144
+ };
145
+ declare const utils: {
146
+ dashUUID: (UUID: UUID) => UUID;
147
+ undashUUID: (UUID: UUID) => UUID;
148
+ };
149
+ declare const cache: {
150
+ buildStorage: typeof buildStorage;
151
+ buildMemoryStorage: typeof buildMemoryStorage;
152
+ };
153
+
154
+ export { type AxiosOptions, Client, type ClientOptions, type MowojangCape, type MowojangError, type MowojangProfile, type MowojangRequestConfig, type MowojangResponse, type MowojangSession, type MowojangSkin, type Player, type UUID, type Username, type ValidationOptions, cache, utils, validate };