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