@jetthai/cuora 1.1.375 → 1.1.376

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/package.json +1 -1
  3. package/src/api/activity.js +3 -2
  4. package/src/api/auth.js +2 -2
  5. package/src/api/common.js +1 -1
  6. package/src/api/game.js +10 -10
  7. package/src/api/payment.js +5 -5
  8. package/src/api/ranking.js +6 -6
  9. package/src/api/user.js +14 -9
  10. package/src/machine/common.js +2 -3
  11. package/src/machine/deposit/amb.js +1 -1
  12. package/src/machine/deposit/crypto_bank.js +10 -2
  13. package/src/machine/deposit/crypto_bank_cash.js +10 -2
  14. package/src/machine/deposit/crypto_way.js +10 -2
  15. package/src/machine/deposit/crypto_way_cash.js +10 -2
  16. package/src/machine/deposit/deposit_fc.js +11 -3
  17. package/src/machine/deposit/direct.js +12 -4
  18. package/src/machine/deposit/direct_cash.js +12 -4
  19. package/src/machine/deposit/float.js +12 -4
  20. package/src/machine/deposit/loadcard_cash.js +11 -3
  21. package/src/machine/deposit/loadcard_vn.js +11 -3
  22. package/src/machine/deposit/manual_cash.js +12 -4
  23. package/src/machine/deposit/manual_vn.js +11 -3
  24. package/src/machine/deposit/qrcode_cash.js +11 -3
  25. package/src/machine/deposit/qrcode_v2.js +11 -3
  26. package/src/machine/deposit/virtual_bank_cash.js +11 -3
  27. package/src/machine/deposit/virtual_bank_vn.js +11 -3
  28. package/src/machine/deposit/vpay.js +12 -4
  29. package/src/machine/game_search_cash.js +4 -4
  30. package/src/machine/game_search_v2.js +9 -9
  31. package/src/machine/game_v2_1.js +8 -3
  32. package/src/machine/honor_board_cash.js +1 -1
  33. package/src/machine/ranking.js +4 -3
  34. package/src/machine/side_cash.js +3 -2
  35. package/src/machine/side_v2.js +3 -2
  36. package/src/machine/user_reset_password.js +5 -4
  37. package/src/machine/vip_table.js +11 -4
  38. package/src/machine/withdraw/withdraw_crypto_cash.js +10 -2
  39. package/src/machine/withdraw/withdraw_manual.js +10 -2
  40. package/src/request/request.js +198 -5
@@ -2,6 +2,139 @@ import pickBy from 'lodash/pickBy.js'
2
2
  import storage from '../util/storage.js'
3
3
 
4
4
  // const pickBy = require('lodash/pickBy')
