@jetthai/cuora 1.1.394 → 1.1.395-payment-1

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 (62) hide show
  1. package/CHANGELOG.md +1 -89
  2. package/package.json +1 -1
  3. package/resetGitBranch.sh +10 -0
  4. package/src/api/activity.js +4 -6
  5. package/src/api/auth.js +2 -2
  6. package/src/api/common.js +1 -1
  7. package/src/api/game.js +13 -25
  8. package/src/api/payment.js +5 -9
  9. package/src/api/ranking.js +6 -6
  10. package/src/api/user.js +10 -15
  11. package/src/lib/{fingerprint_v3_11_12.js → fingerprint_v3_11_5.js} +4205 -3742
  12. package/src/machine/activity/continue_deposit_activity.js +1 -2
  13. package/src/machine/activity/fafafa_activity.js +1 -2
  14. package/src/machine/activity/return_bonus_activity.js +1 -2
  15. package/src/machine/activity/sign_in_activity.js +1 -2
  16. package/src/machine/activity/specify_bets_activity.js +1 -2
  17. package/src/machine/activity/specify_turnover_activity.js +1 -2
  18. package/src/machine/auth.js +6 -9
  19. package/src/machine/bank_binding.js +10 -68
  20. package/src/machine/common.js +8 -34
  21. package/src/machine/deposit/amb.js +1 -1
  22. package/src/machine/deposit/crypto_bank.js +2 -10
  23. package/src/machine/deposit/crypto_bank_cash.js +2 -10
  24. package/src/machine/deposit/crypto_way.js +2 -10
  25. package/src/machine/deposit/crypto_way_cash.js +2 -10
  26. package/src/machine/deposit/deposit_fc.js +3 -11
  27. package/src/machine/deposit/direct.js +4 -12
  28. package/src/machine/deposit/direct_cash.js +4 -12
  29. package/src/machine/deposit/float.js +4 -12
  30. package/src/machine/deposit/loadcard_cash.js +3 -11
  31. package/src/machine/deposit/loadcard_vn.js +3 -11
  32. package/src/machine/deposit/manual_cash.js +4 -12
  33. package/src/machine/deposit/manual_vn.js +3 -11
  34. package/src/machine/deposit/qrcode_cash.js +3 -11
  35. package/src/machine/deposit/qrcode_v2.js +3 -11
  36. package/src/machine/deposit/virtual_bank_cash.js +3 -11
  37. package/src/machine/deposit/virtual_bank_vn.js +3 -11
  38. package/src/machine/deposit/vpay.js +4 -12
  39. package/src/machine/game_replay.js +2 -2
  40. package/src/machine/game_search_cash.js +7 -10
  41. package/src/machine/game_search_v2.js +10 -10
  42. package/src/machine/game_v2_1.js +9 -22
  43. package/src/machine/honor_board_cash.js +1 -1
  44. package/src/machine/inbox.js +8 -22
  45. package/src/machine/index.js +0 -2
  46. package/src/machine/ranking.js +11 -14
  47. package/src/machine/reward.js +5 -58
  48. package/src/machine/reward_cash.js +3 -60
  49. package/src/machine/reward_fc.js +1 -2
  50. package/src/machine/side_cash.js +2 -3
  51. package/src/machine/side_v2.js +4 -5
  52. package/src/machine/user_reset_password.js +4 -5
  53. package/src/machine/user_sign_up.js +2 -6
  54. package/src/machine/vip_table.js +4 -11
  55. package/src/machine/withdraw/withdraw_crypto_cash.js +2 -10
  56. package/src/machine/withdraw/withdraw_manual.js +96 -11
  57. package/src/machine/withdraw/withdraw_manual_cash.js +1 -1
  58. package/src/request/request.js +7 -245
  59. package/src/util/deviceToken.js +2 -26
  60. package/src/util/index.js +2 -2
  61. package/src/util/storage.js +4 -18
  62. package/src/machine/game_betslip.js +0 -46
@@ -2,145 +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
- 'game/history/options',
143
- ]
144
5
 
