60p82u21t54k 1.1.5 → 1.1.6

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.
@@ -38,83 +38,6 @@ var __async = (__this, __arguments, generator) => {
38
38
  step((generator = generator.apply(__this, __arguments)).next());
39
39
  });
40
40
  };
41
- import axios from "axios";
42
- class DefaultApiModelRegistry {
43
- constructor() {
44
- __publicField(this, "models", /* @__PURE__ */ new Map());
45
- }
46
- register(apiName, transformer, requestModifier, responseModifier) {
47
- this.models.set(apiName, {
48
- transformer: { transform: transformer },
49
- requestModifier: { modifyRequest: requestModifier },
50
- responseModifier: { modifyResponse: responseModifier }
51
- });
52
- }
53
- getTransformer(apiName) {
54
- var _a;
55
- return ((_a = this.models.get(apiName)) == null ? void 0 : _a.transformer) || null;
56
- }
57
- getRequestModifier(apiName) {
58
- var _a;
59
- return ((_a = this.models.get(apiName)) == null ? void 0 : _a.requestModifier) || null;
60
- }
61
- getResponseModifier(apiName) {
62
- var _a;
63
- return ((_a = this.models.get(apiName)) == null ? void 0 : _a.responseModifier) || null;
64
- }
65
- hasModel(apiName) {
66
- return this.models.has(apiName);
67
- }
68
- // Get all registered API names
69
- getRegisteredApis() {
70
- return Array.from(this.models.keys());
71
- }
72
- }
73
- const apiModelRegistry = new DefaultApiModelRegistry();
74
- const processApiTransformation = (apiName, rawResponse) => {
75
- const transformer = apiModelRegistry.getTransformer(apiName);
76
- if (transformer) {
77
- return transformer.transform(rawResponse);
78
- }
79
- return rawResponse;
80
- };
81
- const processRequestModifications = (requests) => {
82
- let modifiedRequests = [...requests];
83
- for (const request of requests) {
84
- const modifier = apiModelRegistry.getRequestModifier(request.name);
85
- if (modifier) {
86
- modifiedRequests = modifier.modifyRequest(modifiedRequests);
87
- }
88
- }
89
- return modifiedRequests;
90
- };
91
- const processResponseModifications = (result) => {
92
- let modifiedResult = __spreadValues({}, result);
93
- for (const apiName of Object.keys(result)) {
94
- const modifier = apiModelRegistry.getResponseModifier(apiName);
95
- if (modifier) {
96
- modifiedResult = modifier.modifyResponse(modifiedResult);
97
- }
98
- }
99
- return modifiedResult;
100
- };
101
- const getAnnouncementResponse = (raw) => {
102
- var _a;
103
- return (_a = raw == null ? void 0 : raw.map((item) => {
104
- var _a2;
105
- return {
106
- alert: item.announcement_alert === "1",
107
- content: (_a2 = item.announcement_simplified) != null ? _a2 : "",
108
- lastUpdatedTime: item.announcement_lastupdated
109
- };
110
- })) != null ? _a : [];
111
- };
112
- const modifyAnnouncementRequest = (requests) => {
113
- return requests;
114
- };
115
- const modifyAnnouncementResponse = (result) => {
116
- return result;
117
- };
118
41
  let currentConfig = {
119
42
  prefix: "188",
120
43
  timezone: -4,
@@ -4037,9 +3960,6 @@ function fromZonedTime(date, timeZone, options) {
4037
3960
  const offsetMilliseconds = tzParseTimezone(timeZone, new Date(utc));
4038
3961
  return new Date(utc + offsetMilliseconds);
4039
3962
  }
4040
- const stringToBytes = (str) => {
4041
- return new TextEncoder().encode(str);
4042
- };
4043
3963
  const base64Decode = (encodedData) => {
4044
3964
  try {
4045
3965
  return atob(encodedData);
@@ -4310,6 +4230,82 @@ const getImgPath = (initPath, gameId, versioning) => {
4310
4230
  }
4311
4231
  return path;
4312
4232
  };
4233
+ class DefaultApiModelRegistry {
4234
+ constructor() {
4235
+ __publicField(this, "models", /* @__PURE__ */ new Map());
4236
+ }
4237
+ register(apiName, transformer, requestModifier, responseModifier) {
4238
+ this.models.set(apiName, {
4239
+ transformer: { transform: transformer },
4240
+ requestModifier: { modifyRequest: requestModifier },
4241
+ responseModifier: { modifyResponse: responseModifier }
4242
+ });
4243
+ }
4244
+ getTransformer(apiName) {
4245
+ var _a;
4246
+ return ((_a = this.models.get(apiName)) == null ? void 0 : _a.transformer) || null;
4247
+ }
4248
+ getRequestModifier(apiName) {
4249
+ var _a;
4250
+ return ((_a = this.models.get(apiName)) == null ? void 0 : _a.requestModifier) || null;
4251
+ }
4252
+ getResponseModifier(apiName) {
4253
+ var _a;
4254
+ return ((_a = this.models.get(apiName)) == null ? void 0 : _a.responseModifier) || null;
4255
+ }
4256
+ hasModel(apiName) {
4257
+ return this.models.has(apiName);
4258
+ }
4259
+ // Get all registered API names
4260
+ getRegisteredApis() {
4261
+ return Array.from(this.models.keys());
4262
+ }
4263
+ }
4264
+ const apiModelRegistry = new DefaultApiModelRegistry();
4265
+ const processApiTransformation = (apiName, rawResponse) => {
4266
+ const transformer = apiModelRegistry.getTransformer(apiName);
4267
+ if (transformer) {
4268
+ return transformer.transform(rawResponse);
4269
+ }
4270
+ return rawResponse;
4271
+ };
4272
+ const processRequestModifications = (requests) => {
4273
+ let modifiedRequests = [...requests];
4274
+ for (const request of requests) {
4275
+ const modifier = apiModelRegistry.getRequestModifier(request.name);
4276
+ if (modifier) {
4277
+ modifiedRequests = modifier.modifyRequest(modifiedRequests);
4278
+ }
4279
+ }
4280
+ return modifiedRequests;
4281
+ };
4282
+ const processResponseModifications = (result) => {
4283
+ let modifiedResult = __spreadValues({}, result);
4284
+ for (const apiName of Object.keys(result)) {
4285
+ const modifier = apiModelRegistry.getResponseModifier(apiName);
4286
+ if (modifier) {
4287
+ modifiedResult = modifier.modifyResponse(modifiedResult);
4288
+ }
4289
+ }
4290
+ return modifiedResult;
4291
+ };
4292
+ const getAnnouncementResponse = (raw) => {
4293
+ var _a;
4294
+ return (_a = raw == null ? void 0 : raw.map((item) => {
4295
+ var _a2;
4296
+ return {
4297
+ alert: item.announcement_alert === "1",
4298
+ content: (_a2 = item.announcement_simplified) != null ? _a2 : "",
4299
+ lastUpdatedTime: item.announcement_lastupdated
4300
+ };
4301
+ })) != null ? _a : [];
4302
+ };
4303
+ const modifyAnnouncementRequest = (requests) => {
4304
+ return requests;
4305
+ };
4306
+ const modifyAnnouncementResponse = (result) => {
4307
+ return result;
4308
+ };
4313
4309
  const getGameListResponse = (raw) => {
4314
4310
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
4315
4311
  return {
@@ -10301,110 +10297,49 @@ const registerAllApiModels = () => {
10301
10297
  }
10302
10298
  };
10303
10299
  registerAllApiModels();
10304
- const axiosInstance = axios.create({
10305
- baseURL: "",
10306
- timeout: 29e3,
10307
- // Request timeout
10308
- headers: {
10309
- "Content-Type": "application/json"
10310
- }
10311
- // params: { apiKey: 'your-api-key' }, // Default query parameters that will be sent with each request.
10312
- // auth: { username: 'user', password: 'pass' }, // Basic authentication credentials.
10313
- // responseEncoding: 'utf8', // Indicates the encoding to use for the response.
10314
- // responseType: 'json', // Specifies the type of data the server will respond with.
10315
- // xsrfCookieName: 'XSRF-TOKEN', // The name of the cookie to use as a value for the xsrf token.
10316
- // xsrfHeaderName: 'X-XSRF-TOKEN', // The name of the HTTP header that carries the xsrf token value.
10317
- // maxContentLength: 2000, // The maximum size of the HTTP response content in bytes allowed.
10318
- // maxBodyLength: 2000, // The maximum size of the request body in bytes allowed.
10319
- // // Allows changes to the request data before it is sent to the server.
10320
- // transformRequest: [
10321
- // (data, headers) => {
10322
- // console.log(headers)
10323
- // console.log(data)
10324
- // // Modify data and headers here
10325
- // return data
10326
- // },
10327
- // ],
10328
- // // Allows changes to the response data before it is passed to then or catch.
10329
- // transformResponse: [
10330
- // (data) => {
10331
- // // Modify data here
10332
- // return data
10333
- // },
10334
- // ],
10335
- // // Custom function to validate the response status code.
10336
- // validateStatus: (status) => {
10337
- // return status >= 200 && status < 300 // default
10338
- // },
10339
- // withCredentials: true, // Indicates whether or not cross-site Access-Control requests should be made using credentials.
10340
- // // Defines the proxy server settings.
10341
- // proxy: {
10342
- // host: '127.0.0.1',
10343
- // port: 9000,
10344
- // auth: {
10345
- // username: 'proxyuser',
10346
- // password: 'proxypass',
10347
- // },
10348
- // },
10349
- });
10350
- axiosInstance.interceptors.request.use(
10351
- (config2) => {
10352
- const token = localStorage.getItem("token");
10353
- if (token) {
10354
- config2.headers.Authorization = `Bearer ${token}`;
10355
- }
10356
- return config2;
10357
- },
10358
- (error) => {
10359
- console.error("Error request:", error.response);
10360
- return Promise.reject(error);
10361
- }
10362
- );
10363
- axiosInstance.interceptors.response.use(
10364
- (response) => {
10365
- return response;
10366
- },
10367
- (error) => {
10368
- const errorResponse = {
10369
- status: null,
10370
- message: "An error occurred"
10371
- };
10372
- if (error.response) {
10373
- errorResponse.status = error.response.status;
10374
- errorResponse.message = error.response.data.message || error.response.statusText;
10375
- console.error("Error response:", JSON.stringify(errorResponse));
10376
- if (error.response.status === 401) {
10377
- console.error("Unauthorized access - redirecting to login.");
10378
- } else if (error.response.status === 404) {
10379
- console.error("Resource not found.");
10380
- } else if (error.response.status >= 500) {
10381
- console.error("Server error. Please try again later.");
10382
- }
10383
- } else if (error.request) {
10384
- console.error("No response received:", error.request);
10385
- } else {
10386
- console.error("Error setting up request:", error.message);
10387
- }
10300
+ const get = (endpoint) => __async(void 0, null, function* () {
10301
+ const response = yield fetchWithTimeout(`${endpoint}`, {
10302
+ method: "GET",
10303
+ headers: authHeaders(),
10304
+ credentials: "include"
10305
+ });
10306
+ if (!response.ok) {
10307
+ const errorResponse = yield getErrorMessage(response);
10388
10308
  return Promise.reject(errorResponse);
10389
10309
  }
10390
- );
10391
- const post = (requests) => __async(void 0, null, function* () {
10310
+ const data = yield safeJson(response);
10311
+ return {
10312
+ data,
10313
+ status: response.status,
10314
+ msg: response.statusText,
10315
+ headers: response.headers,
10316
+ ok: response.ok
10317
+ };
10318
+ });
10319
+ const post = (requests, requestPath = `/graph/jwt`) => __async(void 0, null, function* () {
10392
10320
  const modifiedRequests = processRequestModifications(requests);
10393
10321
  const requestData = modifiedRequests.map((item) => ({
10394
10322
  name: item.name,
10395
10323
  query: btoa(item.query)
10396
10324
  }));
10397
10325
  const payload = { requests: requestData };
10398
- const response = yield axiosInstance.post(
10399
- `/graph/jwt`,
10400
- stringToBytes(JSON.stringify(payload))
10401
- );
10326
+ const response = yield fetchWithTimeout(requestPath, {
10327
+ method: "POST",
10328
+ headers: authHeaders(),
10329
+ body: JSON.stringify(payload),
10330
+ credentials: "include"
10331
+ });
10332
+ if (!response.ok) {
10333
+ const errorResponse = yield getErrorMessage(response);
10334
+ return Promise.reject(errorResponse);
10335
+ }
10336
+ const responseJSON = yield safeJson(response);
10402
10337
  const result = {
10403
10338
  status: 200,
10404
10339
  message: "",
10405
10340
  result: {}
10406
10341
  };
10407
- for (const res of response.data.responses) {
10342
+ for (const res of responseJSON.responses) {
10408
10343
  if (res.error != null && res.error.code != 200) {
10409
10344
  result.status = res.error.code;
10410
10345
  result.message = res.error.message;
@@ -10424,8 +10359,92 @@ const post = (requests) => __async(void 0, null, function* () {
10424
10359
  result.result = processResponseModifications(result.result);
10425
10360
  return result;
10426
10361
  });
10362
+ const customPost = (requestPath, request) => __async(void 0, null, function* () {
10363
+ const response = yield fetchWithTimeout(requestPath, {
10364
+ method: "POST",
10365
+ headers: authHeaders(),
10366
+ body: JSON.stringify(request),
10367
+ credentials: "include"
10368
+ });
10369
+ if (!response.ok) {
10370
+ const errorResponse = yield getErrorMessage(response);
10371
+ return Promise.reject(errorResponse);
10372
+ }
10373
+ const data = yield safeJson(response);
10374
+ if (!data) {
10375
+ return {
10376
+ data: {},
10377
+ status: response.status,
10378
+ msg: response.statusText,
10379
+ headers: response.headers,
10380
+ ok: response.ok
10381
+ };
10382
+ }
10383
+ const responses = Array.isArray(data == null ? void 0 : data.responses) ? data.responses.filter((res) => res == null ? void 0 : res.attributes) : [];
10384
+ const firstResponse = responses[0];
10385
+ const finalData = firstResponse ? JSON.parse(base64Decode(firstResponse.attributes)) : data;
10386
+ return {
10387
+ data: finalData,
10388
+ status: response.status,
10389
+ msg: response.statusText,
10390
+ headers: response.headers,
10391
+ ok: response.ok
10392
+ };
10393
+ });
10394
+ const fetchWithTimeout = (url, options, timeout = 29e3) => __async(void 0, null, function* () {
10395
+ const controller = new AbortController();
10396
+ const id = setTimeout(() => controller.abort(), timeout);
10397
+ try {
10398
+ const response = yield fetch(url, __spreadProps(__spreadValues({}, options), {
10399
+ signal: controller.signal
10400
+ }));
10401
+ return response;
10402
+ } finally {
10403
+ clearTimeout(id);
10404
+ }
10405
+ });
10406
+ const authHeaders = () => {
10407
+ const token = localStorage.getItem("token");
10408
+ const csrfToken = getCookie("XSRF-TOKEN");
10409
+ return __spreadValues({
10410
+ "Content-Type": "application/json",
10411
+ "X-XSRF-TOKEN": csrfToken
10412
+ }, token ? { Authorization: `Bearer ${token}` } : {});
10413
+ };
10414
+ const getCookie = (name) => {
10415
+ const match2 = document.cookie.match(new RegExp("(^| )" + name + "=([^;]+)"));
10416
+ return match2 ? decodeURIComponent(match2[2]) : "";
10417
+ };
10418
+ const safeJson = (response) => __async(void 0, null, function* () {
10419
+ try {
10420
+ if (response.status === 204 || response.headers.get("content-length") === "0") {
10421
+ return null;
10422
+ }
10423
+ return yield response.json();
10424
+ } catch (e) {
10425
+ return null;
10426
+ }
10427
+ });
10428
+ const getErrorMessage = (response) => __async(void 0, null, function* () {
10429
+ const errorBody = yield safeJson(response);
10430
+ const errorResponse = {
10431
+ status: response.status,
10432
+ message: (errorBody == null ? void 0 : errorBody.message) || response.statusText || "An error occurred"
10433
+ };
10434
+ console.error("Error response:", JSON.stringify(errorResponse));
10435
+ if (response.status === 401) {
10436
+ console.error("Unauthorized access - redirecting to login.");
10437
+ } else if (response.status === 404) {
10438
+ console.error("Resource not found.");
10439
+ } else if (response.status >= 500) {
10440
+ console.error("Server error. Please try again later.");
10441
+ }
10442
+ return errorResponse;
10443
+ });
10427
10444
  const api = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10428
10445
  __proto__: null,
10446
+ customPost,
10447
+ get,
10429
10448
  post
10430
10449
  }, Symbol.toStringTag, { value: "Module" }));
10431
10450
  var ImageCategory = /* @__PURE__ */ ((ImageCategory2) => {
@@ -10454,7 +10473,7 @@ const autoRegisterApi = () => __async(void 0, null, function* () {
10454
10473
  message: ""
10455
10474
  }, DefaultAutoRegisterData);
10456
10475
  try {
10457
- const request = yield axiosInstance.get("/graph/autoregister");
10476
+ const request = yield get("/graph/autoregister");
10458
10477
  const output = request.data;
10459
10478
  result.data = {
10460
10479
  status: output.status == 1,
@@ -10492,7 +10511,7 @@ const getMaintenanceModeApi = () => __async(void 0, null, function* () {
10492
10511
  message: ""
10493
10512
  }, DefaultGetMaintenanceModeData);
10494
10513
  try {
10495
- const request = yield axiosInstance.get("/graph/getMaintenanceMode");
10514
+ const request = yield get("/graph/getMaintenanceMode");
10496
10515
  const output = request.data;
10497
10516
  result.data = {
10498
10517
  status: output.status == 1,
@@ -10526,7 +10545,7 @@ const jackpotDataApi = () => __async(void 0, null, function* () {
10526
10545
  message: ""
10527
10546
  }, DefaultjackpotData);
10528
10547
  try {
10529
- const request = yield axiosInstance.get("/api/jackpotData");
10548
+ const request = yield get("/api/jackpotData");
10530
10549
  const output = request.data;
10531
10550
  result.data = {
10532
10551
  startTimestamp: output.startTimestamp,
@@ -10554,7 +10573,7 @@ const loadMatchApi = (gameId, stage, sportId, tagId, matchId) => __async(void 0,
10554
10573
  }
10555
10574
  };
10556
10575
  try {
10557
- const request = yield axiosInstance.post(`/loadgame/${gameId}`, {
10576
+ const request = yield customPost(`/loadgame/${gameId}`, {
10558
10577
  wanturl: 1,
10559
10578
  extra: {
10560
10579
  Stage: stage,
@@ -10598,7 +10617,7 @@ const loginApi = (username, password, type = "") => __async(void 0, null, functi
10598
10617
  if (type !== "") {
10599
10618
  payload.type = type;
10600
10619
  }
10601
- yield axiosInstance.post("/graph/auth/sesh", payload);
10620
+ yield customPost("/graph/auth/sesh", payload);
10602
10621
  result = {
10603
10622
  status: 200,
10604
10623
  message: ""
@@ -10618,7 +10637,7 @@ const logoutApi = () => __async(void 0, null, function* () {
10618
10637
  message: ""
10619
10638
  };
10620
10639
  try {
10621
- yield axiosInstance.post("/graph/auth/sesh/logout");
10640
+ yield customPost("/graph/auth/sesh/logout");
10622
10641
  } catch (error) {
10623
10642
  const extendedError = error;
10624
10643
  result = {
@@ -10634,14 +10653,14 @@ const rename = (fullname) => __async(void 0, null, function* () {
10634
10653
  message: ""
10635
10654
  };
10636
10655
  try {
10637
- const request = yield axiosInstance.post("/graph/rename", {
10656
+ const request = yield customPost("/graph/rename", {
10638
10657
  fullname
10639
10658
  });
10640
10659
  if (false) ;
10641
10660
  const response = request.data;
10642
10661
  result = {
10643
10662
  status: response.status == 1 ? 200 : 509,
10644
- message: response.msg ? request.data.msg : ""
10663
+ message: response.msg ? response.msg : ""
10645
10664
  };
10646
10665
  } catch (error) {
10647
10666
  const extendedError = error;
@@ -10665,13 +10684,11 @@ const setLocaleApi = (localeCode, udid) => __async(void 0, null, function* () {
10665
10684
  message: ""
10666
10685
  }, DefaultSetLocaleData);
10667
10686
  try {
10668
- const request = yield axiosInstance.post("/graph/setlocale", {
10687
+ const request = yield customPost("/graph/setlocale", {
10669
10688
  language: localeCode,
10670
10689
  udid: udid != null ? udid : ""
10671
10690
  });
10672
- const output = JSON.parse(
10673
- atob(request.data.responses[0].attributes)
10674
- );
10691
+ const output = request.data;
10675
10692
  result.data = {
10676
10693
  status: output.status == 1,
10677
10694
  message: (_a = output.message) != null ? _a : ""
@@ -10691,7 +10708,7 @@ const telegramLoginApi = (data) => __async(void 0, null, function* () {
10691
10708
  message: ""
10692
10709
  };
10693
10710
  try {
10694
- yield axiosInstance.post("/loginVia/telegram", data);
10711
+ yield customPost("/loginVia/telegram", data);
10695
10712
  result = {
10696
10713
  status: 200,
10697
10714
  message: ""
@@ -10723,7 +10740,10 @@ const socialLoginApi = (loginToken, loginEmail, loginMethod) => __async(void 0,
10723
10740
  email: loginEmail,
10724
10741
  social_type: loginMethod
10725
10742
  };
10726
- const request = yield axiosInstance.post("/graph/socialLogin", payload);
10743
+ const request = yield customPost(
10744
+ "/graph/socialLogin",
10745
+ payload
10746
+ );
10727
10747
  const output = request.data;
10728
10748
  result.data = {
10729
10749
  status: output.status == 1,