60p82u21t54k 1.1.4 → 1.1.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.
@@ -38,6 +38,83 @@ 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
+ };
41
118
  let currentConfig = {
42
119
  prefix: "188",
43
120
  timezone: -4,
@@ -3960,6 +4037,9 @@ function fromZonedTime(date, timeZone, options) {
3960
4037
  const offsetMilliseconds = tzParseTimezone(timeZone, new Date(utc));
3961
4038
  return new Date(utc + offsetMilliseconds);
3962
4039
  }
4040
+ const stringToBytes = (str) => {
4041
+ return new TextEncoder().encode(str);
4042
+ };
3963
4043
  const base64Decode = (encodedData) => {
3964
4044
  try {
3965
4045
  return atob(encodedData);
@@ -4230,82 +4310,6 @@ const getImgPath = (initPath, gameId, versioning) => {
4230
4310
  }
4231
4311
  return path;
4232
4312
  };
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
- };
4309
4313
  const getGameListResponse = (raw) => {
4310
4314
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
4311
4315
  return {
@@ -10297,49 +10301,110 @@ const registerAllApiModels = () => {
10297
10301
  }
10298
10302
  };
10299
10303
  registerAllApiModels();
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);
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
+ }
10308
10388
  return Promise.reject(errorResponse);
10309
10389
  }
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* () {
10390
+ );
10391
+ const post = (requests) => __async(void 0, null, function* () {
10320
10392
  const modifiedRequests = processRequestModifications(requests);
10321
10393
  const requestData = modifiedRequests.map((item) => ({
10322
10394
  name: item.name,
10323
10395
  query: btoa(item.query)
10324
10396
  }));
10325
10397
  const payload = { requests: requestData };
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);
10398
+ const response = yield axiosInstance.post(
10399
+ `/graph/jwt`,
10400
+ stringToBytes(JSON.stringify(payload))
10401
+ );
10337
10402
  const result = {
10338
10403
  status: 200,
10339
10404
  message: "",
10340
10405
  result: {}
10341
10406
  };
10342
- for (const res of responseJSON.responses) {
10407
+ for (const res of response.data.responses) {
10343
10408
  if (res.error != null && res.error.code != 200) {
10344
10409
  result.status = res.error.code;
10345
10410
  result.message = res.error.message;
@@ -10359,92 +10424,8 @@ const post = (requests, requestPath = `/graph/jwt`) => __async(void 0, null, fun
10359
10424
  result.result = processResponseModifications(result.result);
10360
10425
  return result;
10361
10426
  });
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
- });
10444
10427
  const api = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10445
10428
  __proto__: null,
10446
- customPost,
10447
- get,
10448
10429
  post
10449
10430
  }, Symbol.toStringTag, { value: "Module" }));