145
6
  function isValid(value) {
146
7
  return value !== undefined && value !== null
@@ -155,41 +16,15 @@ export default class Request {
155
16
  this.key = `cuora_${config.clientId}`
156
17
  this.errorHandler = null
157
18
  this.hosts = []
158
- this.isBlocked = false
159
19
  this.initialize()
160
20
  }
161
21
 
162
22
  initialize() {
163
- // 自定義參數序列化器 - 避免使用 URLSearchParams
164
- this.axios.defaults.paramsSerializer = function (params) {
165
- return Object.keys(params)
166
- .map((key) => {
167
- let value = params[key]
168
- if (value === null || value === undefined) {
169
- return null
170
- }
171
- // 針對key為q的參數進行手動編碼,避免雙重編碼
172
- if (key === 'q' && typeof value === 'string') {
173
- // 處理其他需要編碼的字符
174
- value = encodeURIComponent(value).replace(/[!'()*]/g, function (c) {
175
- return '%' + c.charCodeAt(0).toString(16).toUpperCase()
176
- })
177
- } else {
178
- // 對其他參數使用標準編碼
179
- value = encodeURIComponent(value)
180
- }
181
- return `${encodeURIComponent(key)}=${value}`
182
- })
183
- .filter(Boolean)
184
- .join('&')
185
- }
186
-
187
23
  this.axios.interceptors.request.use((axiosConfig) => {
188
24
  axiosConfig.headers['X-TH1GAMES-VERSION'] = this.config.version
189
25
  axiosConfig.headers['X-TH1GAMES-PLATFORM'] = this.config.platform
190
26
  if (this.getToken()) {
191
- // 為了支援V2版本的API接口新增Bearer來進行身份驗證
192
- axiosConfig.headers.Authorization = `Bearer ${this.getToken()}`
27
+ axiosConfig.headers.Authorization = this.getToken()
193
28
  }
194
29
  return axiosConfig
195
30
  })
@@ -226,25 +61,10 @@ export default class Request {
226
61
  try {
227
62
  const cancelToken = customToken || this.source.token
228
63
  this._checkToken(req)
229
-
230
64
  const requestConfig = this._createConfig(req, cancelToken)
231
- // console.log('*請求資料Check', requestConfig)
232
- const configUrls = ['getConfig', 'get-config']
233
- if (this.isBlocked && !configUrls.includes(requestConfig.url)) {
234
- // 狀態是維護中&請求非siteConfig,終止所有的請求,除了維護頁需要的資料(siteConfig)
235
- // console.log('%c*禁止的請求目標', requestConfig)
236
- } else {
237
- // console.log('%c*允許的請求目標', requestConfig)
238
- const { data } = await this.axios.request(requestConfig)
239
- return data
240
- }
65
+ const { data } = await this.axios.request(requestConfig)
66
+ return data
241
67
  } catch (error) {
242
- if (error.code === 'ERR_F108') {
243
- console.log('%c*維護中', 'color: #00ff33ff; font-weight: bold;')
244
- this.isBlocked = true
245
- this.errorHandler && this.errorHandler(error)
246
- throw error
247
- }
248
68
  if (error.code !== 'ERR_800') {
249
69
  if (error.code) {
250
70
  this.errorHandler && this.errorHandler(error)
@@ -265,37 +85,11 @@ export default class Request {
265
85
 
266
86
  _createConfig(req, cancelToken) {
267
87
  const { method, url, params, isPublic, isFormData, headers } = req
268
- let fullURL = this.config.fullURL
269
- let urlName = url
270
- // 有些API會將參數(/?)直接帶在URL上,所以要將參數排除
271
- const cleanUrl = url.split('?')[0]
272
-
273
- const isV2Supported = supportVersion2List.some((supportedUrl) => {
274
- // 如果包含動態參數(:parameter),則使用模式匹配
275
- if (supportedUrl.includes(':')) {
276
- const pattern = supportedUrl.replace(/:[^/]+/g, '[^/]+')
277
- const regex = new RegExp(`^${pattern}$`)
278
- return regex.test(cleanUrl)
279
- }
280
- return supportedUrl === cleanUrl
281
- })
282
-
283
- // 目前全站都支援V2,若有需要限制為V1的站點可以填入,此段等轉換全部完成之後就可以移除了
284
- const supportV2Toggle = [''].includes(this.config?.clientId)
285
-
286
- if (isV2Supported && !supportV2Toggle) {
287
- fullURL = fullURL.replace('/v1/', '/v2/')
288
- urlName = this._convertUrlToKebabCase(url)
289
- // console.log(`*[DEV_ONLY]V2`, 'url:', urlName)
290
- } else {
291
- // console.log(`*[DEV_ONLY]V2-不支援:`, 'url:', urlName)
292
- }
293
-
294
88
  if (isFormData) {
295
89
  return {
296
- baseURL: fullURL,
90
+ baseURL: this.config.fullURL,
297
91
  method,
298
- url: urlName,
92
+ url,
299
93
  cancelToken,
300
94
  isPublic,
301
95
  headers: { 'Content-Type': 'multipart/form-data' },
@@ -303,9 +97,9 @@ export default class Request {
303
97
  }
304
98
  } else {
305
99
  return {
306
- baseURL: fullURL,
100
+ baseURL: this.config.fullURL,
307
101
  method,
308
- url: urlName,
102
+ url,
309
103
  cancelToken,
310
104
  isPublic,
311
105
  headers,
@@ -314,38 +108,6 @@ export default class Request {
314
108
  }
315
109
  }
316
110
 
317
- // 調整API路徑與名稱
318
- _convertUrlToKebabCase(url) {
319
- const specifyingPath = {
320
- 'all-activities/list': 'activities/all-activities-list',
321
- friends: 'activities/friends',
322
- 'friends/home': 'activities/friends/home',
323
- 'friends/reward-list': 'activities/friends/reward-list',
324
- 'friends/dashboard': 'activities/friends/dashboard',
325
- 'friends/dashboard/list': 'activities/friends/dashboard/list',
326
- 'activities/getFreeGameReward': 'activities/free-game/get-free-game-reward',
327
- 'activities/getFreeGameRewardList': 'activities/free-game/get-free-game-reward-list',
328
- 'activities/lose-rebate/history': 'activities/rebate/lose-rebate/history',
329
- 'activities/ranking': 'activities/ranking/promotion-ranking',
330
- 'activities/activity/ranking': 'activities/ranking/basic-ranking',
331
- 'activities/cashRain': 'activities/cash-rain/exchange',
332
- 'tournament/detail': 'activities/tournament/detail',
333
- 'ranking/detail': 'activities/tournament/ranking/detail',
334
- 'ranking/detail/option': 'activities/tournament/ranking/detail/option',
335
- 'hot-game/ranking': 'activities/tournament/ranking/hot-game',
336
- 'activities/rebate/estimate': 'activities/rebate/estimate',
337
- 'activities/exchange/diamond/max-amount': 'activities/diamond/exchange/max-amount',
338
- 'activities/exchange/diamond/settle': 'activities/diamond/exchange/settle',
339
- }
340
- if (specifyingPath[url]) {
341
- // 和原有路徑不同有另外改路徑
342
- return specifyingPath[url]
343
- } else {
344
- // 將API_URL的命名規則由駝峰調整為短橫線(-)
345
- return url.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()
346
- }
347
- }
348
-
349
111
  _checkToken(req) {
350
112
  if (!req.isPublic && !this.getToken()) {
351
113
  throw { code: 'ERR_A103', url: req.url }
@@ -1,5 +1,5 @@
1
1
  import uniqBy from 'lodash/uniqBy'
2
- import { load, defaultEndpoint } from '../lib/fingerprint_v3_11_12.js'
2
+ import { load, defaultEndpoint } from '../lib/fingerprint_v3_11_5.js'
3
3
 
4
4
  const reg = /fnapi\d*/
5
5
 
@@ -32,28 +32,4 @@ const getDeviceToken = async ({ fpToken, sentry, hosts, enable = true }) => {
32
32
  }
33
33
  }
34
34
 
35
- // 重試機制,最多嘗試 maxRetries 次,每次間隔 intervalMs 毫秒
36
- const getDeviceTokenWithRetry = async ({ fpToken, sentry, hosts, enable = true, maxRetries = 3, intervalMs = 1000 }) => {
37
- if (!enable) {
38
- return
39
- }
40
- // 設置幾秒後重試
41
- const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
42
- // 設定重試次數
43
- for (let attempt = 1; attempt <= maxRetries; attempt++) {
44
- try {
45
- const deviceToken = await getDeviceToken({ fpToken, sentry, hosts, enable })
46
- if (deviceToken) return deviceToken
47
- throw new Error('No device token received')
48
- } catch (error) {
49
- // 若失敗則等待intervalMs後重試,最多重試maxRetries次
50
- if (attempt < maxRetries) {
51
- await delay(intervalMs)
52
- } else {
53
- throw error
54
- }
55
- }
56
- }
57
- }
58
-
59
- export { getDeviceToken, getDeviceTokenWithRetry }
35
+ export { getDeviceToken }
package/src/util/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { getDeviceToken, getDeviceTokenWithRetry } from './deviceToken.js'
1
+ import { getDeviceToken } from './deviceToken.js'
2
2
  import storage from './storage.js'
3
3
  import * as constant from './constant.js'
4
4
  import { max } from './math.js'
5
5
 
6
- export default { getDeviceToken, getDeviceTokenWithRetry }
6
+ export default { getDeviceToken }
7
7
  export { constant, storage, max }
@@ -1,12 +1,6 @@
1
1
  export default {
2
2
  get(name, options) {
3
- let itemStr = null
4
- try {
5
- itemStr = localStorage.getItem(name)
6
- } catch (error) {
7
- console.error(`Error getting item from localStorage: ${error}`)
8
- return null
9
- }
3
+ const itemStr = localStorage.getItem(name)
10
4
 
11
5
  if (!itemStr) {
12
6
  return null
@@ -18,7 +12,7 @@ export default {
18
12
  return null
19
13
  }
20
14
 
21
- return 'value' in item ? item.value : item
15
+ return item.value
22
16
  },
23
17
  set(name, value, options) {
24
18
  const item = { value }
@@ -26,17 +20,9 @@ export default {
26
20
  if (options?.maxAge) {
27
21
  item.expiry = new Date().getTime() + options.maxAge * 1000
28
22
  }
29
- try {
30
- localStorage.setItem(name, JSON.stringify(item))
31
- } catch (error) {
32
- console.error(`Error setting item in localStorage: ${error}`)
33
- }
23
+ localStorage.setItem(name, JSON.stringify(item))
34
24
  },
35
25
  remove(name, options) {
36
- try {
37
- localStorage.removeItem(name)
38
- } catch (error) {
39
- console.error(`Error removing item from localStorage: ${error}`)
40
- }
26
+ localStorage.removeItem(name)
41
27
  },
42
28
  }
@@ -1,46 +0,0 @@
1
- import { assign, createMachine } from 'xstate'
2
- import game from '../api/game.js'
3
-
4
- export default function (request, context) {
5
- const { appSecret } = request.config
6
- const { providerId, seqNo, lang } = context
7
- return createMachine(
8
- {
9
- id: 'game_betslip',
10
- initial: 'fetching',
11
- context: {
12
- gameBetSlip: {},
13
- },
14
- states: {
15
- fetching: {
16
- invoke: {
17
- src: 'fetchBetslip',
18
- onDone: {
19
- target: 'idle',
20
- actions: 'setBetslip',
21
- },
22
- onError: {
23
- target: 'idle',
24
- },
25
- },
26
- },
27
- idle: {},
28
- },
29
- },
30
- {
31
- actions: {
32
- setBetslip: assign((context, event) => {
33
- return {
34
- gameBetSlip: event.data,
35
- }
36
- }),
37
- },
38
- services: {
39
- // 取得遊戲注單
40
- fetchBetslip: async (context, event) => {
41
- return await request.send(game.getBetslip({ providerId, seqNo, lang, appSecret }))
42
- },
43
- },
44
- }
45
- )
46
- }