@jetthai/cuora 1.1.374 → 1.1.375-qa-2
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/CHANGELOG.md +26 -0
- package/package.json +1 -1
- package/src/api/activity.js +3 -2
- package/src/api/auth.js +2 -2
- package/src/api/common.js +1 -1
- package/src/api/game.js +12 -12
- package/src/api/payment.js +5 -5
- package/src/api/ranking.js +6 -6
- package/src/api/user.js +14 -9
- package/src/machine/common.js +2 -3
- package/src/machine/deposit/amb.js +1 -1
- package/src/machine/deposit/crypto_bank.js +10 -2
- package/src/machine/deposit/crypto_bank_cash.js +10 -2
- package/src/machine/deposit/crypto_way.js +10 -2
- package/src/machine/deposit/crypto_way_cash.js +10 -2
- package/src/machine/deposit/deposit_fc.js +11 -3
- package/src/machine/deposit/direct.js +12 -4
- package/src/machine/deposit/direct_cash.js +12 -4
- package/src/machine/deposit/float.js +12 -4
- package/src/machine/deposit/loadcard_cash.js +11 -3
- package/src/machine/deposit/loadcard_vn.js +11 -3
- package/src/machine/deposit/manual_cash.js +12 -4
- package/src/machine/deposit/manual_vn.js +11 -3
- package/src/machine/deposit/qrcode_cash.js +11 -3
- package/src/machine/deposit/qrcode_v2.js +11 -3
- package/src/machine/deposit/virtual_bank_cash.js +11 -3
- package/src/machine/deposit/virtual_bank_vn.js +11 -3
- package/src/machine/deposit/vpay.js +12 -4
- package/src/machine/game_replay.js +2 -2
- package/src/machine/game_search_cash.js +4 -4
- package/src/machine/game_search_v2.js +9 -9
- package/src/machine/game_v2_1.js +9 -3
- package/src/machine/honor_board_cash.js +1 -1
- package/src/machine/ranking.js +4 -3
- package/src/machine/side_cash.js +3 -2
- package/src/machine/side_v2.js +3 -2
- package/src/machine/user_reset_password.js +5 -4
- package/src/machine/vip_table.js +11 -4
- package/src/machine/withdraw/withdraw_crypto_cash.js +10 -2
- package/src/machine/withdraw/withdraw_manual.js +10 -2
- package/src/request/request.js +219 -7
package/src/request/request.js
CHANGED
|
@@ -2,6 +2,143 @@ 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
|
+
// 09/09
|
|
138
|
+
'getAnnouncements',
|
|
139
|
+
'game/list/v3/gameInfo',
|
|
140
|
+
'payment/v2/uploadCommonSlip',
|
|
141
|
+
]
|
|
5
142
|
|
|
6
143
|
function isValid(value) {
|
|
7
144
|
return value !== undefined && value !== null
|
|
@@ -16,6 +153,7 @@ export default class Request {
|
|
|
16
153
|
this.key = `cuora_${config.clientId}`
|
|
17
154
|
this.errorHandler = null
|
|
18
155
|
this.hosts = []
|
|
156
|
+
this.isBlocked = false
|
|
19
157
|
this.initialize()
|
|
20
158
|
}
|
|
21
159
|
|
|
@@ -24,7 +162,8 @@ export default class Request {
|
|
|
24
162
|
axiosConfig.headers['X-TH1GAMES-VERSION'] = this.config.version
|
|
25
163
|
axiosConfig.headers['X-TH1GAMES-PLATFORM'] = this.config.platform
|
|
26
164
|
if (this.getToken()) {
|
|
27
|
-
|
|
165
|
+
// 為了支援V2版本的API接口新增Bearer來進行身份驗證
|
|
166
|
+
axiosConfig.headers.Authorization = `Bearer ${this.getToken()}`
|
|
28
167
|
}
|
|
29
168
|
return axiosConfig
|
|
30
169
|
})
|
|
@@ -61,10 +200,25 @@ export default class Request {
|
|
|
61
200
|
try {
|
|
62
201
|
const cancelToken = customToken || this.source.token
|
|
63
202
|
this._checkToken(req)
|
|
203
|
+
|
|
64
204
|
const requestConfig = this._createConfig(req, cancelToken)
|
|
65
|
-
|
|
66
|
-
|
|
205
|
+
// console.log('*請求資料Check', requestConfig)
|
|
206
|
+
const configUrls = ['getConfig', 'get-config']
|
|
207
|
+
if (this.isBlocked && !configUrls.includes(requestConfig.url)) {
|
|
208
|
+
// 狀態是維護中&請求非siteConfig,終止所有的請求,除了維護頁需要的資料(siteConfig)
|
|
209
|
+
// console.log('%c*禁止的請求目標', requestConfig)
|
|
210
|
+
} else {
|
|
211
|
+
// console.log('%c*允許的請求目標', requestConfig)
|
|
212
|
+
const { data } = await this.axios.request(requestConfig)
|
|
213
|
+
return data
|
|
214
|
+
}
|
|
67
215
|
} catch (error) {
|
|
216
|
+
if (error.code === 'ERR_F108') {
|
|
217
|
+
console.log('%c*維護中', 'color: #00ff33ff; font-weight: bold;')
|
|
218
|
+
this.isBlocked = true
|
|
219
|
+
this.errorHandler && this.errorHandler(error)
|
|
220
|
+
throw error
|
|
221
|
+
}
|
|
68
222
|
if (error.code !== 'ERR_800') {
|
|
69
223
|
if (error.code) {
|
|
70
224
|
this.errorHandler && this.errorHandler(error)
|
|
@@ -85,11 +239,37 @@ export default class Request {
|
|
|
85
239
|
|
|
86
240
|
_createConfig(req, cancelToken) {
|
|
87
241
|
const { method, url, params, isPublic, isFormData, headers } = req
|
|
242
|
+
let fullURL = this.config.fullURL
|
|
243
|
+
let urlName = url
|
|
244
|
+
// 有些API會將參數(/?)直接帶在URL上,所以要將參數排除
|
|
245
|
+
const cleanUrl = url.split('?')[0]
|
|
246
|
+
|
|
247
|
+
const isV2Supported = supportVersion2List.some((supportedUrl) => {
|
|
248
|
+
// 如果包含動態參數(:parameter),則使用模式匹配
|
|
249
|
+
if (supportedUrl.includes(':')) {
|
|
250
|
+
const pattern = supportedUrl.replace(/:[^/]+/g, '[^/]+')
|
|
251
|
+
const regex = new RegExp(`^${pattern}$`)
|
|
252
|
+
return regex.test(cleanUrl)
|
|
253
|
+
}
|
|
254
|
+
return supportedUrl === cleanUrl
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
// 目前全站都支援V2,若有需要限制為V1的站點可以填入,此段等轉換全部完成之後就可以移除了
|
|
258
|
+
const supportV2Toggle = [''].includes(this.config?.clientId)
|
|
259
|
+
|
|
260
|
+
if (isV2Supported && !supportV2Toggle) {
|
|
261
|
+
fullURL = fullURL.replace('/v1/', '/v2/')
|
|
262
|
+
urlName = this._convertUrlToKebabCase(url)
|
|
263
|
+
// console.log(`*[DEV_ONLY]V2`, 'url:', urlName)
|
|
264
|
+
} else {
|
|
265
|
+
// console.log(`*[DEV_ONLY]V2-不支援:`, 'url:', urlName)
|
|
266
|
+
}
|
|
267
|
+
|
|
88
268
|
if (isFormData) {
|
|
89
269
|
return {
|
|
90
|
-
baseURL:
|
|
270
|
+
baseURL: fullURL,
|
|
91
271
|
method,
|
|
92
|
-
url,
|
|
272
|
+
url: urlName,
|
|
93
273
|
cancelToken,
|
|
94
274
|
isPublic,
|
|
95
275
|
headers: { 'Content-Type': 'multipart/form-data' },
|
|
@@ -97,9 +277,9 @@ export default class Request {
|
|
|
97
277
|
}
|
|
98
278
|
} else {
|
|
99
279
|
return {
|
|
100
|
-
baseURL:
|
|
280
|
+
baseURL: fullURL,
|
|
101
281
|
method,
|
|
102
|
-
url,
|
|
282
|
+
url: urlName,
|
|
103
283
|
cancelToken,
|
|
104
284
|
isPublic,
|
|
105
285
|
headers,
|
|
@@ -108,6 +288,38 @@ export default class Request {
|
|
|
108
288
|
}
|
|
109
289
|
}
|
|
110
290
|
|
|
291
|
+
// 調整API路徑與名稱
|
|
292
|
+
_convertUrlToKebabCase(url) {
|
|
293
|
+
const specifyingPath = {
|
|
294
|
+
'all-activities/list': 'activities/all-activities-list',
|
|
295
|
+
friends: 'activities/friends',
|
|
296
|
+
'friends/home': 'activities/friends/home',
|
|
297
|
+
'friends/reward-list': 'activities/friends/reward-list',
|
|
298
|
+
'friends/dashboard': 'activities/friends/dashboard',
|
|
299
|
+
'friends/dashboard/list': 'activities/friends/dashboard/list',
|
|
300
|
+
'activities/getFreeGameReward': 'activities/free-game/get-free-game-reward',
|
|
301
|
+
'activities/getFreeGameRewardList': 'activities/free-game/get-free-game-reward-list',
|
|
302
|
+
'activities/lose-rebate/history': 'activities/rebate/lose-rebate/history',
|
|
303
|
+
'activities/ranking': 'activities/ranking/promotion-ranking',
|
|
304
|
+
'activities/activity/ranking': 'activities/ranking/basic-ranking',
|
|
305
|
+
'activities/cashRain': 'activities/cash-rain/exchange',
|
|
306
|
+
'tournament/detail': 'activities/tournament/detail',
|
|
307
|
+
'ranking/detail': 'activities/tournament/ranking/detail',
|
|
308
|
+
'ranking/detail/option': 'activities/tournament/ranking/detail/option',
|
|
309
|
+
'hot-game/ranking': 'activities/tournament/ranking/hot-game',
|
|
310
|
+
'activities/rebate/estimate': 'activities/rebate/estimate',
|
|
311
|
+
'activities/exchange/diamond/max-amount': 'activities/diamond/exchange/max-amount',
|
|
312
|
+
'activities/exchange/diamond/settle': 'activities/diamond/exchange/settle',
|
|
313
|
+
}
|
|
314
|
+
if (specifyingPath[url]) {
|
|
315
|
+
// 和原有路徑不同有另外改路徑
|
|
316
|
+
return specifyingPath[url]
|
|
317
|
+
} else {
|
|
318
|
+
// 將API_URL的命名規則由駝峰調整為短橫線(-)
|
|
319
|
+
return url.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
111
323
|
_checkToken(req) {
|
|
112
324
|
if (!req.isPublic && !this.getToken()) {
|
|
113
325
|
throw { code: 'ERR_A103', url: req.url }
|