5
+ const supportVersion2List = [
6
+ // 04-09 Update
7
+ 'game/play',
8
+ 'game/gameReplay',
9
+ 'game/logout',
10
+ 'game/list/v3/root',
11
+ 'game/list/v3/category',
12
+ 'game/list/v3/addition',
13
+ 'game/list/v3/categoryByRange',
14
+ 'game/list/v3/additionByRange',
15
+ 'game/list/v3/myFavorite',
16
+ 'game/list/v3/addMyFavorite',
17
+ 'game/list/v3/removeMyFavorite',
18
+ 'login',
19
+ 'callback/:strategy',
20
+ 'guestLogin',
21
+ 'appLogin',
22
+ 'logout',
23
+ 'self',
24
+ 'register',
25
+ 'settings/password',
26
+ 'verify',
27
+ 'reset',
28
+ 'acknowledge',
29
+ 'recovery',
30
+ 'recovery/abandon',
31
+ 'recovery/acknowledge',
32
+ 'checkDt',
33
+ 'updateDt',
34
+ 'checkAC',
35
+ 'checkAccount',
36
+ 'getAllAvatar',
37
+ 'updateUserAvatar',
38
+ 'getConfig',
39
+ 'getQuickLayout',
40
+ 'getNavbarSetting',
41
+ 'getAffiliateCode',
42
+ 'get-site-config',
43
+ 'mailbox/sendMessage',
44
+ 'mailbox/getMessageList',
45
+ 'mailbox/getMessage',
46
+ 'mailbox/updateMessage',
47
+ 'mailbox/getMessageTypes',
48
+ // 05-23 Update
49
+ 'game/info',
50
+ 'recovery/v2/initiate',
51
+ 'recovery/v2/acknowledge',
52
+ 'recovery/v2/abandon',
53
+ 'recovery/v2/reset',
54
+ 'recovery/v2/changePassword',
55
+ 'account-binding/status',
56
+ 'account-binding/bind',
57
+ 'account-binding/acknowledge',
58
+ 'account-binding/bind-third-party',
59
+ 'feeds',
60
+ 'broadcast',
61
+ 'upload',
62
+ 'game/search',
63
+ 'game/search/home',
64
+ 'game/search/list',
65
+ 'game/search/trace',
66
+ 'game/history',
67
+ 'game/history/detail',
68
+ 'payment/v2/bankWallet/promotion/apply',
69
+ 'payment/v2/bankWallet/promotion/giveUp',
70
+ 'payment/v2/bankWallet/promotion/preview',
71
+ 'payment/v2/bankWallet/promotions',
72
+ 'payment/v2/bankWallet/restore',
73
+ 'payment/v2/callback',
74
+ 'payment/v2/convertFreeCredit',
75
+ 'payment/v2/getBindingBankList',
76
+ 'payment/v2/getBindingPaymentList',
77
+ 'payment/v2/getWithdrawBankList',
78
+ 'payment/v2/getCurrentWithdrawRule',
79
+ 'payment/v2/withdrawCheck',
80
+ 'payment/v2/history',
81
+ 'payment/v2/mergeWallet',
82
+ 'payment/v2/paymentDetail',
83
+ 'payment/v2/category/options',
84
+ 'payment/v2/paymentInfo',
85
+ 'payment/v2/getBindingPaymentInfo',
86
+ 'payment/v2/pendingOrder',
87
+ 'payment/v2/promotions',
88
+ 'payment/v2/spotmarket',
89
+ 'payment/v2/transactionHistory',
90
+ 'payment/v2/updateUtr',
91
+ 'payment/v2/setting',
92
+ 'payment/v2/amb/setting',
93
+ 'payment/v2/updatePaymentInfo',
94
+ 'payment/v2/uploadSlip',
95
+ 'payment/v2/withdrawRule',
96
+ 'payment/v2/:paymentType/getBankList',
97
+ 'payment/v2/:paymentType/transaction',
98
+ 'payment/v2/:paymentType/checkTransaction',
99
+ 'payment/v2/:paymentType/bonus/preview',
100
+ 'payment/v2/:paymentType/expected/result',
101
+ 'payment/v2/:paymentType/crypto/expected/result',
102
+ // 05-28 Update
103
+ 'all-activities/list',
104
+ 'activities/list',
105
+ 'activities/rewards',
106
+ 'activities/rewardAmount',
107
+ 'activities/sentAward',
108
+ 'activities/exchange',
109
+ 'activities/collect',
110
+ 'activities',
111
+ 'activities/types',
112
+ 'activities/promo',
113
+ 'activities/viptable',
114
+ 'activities/numbers',
115
+ 'activities/honorBroadcast',
116
+ 'activities/exchange/diamond/max-amount',
117
+ 'activities/exchange/diamond/settle',
118
+ 'tournament/detail',
119
+ 'ranking/detail',
120
+ 'ranking/detail/option',
121
+ 'hot-game/ranking',
122
+ 'activities/getFreeGameReward',
123
+ 'activities/getFreeGameRewardList',
124
+ 'activities/rebate/estimate',
125
+ 'activities/rebate/collect',
126
+ 'activities/rebate/history',
127
+ 'activities/lose-rebate/history',
128
+ 'friends',
129
+ 'friends/home',
130
+ 'friends/reward-list',
131
+ 'friends/dashboard',
132
+ 'friends/dashboard/list',
133
+ 'activities/ranking',
134
+ 'activities/activity/ranking',
135
+ 'activities/cashRain',
136
+ 'activities/jackpot/list',
137
+ ]
5
138
 
6
139
  function isValid(value) {
7
140
  return value !== undefined && value !== null
@@ -25,7 +158,8 @@ export default class Request {
25
158
  axiosConfig.headers['X-TH1GAMES-VERSION'] = this.config.version
26
159
  axiosConfig.headers['X-TH1GAMES-PLATFORM'] = this.config.platform
27
160
  if (this.getToken()) {
28
- axiosConfig.headers.Authorization = this.getToken()
161
+ // 為了支援V2版本的API接口新增Bearer來進行身份驗證
162
+ axiosConfig.headers.Authorization = `Bearer ${this.getToken()}`
29
163
  }
30
164
  return axiosConfig
31
165
  })