10450
10431
  var ImageCategory = /* @__PURE__ */ ((ImageCategory2) => {
@@ -10473,7 +10454,7 @@ const autoRegisterApi = () => __async(void 0, null, function* () {
10473
10454
  message: ""
10474
10455
  }, DefaultAutoRegisterData);
10475
10456
  try {
10476
- const request = yield get("/graph/autoregister");
10457
+ const request = yield axiosInstance.get("/graph/autoregister");
10477
10458
  const output = request.data;
10478
10459
  result.data = {
10479
10460
  status: output.status == 1,
@@ -10511,7 +10492,7 @@ const getMaintenanceModeApi = () => __async(void 0, null, function* () {
10511
10492
  message: ""
10512
10493
  }, DefaultGetMaintenanceModeData);
10513
10494
  try {
10514
- const request = yield get("/graph/getMaintenanceMode");
10495
+ const request = yield axiosInstance.get("/graph/getMaintenanceMode");
10515
10496
  const output = request.data;
10516
10497
  result.data = {
10517
10498
  status: output.status == 1,
@@ -10545,7 +10526,7 @@ const jackpotDataApi = () => __async(void 0, null, function* () {
10545
10526
  message: ""
10546
10527
  }, DefaultjackpotData);
10547
10528
  try {
10548
- const request = yield get("/api/jackpotData");
10529
+ const request = yield axiosInstance.get("/api/jackpotData");
10549
10530
  const output = request.data;
10550
10531
  result.data = {
10551
10532
  startTimestamp: output.startTimestamp,
@@ -10573,7 +10554,7 @@ const loadMatchApi = (gameId, stage, sportId, tagId, matchId) => __async(void 0,
10573
10554
  }
10574
10555
  };
10575
10556
  try {
10576
- const request = yield customPost(`/loadgame/${gameId}`, {
10557
+ const request = yield axiosInstance.post(`/loadgame/${gameId}`, {
10577
10558
  wanturl: 1,
10578
10559
  extra: {
10579
10560
  Stage: stage,
@@ -10617,7 +10598,7 @@ const loginApi = (username, password, type = "") => __async(void 0, null, functi
10617
10598
  if (type !== "") {
10618
10599
  payload.type = type;
10619
10600
  }
10620
- yield customPost("/graph/auth/sesh", payload);
10601
+ yield axiosInstance.post("/graph/auth/sesh", payload);
10621
10602
  result = {
10622
10603
  status: 200,
10623
10604
  message: ""
@@ -10637,7 +10618,7 @@ const logoutApi = () => __async(void 0, null, function* () {
10637
10618
  message: ""
10638
10619
  };
10639
10620
  try {
10640
- yield customPost("/graph/auth/sesh/logout");
10621
+ yield axiosInstance.post("/graph/auth/sesh/logout");
10641
10622
  } catch (error) {
10642
10623
  const extendedError = error;
10643
10624
  result = {
@@ -10653,14 +10634,14 @@ const rename = (fullname) => __async(void 0, null, function* () {
10653
10634
  message: ""
10654
10635
  };
10655
10636
  try {
10656
- const request = yield customPost("/graph/rename", {
10637
+ const request = yield axiosInstance.post("/graph/rename", {
10657
10638
  fullname
10658
10639
  });
10659
10640
  if (false) ;
10660
10641
  const response = request.data;
10661
10642
  result = {
10662
10643
  status: response.status == 1 ? 200 : 509,
10663
- message: response.msg ? response.msg : ""
10644
+ message: response.msg ? request.data.msg : ""
10664
10645
  };
10665
10646
  } catch (error) {
10666
10647
  const extendedError = error;
@@ -10684,11 +10665,13 @@ const setLocaleApi = (localeCode, udid) => __async(void 0, null, function* () {
10684
10665
  message: ""
10685
10666
  }, DefaultSetLocaleData);
10686
10667
  try {
10687
- const request = yield customPost("/graph/setlocale", {
10668
+ const request = yield axiosInstance.post("/graph/setlocale", {
10688
10669
  language: localeCode,
10689
10670
  udid: udid != null ? udid : ""
10690
10671
  });
10691
- const output = request.data;
10672
+ const output = JSON.parse(
10673
+ atob(request.data.responses[0].attributes)
10674
+ );
10692
10675
  result.data = {
10693
10676
  status: output.status == 1,
10694
10677
  message: (_a = output.message) != null ? _a : ""
@@ -10708,7 +10691,7 @@ const telegramLoginApi = (data) => __async(void 0, null, function* () {
10708
10691
  message: ""
10709
10692
  };
10710
10693
  try {
10711
- yield customPost("/loginVia/telegram", data);
10694
+ yield axiosInstance.post("/loginVia/telegram", data);
10712
10695
  result = {
10713
10696
  status: 200,
10714
10697
  message: ""
@@ -10740,7 +10723,7 @@ const socialLoginApi = (loginToken, loginEmail, loginMethod) => __async(void 0,
10740
10723
  email: loginEmail,
10741
10724
  social_type: loginMethod
10742
10725
  };
10743
- const request = yield customPost("/graph/socialLogin", payload);
10726
+ const request = yield axiosInstance.post("/graph/socialLogin", payload);
10744
10727
  const output = request.data;
10745
10728
  result.data = {
10746
10729
  status: output.status == 1,