@epicauth/sdk 0.1.3 → 1.0.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/README.md CHANGED
@@ -2,14 +2,49 @@
2
2
 
3
3
  To install dependencies:
4
4
 
5
+ ## **`Bun`**
5
6
  ```bash
6
- bun install
7
+ bun add @epicauth/sdk
7
8
  ```
8
-
9
- To run:
10
-
9
+ ## **`npm`**
11
10
  ```bash
12
- bun run index.ts
11
+ npm install @epicauth/sdk
13
12
  ```
14
13
 
15
14
  This project was created using `bun init` in bun v1.3.13. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
15
+
16
+
17
+ ## **`EpicAuthApp` instance definition**
18
+
19
+ Visit https://epicauth.cc/app/ and select your application, then click on the **Javascript** tab.
20
+
21
+ It'll provide you with the code which you should replace in the `epicauth.ts` file.
22
+
23
+ ```typescript
24
+ const EpicAuthApp = new EpicAuth({
25
+ name: "", // App name (Manage Applications --> Application name)
26
+ ownerid: "", // Owner ID (Account-Settings --> OwnerID)
27
+ version: "",
28
+ });
29
+ ```
30
+
31
+ ## **Initialize application**
32
+
33
+ ```typescript
34
+ await EpicAuthApp.init();
35
+ ```
36
+
37
+ ## **Display application information**
38
+
39
+ ```typescript
40
+ await EpicAuthApp.fetchStats();
41
+ console.log(`
42
+ App data:
43
+ Number of users: ${EpicAuthApp.app_data?.numUsers}
44
+ Number of online users: ${EpicAuthApp.app_data?.onlineUsers}
45
+ Number of keys: ${EpicAuthApp.app_data?.numKeys}
46
+ Application Version: ${EpicAuthApp.app_data?.app_ver}
47
+ Customer panel link: ${EpicAuthApp.app_data?.customer_panel}
48
+ `);
49
+ ```
50
+
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { EpicAuthAppData, EpicAuthOptions, EpicAuthUserData } from "./types/types";
2
- import type { LicenseOptions, LoginOptions } from "./types/inputs";
2
+ import type { LicenseOptions, LoginOptions, RegisterOptions, UpgradeOptions, WebhookOptions } from "./types/inputs";
3
3
  export default class EpicAuth {
4
4
  private name;
5
5
  private ownerid;
@@ -15,7 +15,19 @@ export default class EpicAuth {
15
15
  user_data: EpicAuthUserData | null;
16
16
  app_data: EpicAuthAppData | null;
17
17
  constructor(options: EpicAuthOptions);
18
- Init(): Promise<undefined>;
18
+ /**
19
+ * Initialize EpicAuth authentication service.
20
+ *
21
+ * This method sets up the authentication client, loads configuration,
22
+ * and prepares the necessary tokens and listeners.
23
+ *
24
+ * **Important**: Must be called **exactly once** during app startup,
25
+ * preferably in the main entry point or root module.
26
+ *
27
+ * @returns {Promise<void>} Resolves when initialization is complete.
28
+ * @throws {EpicAuthError} If configuration is invalid or network error occurs.
29
+ */
30
+ init(): Promise<undefined>;
19
31
  /**
20
32
  * Login to EpicAuth using a username and password.
21
33
  *
@@ -34,12 +46,161 @@ export default class EpicAuth {
34
46
  * @param hwid Optional custom HWID.
35
47
  */
36
48
  license({ license, code, hwid }: LicenseOptions): Promise<undefined>;
49
+ /**
50
+ * Register to EpicAuth using a username and password.
51
+ *
52
+ * @param username User's username.
53
+ * @param password User's password.
54
+ * @param license User's license.
55
+ * @param hwid Optional custom HWID.
56
+ */
57
+ register({ username, password, license, hwid }: RegisterOptions): Promise<undefined>;
58
+ /**
59
+ * Upgrade your user by license
60
+ *
61
+ * @param username User's username
62
+ * @param license the license to upgrade user expiry
63
+ * @description license should be not used
64
+ */
65
+ upgrade({ username, license }: UpgradeOptions): Promise<never>;
66
+ /**
67
+ * Get global Var
68
+ *
69
+ * @param name var name
70
+ */
71
+ var({ name }: {
72
+ name: string;
73
+ }): Promise<void>;
74
+ /**
75
+ * get user variable
76
+ *
77
+ * @param name User's variable name
78
+ */
79
+ getvar({ name }: {
80
+ name: string;
81
+ }): Promise<void>;
82
+ /**
83
+ * edit user variable
84
+ *
85
+ * @param name User's variable name
86
+ * @param value User's variable value
87
+ */
88
+ setvar({ name, value }: {
89
+ name: string;
90
+ value: string;
91
+ }): Promise<true | undefined>;
92
+ /**
93
+ * Ban function
94
+ *
95
+ * @description Ban current user
96
+ */
97
+ ban(): Promise<true | undefined>;
98
+ /**
99
+ * EpicAuth file system
100
+ *
101
+ * @param id file id, Avilable in dashboard
102
+ * @description Download files by it's id
103
+ */
104
+ file({ id }: {
105
+ id: string;
106
+ }): Promise<Buffer<ArrayBuffer> | undefined>;
107
+ /**
108
+ * EpicAuth's Webhook function
109
+ *
110
+ * @param id file id
111
+ */
112
+ webhook({ id, param, body, conttype }: WebhookOptions): Promise<string | undefined>;
113
+ /**
114
+ * Check auth function
115
+ *
116
+ * @description check auth fo current session
117
+ */
118
+ check(): Promise<true | undefined>;
119
+ /**
120
+ * Check Blacklist
121
+ *
122
+ * @description Check if user in blacklisted or not
123
+ */
124
+ checkblacklist(): Promise<true | undefined>;
125
+ /**
126
+ * Log function
127
+ *
128
+ * @description send log to EpicAuth or webhook if exist.
129
+ */
130
+ log({ message }: {
131
+ message: string;
132
+ }): Promise<void>;
133
+ /**
134
+ * FetchOnline function
135
+ *
136
+ * @description Get number of online users
137
+ */
138
+ fetchOnline(): Promise<number | false | null>;
139
+ /**
140
+ * FetchStats function
141
+ *
142
+ * @description Get application status
143
+ */
144
+ fetchStats(): Promise<void>;
145
+ /**
146
+ * Chat Get function
147
+ * @param channel Channel name
148
+ * @description retrive messages
149
+ * @returns return { author: string; message: string; timestamp: number; } [] | null
150
+ */
151
+ chatGet({ channel }: {
152
+ channel: string;
153
+ }): Promise<false | {
154
+ author: string;
155
+ message: string;
156
+ timestamp: number;
157
+ }[] | null>;
158
+ /**
159
+ * Chat Send function
160
+ * @param channel Channel name
161
+ * @param message message to send
162
+ * @description Send message to channel
163
+ * @returns return true | false
164
+ */
165
+ chatSend({ message, channel }: {
166
+ message: string;
167
+ channel: string;
168
+ }): Promise<boolean>;
169
+ /**
170
+ * Change username function
171
+ *
172
+ * @param username users' username
173
+ * @description change user's username
174
+ */
175
+ changeUsername({ username }: {
176
+ username: string;
177
+ }): Promise<false | undefined>;
178
+ /**
179
+ * Logout function
180
+ * @description logout & close session
181
+ */
182
+ logout(): Promise<void>;
183
+ /**
184
+ * Enable 2FA
185
+ * @param code 2fa code in second time
186
+ * @description Enable 2FA
187
+ */
188
+ enable2fa({ code }: {
189
+ code?: string;
190
+ }): Promise<void>;
191
+ /**
192
+ * Disable 2FA
193
+ * @description Disable 2FA
194
+ */
195
+ disable2fa(): Promise<void>;
37
196
  checkinit(): Promise<undefined>;
38
197
  getHWID(): string;
198
+ displayQrCode(qrCodeUrl: string): Promise<void>;
39
199
  private fail;
40
200
  private sleep;
41
201
  private request;
42
202
  private logEvent;
43
203
  private redactField;
204
+ private load_app_data;
44
205
  private load_user_data;
45
206
  }
package/dist/client.js CHANGED
@@ -7,6 +7,7 @@ import os from "os";
7
7
  import { createInterface } from "readline";
8
8
  import path from "node:path";
9
9
  import { sha512 } from "@noble/hashes/sha2.js";
10
+ import * as QRCode from "qrcode";
10
11
  ed.hashes.sha512 = (...msgs) => sha512(ed.etc.concatBytes(...msgs));
11
12
  const readline = createInterface({
12
13
  input: process.stdin,
@@ -40,7 +41,19 @@ export default class EpicAuth {
40
41
  throw new Error("Name, ownerid, and version are required");
41
42
  }
42
43
  }
43
- async Init() {
44
+ /**
45
+ * Initialize EpicAuth authentication service.
46
+ *
47
+ * This method sets up the authentication client, loads configuration,
48
+ * and prepares the necessary tokens and listeners.
49
+ *
50
+ * **Important**: Must be called **exactly once** during app startup,
51
+ * preferably in the main entry point or root module.
52
+ *
53
+ * @returns {Promise<void>} Resolves when initialization is complete.
54
+ * @throws {EpicAuthError} If configuration is invalid or network error occurs.
55
+ */
56
+ async init() {
44
57
  if (!this.sessionid && this.initialized) {
45
58
  return this.fail("Application already initialized", 0);
46
59
  }
@@ -153,6 +166,458 @@ export default class EpicAuth {
153
166
  return this.fail(response['message']);
154
167
  }
155
168
  }
169
+ /**
170
+ * Register to EpicAuth using a username and password.
171
+ *
172
+ * @param username User's username.
173
+ * @param password User's password.
174
+ * @param license User's license.
175
+ * @param hwid Optional custom HWID.
176
+ */
177
+ async register({ username, password, license, hwid }) {
178
+ this.checkinit();
179
+ if (!hwid)
180
+ hwid = this.getHWID();
181
+ const body = {
182
+ "type": "register",
183
+ "name": this.name,
184
+ "ownerid": this.ownerid,
185
+ "sessionid": this.sessionid,
186
+ "username": username,
187
+ "pass": password,
188
+ "key": license,
189
+ "hwid": hwid,
190
+ };
191
+ const response = await this.request(body);
192
+ if (response["success"] === true) {
193
+ console.log(response["message"]);
194
+ this.load_user_data(response["info"]);
195
+ }
196
+ else {
197
+ console.log(response["message"]);
198
+ return this.fail(response['message']);
199
+ }
200
+ }
201
+ /**
202
+ * Upgrade your user by license
203
+ *
204
+ * @param username User's username
205
+ * @param license the license to upgrade user expiry
206
+ * @description license should be not used
207
+ */
208
+ async upgrade({ username, license }) {
209
+ this.checkinit();
210
+ const body = {
211
+ "type": "upgrade",
212
+ "name": this.name,
213
+ "ownerid": this.ownerid,
214
+ "sessionid": this.sessionid,
215
+ "username": username,
216
+ "key": license,
217
+ };
218
+ const response = await this.request(body);
219
+ if (response["success"] === true) {
220
+ console.log(response["message"]);
221
+ return this.fail("Restart the application to apply the changes.");
222
+ }
223
+ else {
224
+ console.log(response["message"]);
225
+ return this.fail(response['message']);
226
+ }
227
+ }
228
+ /**
229
+ * Get global Var
230
+ *
231
+ * @param name var name
232
+ */
233
+ async var({ name }) {
234
+ this.checkinit();
235
+ const body = {
236
+ "type": "var",
237
+ "name": this.name,
238
+ "ownerid": this.ownerid,
239
+ "sessionid": this.sessionid,
240
+ "varid": name
241
+ };
242
+ const response = await this.request(body);
243
+ if (response["success"] === true) {
244
+ console.log(response["message"]);
245
+ }
246
+ else {
247
+ this.fail(response["message"] ?? "var error");
248
+ }
249
+ }
250
+ /**
251
+ * get user variable
252
+ *
253
+ * @param name User's variable name
254
+ */
255
+ async getvar({ name }) {
256
+ this.checkinit();
257
+ const body = {
258
+ "type": "getvar",
259
+ "name": this.name,
260
+ "ownerid": this.ownerid,
261
+ "sessionid": this.sessionid,
262
+ "var": name
263
+ };
264
+ const response = await this.request(body);
265
+ if (response["success"] === true) {
266
+ console.log(response["message"]);
267
+ }
268
+ else {
269
+ this.fail(response["message"] ?? "getvar error");
270
+ }
271
+ }
272
+ /**
273
+ * edit user variable
274
+ *
275
+ * @param name User's variable name
276
+ * @param value User's variable value
277
+ */
278
+ async setvar({ name, value }) {
279
+ this.checkinit();
280
+ const body = {
281
+ "type": "setvar",
282
+ "name": this.name,
283
+ "ownerid": this.ownerid,
284
+ "sessionid": this.sessionid,
285
+ "varid": name,
286
+ "data": value,
287
+ };
288
+ const response = await this.request(body);
289
+ if (response["success"] === true) {
290
+ return true;
291
+ }
292
+ else {
293
+ this.fail(response["message"] ?? "setvar error");
294
+ }
295
+ }
296
+ /**
297
+ * Ban function
298
+ *
299
+ * @description Ban current user
300
+ */
301
+ async ban() {
302
+ this.checkinit();
303
+ const body = {
304
+ "type": "ban",
305
+ "name": this.name,
306
+ "ownerid": this.ownerid,
307
+ "sessionid": this.sessionid,
308
+ };
309
+ const response = await this.request(body);
310
+ if (response["success"] === true) {
311
+ return true;
312
+ }
313
+ else {
314
+ this.fail(response["message"]);
315
+ }
316
+ }
317
+ /**
318
+ * EpicAuth file system
319
+ *
320
+ * @param id file id, Avilable in dashboard
321
+ * @description Download files by it's id
322
+ */
323
+ async file({ id }) {
324
+ this.checkinit();
325
+ const body = {
326
+ "type": "file",
327
+ "name": this.name,
328
+ "ownerid": this.ownerid,
329
+ "sessionid": this.sessionid,
330
+ "fileid": id
331
+ };
332
+ const response = await this.request(body);
333
+ if (response["success"] === true) {
334
+ return Buffer.from(response['contents']);
335
+ }
336
+ else {
337
+ this.fail(response["message"]);
338
+ }
339
+ }
340
+ /**
341
+ * EpicAuth's Webhook function
342
+ *
343
+ * @param id file id
344
+ */
345
+ async webhook({ id, param, body, conttype }) {
346
+ this.checkinit();
347
+ const data = {
348
+ "type": "webhook",
349
+ "name": this.name,
350
+ "ownerid": this.ownerid,
351
+ "sessionid": this.sessionid,
352
+ "webid": id,
353
+ "params": param,
354
+ "body": body,
355
+ "conttype": conttype,
356
+ };
357
+ const response = await this.request(data);
358
+ if (response["success"] === true) {
359
+ return response['message'];
360
+ }
361
+ else {
362
+ this.fail(response["message"]);
363
+ }
364
+ }
365
+ /**
366
+ * Check auth function
367
+ *
368
+ * @description check auth fo current session
369
+ */
370
+ async check() {
371
+ this.checkinit();
372
+ const body = {
373
+ "type": "check",
374
+ "name": this.name,
375
+ "ownerid": this.ownerid,
376
+ "sessionid": this.sessionid,
377
+ };
378
+ const response = await this.request(body);
379
+ if (response["success"] === true) {
380
+ return true;
381
+ }
382
+ else {
383
+ this.fail(response["message"]);
384
+ }
385
+ }
386
+ /**
387
+ * Check Blacklist
388
+ *
389
+ * @description Check if user in blacklisted or not
390
+ */
391
+ async checkblacklist() {
392
+ this.checkinit();
393
+ const hwid = this.getHWID();
394
+ const body = {
395
+ "type": "checkblacklist",
396
+ "name": this.name,
397
+ "ownerid": this.ownerid,
398
+ "sessionid": this.sessionid,
399
+ "hwid": hwid,
400
+ };
401
+ const response = await this.request(body);
402
+ if (response["success"] === true) {
403
+ return true;
404
+ }
405
+ else {
406
+ this.fail(response["message"]);
407
+ }
408
+ }
409
+ /**
410
+ * Log function
411
+ *
412
+ * @description send log to EpicAuth or webhook if exist.
413
+ */
414
+ async log({ message }) {
415
+ this.checkinit();
416
+ const body = {
417
+ "type": "log",
418
+ "name": this.name,
419
+ "ownerid": this.ownerid,
420
+ "sessionid": this.sessionid,
421
+ "message": message,
422
+ "pcuser": os.userInfo().username,
423
+ };
424
+ await this.request(body);
425
+ }
426
+ /**
427
+ * FetchOnline function
428
+ *
429
+ * @description Get number of online users
430
+ */
431
+ async fetchOnline() {
432
+ this.checkinit();
433
+ const body = {
434
+ "type": "fetchOnline",
435
+ "name": this.name,
436
+ "ownerid": this.ownerid,
437
+ "sessionid": this.sessionid,
438
+ };
439
+ const response = await this.request(body);
440
+ if (response["success"] === true) {
441
+ if ("users" in response) {
442
+ return Number(response['users']);
443
+ }
444
+ else {
445
+ return null;
446
+ }
447
+ }
448
+ else {
449
+ return false;
450
+ }
451
+ }
452
+ /**
453
+ * FetchStats function
454
+ *
455
+ * @description Get application status
456
+ */
457
+ async fetchStats() {
458
+ this.checkinit();
459
+ const body = {
460
+ "type": "fetchStats",
461
+ "name": this.name,
462
+ "ownerid": this.ownerid,
463
+ "sessionid": this.sessionid,
464
+ };
465
+ const response = await this.request(body);
466
+ if (response["success"] === true) {
467
+ return this.load_app_data(response['appinfo']);
468
+ }
469
+ }
470
+ /**
471
+ * Chat Get function
472
+ * @param channel Channel name
473
+ * @description retrive messages
474
+ * @returns return { author: string; message: string; timestamp: number; } [] | null
475
+ */
476
+ async chatGet({ channel }) {
477
+ this.checkinit();
478
+ const body = {
479
+ "type": "chatget",
480
+ "name": this.name,
481
+ "ownerid": this.ownerid,
482
+ "sessionid": this.sessionid,
483
+ "channel": channel,
484
+ };
485
+ const response = await this.request(body);
486
+ if (response["success"] === true) {
487
+ return response["messages"];
488
+ }
489
+ else {
490
+ return false;
491
+ }
492
+ }
493
+ /**
494
+ * Chat Send function
495
+ * @param channel Channel name
496
+ * @param message message to send
497
+ * @description Send message to channel
498
+ * @returns return true | false
499
+ */
500
+ async chatSend({ message, channel }) {
501
+ this.checkinit();
502
+ const body = {
503
+ "type": "chatsend",
504
+ "name": this.name,
505
+ "ownerid": this.ownerid,
506
+ "sessionid": this.sessionid,
507
+ "channel": channel,
508
+ "message": message,
509
+ };
510
+ const response = await this.request(body);
511
+ if (response["success"] === true) {
512
+ return true;
513
+ }
514
+ else {
515
+ return false;
516
+ }
517
+ }
518
+ /**
519
+ * Change username function
520
+ *
521
+ * @param username users' username
522
+ * @description change user's username
523
+ */
524
+ async changeUsername({ username }) {
525
+ this.checkinit();
526
+ const body = {
527
+ "type": "changeUsername",
528
+ "newUsername": username,
529
+ "name": this.name,
530
+ "ownerid": this.ownerid,
531
+ "sessionid": this.sessionid,
532
+ };
533
+ const response = await this.request(body);
534
+ if (response["success"] === true) {
535
+ console.log("Username changed successfully");
536
+ }
537
+ else {
538
+ return false;
539
+ }
540
+ }
541
+ /**
542
+ * Logout function
543
+ * @description logout & close session
544
+ */
545
+ async logout() {
546
+ this.checkinit();
547
+ const body = {
548
+ "type": "logout",
549
+ "name": this.name,
550
+ "ownerid": this.ownerid,
551
+ "sessionid": this.sessionid,
552
+ };
553
+ const response = await this.request(body);
554
+ if (response["success"] === true) {
555
+ this.fail("Logged out successfully");
556
+ }
557
+ else {
558
+ this.fail(response["message"]);
559
+ }
560
+ }
561
+ /**
562
+ * Enable 2FA
563
+ * @param code 2fa code in second time
564
+ * @description Enable 2FA
565
+ */
566
+ async enable2fa({ code }) {
567
+ this.checkinit();
568
+ const post_data = {
569
+ "type": "2faenable",
570
+ "name": this.name,
571
+ "ownerid": this.ownerid,
572
+ "sessionid": this.sessionid,
573
+ ...code && { "code": code },
574
+ };
575
+ const response = await this.request(post_data);
576
+ if (response["success"] === true) {
577
+ if (!code) {
578
+ console.log(response);
579
+ console.log("Your 2fa secret code is: " + response["2fa"]["secret_code"]);
580
+ this.displayQrCode(response["2fa"]["QRCode"]);
581
+ console.log("Please enter the code you received in your authenticator app.");
582
+ const userCode = await new Promise((resolve) => {
583
+ readline.question("Enter the code: ", (input) => {
584
+ resolve(input);
585
+ });
586
+ });
587
+ await this.enable2fa({ code: userCode });
588
+ }
589
+ else {
590
+ console.log("2FA enabled successfully");
591
+ }
592
+ }
593
+ else {
594
+ console.log(response["message"]);
595
+ this.sleep(5000);
596
+ process.exit(0);
597
+ }
598
+ }
599
+ /**
600
+ * Disable 2FA
601
+ * @description Disable 2FA
602
+ */
603
+ async disable2fa() {
604
+ this.checkinit();
605
+ const code = await new Promise((resolve) => {
606
+ readline.question("Enter the code: ", (input) => {
607
+ resolve(input);
608
+ });
609
+ });
610
+ const post_data = {
611
+ "type": "2fadisable",
612
+ "name": this.name,
613
+ "ownerid": this.ownerid,
614
+ "sessionid": this.sessionid,
615
+ "code": code,
616
+ };
617
+ const response = await this.request(post_data);
618
+ console.log(response["message"]);
619
+ await this.sleep(5000);
620
+ }
156
621
  async checkinit() {
157
622
  if (!this.sessionid && !this.initialized) {
158
623
  return this.fail("You need to run the EpicAuthApp.init(); function before any other EpicAuth functions");
@@ -231,6 +696,41 @@ export default class EpicAuth {
231
696
  .digest("hex")
232
697
  .substring(0, 32);
233
698
  }
699
+ async displayQrCode(qrCodeUrl) {
700
+ try {
701
+ const qrCode = await QRCode.toDataURL(qrCodeUrl);
702
+ const base64Data = qrCode.split(",")[1];
703
+ if (!base64Data) {
704
+ throw new Error("Invalid QR code data");
705
+ }
706
+ const img = Buffer.from(base64Data, "base64");
707
+ const outputPath = this.path ?? "qrcode.png";
708
+ fs.writeFileSync(outputPath, img);
709
+ const platform = os.platform();
710
+ let openCommand;
711
+ if (platform === "win32") {
712
+ openCommand = `start ${outputPath}`;
713
+ }
714
+ else if (platform === "darwin") {
715
+ openCommand = `open ${outputPath}`;
716
+ }
717
+ else if (platform === "linux") {
718
+ openCommand = `xdg-open ${outputPath}`;
719
+ }
720
+ else {
721
+ console.error("Unsupported platform for opening the QR code image");
722
+ return;
723
+ }
724
+ exec(openCommand, (error) => {
725
+ if (error) {
726
+ console.error("Failed to display the QR code image:", error);
727
+ }
728
+ });
729
+ }
730
+ catch (error) {
731
+ console.error("Failed to generate QR code:", error);
732
+ }
733
+ }
234
734
  async fail(message, ms = 5000) {
235
735
  if (this.exitOnError) {
236
736
  console.error(message);
@@ -332,6 +832,15 @@ export default class EpicAuth {
332
832
  const regex = new RegExp(`"${field}":\\s*".*?"`, "g");
333
833
  return content.replace(regex, `"${field}": "[REDACTED]"`);
334
834
  }
835
+ load_app_data(data) {
836
+ this.app_data = {
837
+ numUsers: Number(data["numUsers"]),
838
+ numKeys: Number(data["numKeys"]),
839
+ app_ver: data["version"],
840
+ customer_panel: data["customerPanelLink"],
841
+ onlineUsers: Number(data["numOnlineUsers"]),
842
+ };
843
+ }
335
844
  load_user_data(data) {
336
845
  const subscription = data.subscriptions[0];
337
846
  if (!subscription) {
package/dist/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
+ export { default as EpicAuth } from "./client";
2
+ export { EpicAuthError } from "./errors";
1
3
  import EpicAuth from "./client";
2
4
  export default EpicAuth;
package/dist/index.js CHANGED
@@ -1,2 +1,5 @@
1
+ // src/index.ts
2
+ export { default as EpicAuth } from "./client";
3
+ export { EpicAuthError } from "./errors";
1
4
  import EpicAuth from "./client";
2
5
  export default EpicAuth;
@@ -9,3 +9,19 @@ export interface LicenseOptions {
9
9
  code?: string;
10
10
  hwid?: string;
11
11
  }
12
+ export interface RegisterOptions {
13
+ username: string;
14
+ password: string;
15
+ license: string;
16
+ hwid?: string;
17
+ }
18
+ export interface UpgradeOptions {
19
+ username: string;
20
+ license: string;
21
+ }
22
+ export interface WebhookOptions {
23
+ id: string;
24
+ param: string;
25
+ body?: string;
26
+ conttype?: string;
27
+ }
@@ -64,3 +64,174 @@ export interface LicenseResponse {
64
64
  nonce: string;
65
65
  ownerid: string;
66
66
  }
67
+ export interface RegisterResponse {
68
+ success: boolean;
69
+ code: number;
70
+ message: string;
71
+ info: {
72
+ username: string;
73
+ subscriptions: {
74
+ subscription: string;
75
+ key: string;
76
+ expiry: string;
77
+ timeleft: number;
78
+ level: string;
79
+ }[];
80
+ ip: string;
81
+ hwid: string | undefined;
82
+ createdate: string | number;
83
+ lastlogin: string;
84
+ };
85
+ nonce: string;
86
+ ownerid: string;
87
+ }
88
+ export interface UpgradeResponse {
89
+ success: boolean;
90
+ code: number;
91
+ message: string | null;
92
+ nonce: string;
93
+ ownerid: string;
94
+ }
95
+ export interface VarResponse {
96
+ success: boolean;
97
+ code: number;
98
+ message: string;
99
+ nonce: string;
100
+ ownerid: string;
101
+ }
102
+ export interface GetvarResponse {
103
+ success: boolean;
104
+ code: number;
105
+ message: string;
106
+ response: string;
107
+ nonce: string;
108
+ ownerid: string;
109
+ }
110
+ export interface SetvarResponse {
111
+ success: boolean;
112
+ code: number;
113
+ message: string;
114
+ nonce: string;
115
+ ownerid: string;
116
+ }
117
+ export interface BanResponse {
118
+ success: boolean;
119
+ code: number;
120
+ message: string;
121
+ nonce: string;
122
+ ownerid: string;
123
+ }
124
+ export interface FileResponse {
125
+ success: boolean;
126
+ code: number;
127
+ message: string;
128
+ contents: string;
129
+ nonce: string;
130
+ ownerid: string;
131
+ }
132
+ export interface WebhookResponse {
133
+ success: boolean;
134
+ code: number;
135
+ message: string;
136
+ response: string;
137
+ ownerid: string;
138
+ nonce: string;
139
+ }
140
+ export interface CheckResponse {
141
+ success: boolean;
142
+ code: number;
143
+ message: string;
144
+ nonce: string;
145
+ ownerid: string;
146
+ }
147
+ export interface CheckBlacklistResponse {
148
+ success: boolean;
149
+ code: number;
150
+ message: string;
151
+ nonce: string;
152
+ ownerid: string;
153
+ }
154
+ export interface fetchOnlineResponse {
155
+ success: boolean;
156
+ code: number;
157
+ message: string;
158
+ nonce: string;
159
+ ownerid: string;
160
+ }
161
+ export interface fetchOnlineResponse2 {
162
+ success: boolean;
163
+ code: number;
164
+ message: string;
165
+ users: string[];
166
+ nonce: string;
167
+ ownerid: string;
168
+ }
169
+ export interface fetchStatsResponse {
170
+ success: boolean;
171
+ code: number;
172
+ message: string;
173
+ appinfo: {
174
+ numUsers: string;
175
+ numOnlineUsers: string;
176
+ numKeys: string;
177
+ version: string;
178
+ customerPanelLink: string;
179
+ };
180
+ nonce: string;
181
+ ownerid: string;
182
+ }
183
+ export interface ChatGetResponse {
184
+ success: boolean;
185
+ code: number;
186
+ message: string;
187
+ messages: {
188
+ author: string;
189
+ message: string;
190
+ timestamp: number;
191
+ }[] | null;
192
+ nonce: string;
193
+ ownerid: string;
194
+ }
195
+ export interface ChatSendResponse {
196
+ success: boolean;
197
+ code: number;
198
+ message: string;
199
+ nonce: string;
200
+ ownerid: string;
201
+ }
202
+ export interface ChangeUsernameResponse {
203
+ success: boolean;
204
+ code: number;
205
+ message: string;
206
+ nonce: string;
207
+ ownerid: string;
208
+ }
209
+ export interface LogoutResponse {
210
+ success: boolean;
211
+ code: number;
212
+ message: string;
213
+ nonce: string;
214
+ ownerid: string;
215
+ }
216
+ export interface Enable2faResponse {
217
+ success: boolean;
218
+ message: string;
219
+ code: number;
220
+ "2fa": {
221
+ secret_code: string;
222
+ QRCode: string;
223
+ };
224
+ nonce: string;
225
+ ownerid: string;
226
+ }
227
+ export interface Disable2faResponse {
228
+ success: boolean;
229
+ message: string;
230
+ code: number;
231
+ "2fa": {
232
+ secret_code: string;
233
+ QRCode: string;
234
+ };
235
+ nonce: string;
236
+ ownerid: string;
237
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epicauth/sdk",
3
- "version": "0.1.3",
3
+ "version": "1.0.0",
4
4
  "description": "EpicAuth SDK for Node.js and Bun",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -25,7 +25,9 @@
25
25
  "license": "Elastic-2.0",
26
26
  "dependencies": {
27
27
  "@noble/ed25519": "^3.1.0",
28
- "@noble/hashes": "^2.2.0"
28
+ "@noble/hashes": "^2.2.0",
29
+ "@types/qrcode": "^1.5.6",
30
+ "qrcode": "^1.5.4"
29
31
  },
30
32
  "devDependencies": {
31
33
  "@types/bun": "latest",