@@ -101,11 +235,38 @@ export default class Request {
101
235
 
102
236
  _createConfig(req, cancelToken) {
103
237
  const { method, url, params, isPublic, isFormData, headers } = req
238
+ let fullURL = this.config.fullURL
239
+ let urlName = url
240
+ // 有些API會將參數(/?)直接帶在URL上,所以要將參數排除
241
+ const cleanUrl = url.split('?')[0]
242
+
243
+ const isV2Supported = supportVersion2List.some((supportedUrl) => {
244
+ // 如果包含動態參數(:parameter),則使用模式匹配
245
+ if (supportedUrl.includes(':')) {
246
+ const pattern = supportedUrl.replace(/:[^/]+/g, '[^/]+')
247
+ const regex = new RegExp(`^${pattern}$`)
248
+ return regex.test(cleanUrl)
249
+ }
250
+ return supportedUrl === cleanUrl
251
+ })
252
+
253
+ // 如果站點是ZAZA,則不支援V2版本的API
254
+ // clientId 可參照各站環境設定檔案
255
+ const supportV2Toggle = ['ZAZA'].includes(this.config?.clientId)
256
+
257
+ if (isV2Supported && !supportV2Toggle) {
258
+ fullURL = fullURL.replace('/v1/', '/v2/')
259
+ urlName = this._convertUrlToKebabCase(url)
260
+ // console.log(`*[DEV_ONLY]V2`, 'url:', urlName)
261
+ } else {
262
+ // console.log(`*[DEV_ONLY]V2-不支援:`, 'url:', urlName)
263
+ }
264
+
104
265
  if (isFormData) {
105
266
  return {
106
- baseURL: this.config.fullURL,
267
+ baseURL: fullURL,
107
268
  method,
108
- url,
269
+ url: urlName,
109
270
  cancelToken,
110
271
  isPublic,
111
272
  headers: { 'Content-Type': 'multipart/form-data' },
@@ -113,9 +274,9 @@ export default class Request {
113
274
  }
114
275
  } else {
115
276
  return {
116
- baseURL: this.config.fullURL,
277
+ baseURL: fullURL,
117
278
  method,
118
- url,
279
+ url: urlName,
119
280
  cancelToken,
120
281
  isPublic,
121
282
  headers,
@@ -124,6 +285,38 @@ export default class Request {
124
285
  }
125
286
  }
126
287
 
288
+ // 調整API路徑與名稱
289
+ _convertUrlToKebabCase(url) {
290
+ const specifyingPath = {
291
+ 'all-activities/list': 'activities/all-activities-list',
292
+ friends: 'activities/friends',
293
+ 'friends/home': 'activities/friends/home',
294
+ 'friends/reward-list': 'activities/friends/reward-list',
295
+ 'friends/dashboard': 'activities/friends/dashboard',
296
+ 'friends/dashboard/list': 'activities/friends/dashboard/list',
297
+ 'activities/getFreeGameReward': 'activities/free-game/get-free-game-reward',
298
+ 'activities/getFreeGameRewardList': 'activities/free-game/get-free-game-reward-list',
299
+ 'activities/lose-rebate/history': 'activities/rebate/lose-rebate/history',
300
+ 'activities/ranking': 'activities/ranking/promotion-ranking',
301
+ 'activities/activity/ranking': 'activities/ranking/basic-ranking',
302
+ 'activities/cashRain': 'activities/cash-rain/exchange',
303
+ 'tournament/detail': 'activities/tournament/detail',
304
+ 'ranking/detail': 'activities/tournament/ranking/detail',
305
+ 'ranking/detail/option': 'activities/tournament/ranking/detail/option',
306
+ 'hot-game/ranking': 'activities/tournament/ranking/hot-game',
307
+ 'activities/rebate/estimate': 'activities/rebate/estimate',
308
+ 'activities/exchange/diamond/max-amount': 'activities/diamond/exchange/max-amount',
309
+ 'activities/exchange/diamond/settle': 'activities/diamond/exchange/settle',
310
+ }
311
+ if (specifyingPath[url]) {
312
+ // 和原有路徑不同有另外改路徑
313
+ return specifyingPath[url]
314
+ } else {
315
+ // 將API_URL的命名規則由駝峰調整為短橫線(-)
316
+ return url.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()
317
+ }
318
+ }
319
+
127
320
  _checkToken(req) {
128
321
  if (!req.isPublic && !this.getToken()) {
129
322
  throw { code: 'ERR_A103', url: req.url }