@jetthai/cuora 1.1.394-dev-8 → 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 (68) hide show
  1. package/CHANGELOG.md +1 -125
  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 -6
  7. package/src/api/game.js +13 -25
  8. package/src/api/index.js +1 -3
  9. package/src/api/payment.js +5 -9
  10. package/src/api/ranking.js +6 -6
  11. package/src/api/user.js +10 -15
  12. package/src/lib/{fingerprint_v3_11_12.js → fingerprint_v3_11_5.js} +4205 -3742
  13. package/src/machine/activity/continue_deposit_activity.js +1 -2
  14. package/src/machine/activity/fafafa_activity.js +5 -39
  15. package/src/machine/activity/return_bonus_activity.js +1 -2
  16. package/src/machine/activity/roulette_activity_v2.js +0 -5
  17. package/src/machine/activity/sign_in_activity.js +1 -2
  18. package/src/machine/activity/specify_bets_activity.js +1 -2
  19. package/src/machine/activity/specify_turnover_activity.js +1 -2
  20. package/src/machine/auth.js +7 -13
  21. package/src/machine/auth_otp_v3.js +11 -42
  22. package/src/machine/bank_binding.js +10 -67
  23. package/src/machine/common.js +9 -47
  24. package/src/machine/deposit/amb.js +1 -1
  25. package/src/machine/deposit/crypto_bank.js +2 -10
  26. package/src/machine/deposit/crypto_bank_cash.js +2 -10
  27. package/src/machine/deposit/crypto_way.js +2 -10
  28. package/src/machine/deposit/crypto_way_cash.js +2 -10
  29. package/src/machine/deposit/deposit_fc.js +3 -11
  30. package/src/machine/deposit/direct.js +4 -12
  31. package/src/machine/deposit/direct_cash.js +4 -12
  32. package/src/machine/deposit/float.js +4 -12
  33. package/src/machine/deposit/loadcard_cash.js +3 -11
  34. package/src/machine/deposit/loadcard_vn.js +3 -11
  35. package/src/machine/deposit/manual_cash.js +4 -12
  36. package/src/machine/deposit/manual_vn.js +3 -11
  37. package/src/machine/deposit/qrcode_cash.js +3 -11
  38. package/src/machine/deposit/qrcode_v2.js +3 -11
  39. package/src/machine/deposit/virtual_bank_cash.js +3 -11
  40. package/src/machine/deposit/virtual_bank_vn.js +3 -11
  41. package/src/machine/deposit/vpay.js +4 -12
  42. package/src/machine/game_replay.js +2 -2
  43. package/src/machine/game_search_cash.js +7 -10
  44. package/src/machine/game_search_v2.js +10 -10
  45. package/src/machine/game_v2_1.js +13 -27
  46. package/src/machine/honor_board_cash.js +1 -1
  47. package/src/machine/inbox.js +8 -22
  48. package/src/machine/index.js +0 -2
  49. package/src/machine/ranking.js +11 -14
  50. package/src/machine/reward.js +5 -58
  51. package/src/machine/reward_cash.js +3 -60
  52. package/src/machine/reward_fc.js +1 -2
  53. package/src/machine/roulette_v2.js +0 -4
  54. package/src/machine/side_cash.js +2 -3
  55. package/src/machine/side_v2.js +4 -5
  56. package/src/machine/user_reset_password.js +4 -5
  57. package/src/machine/user_sign_up.js +2 -6
  58. package/src/machine/vip_table.js +4 -11
  59. package/src/machine/withdraw/withdraw_crypto_cash.js +2 -10
  60. package/src/machine/withdraw/withdraw_manual.js +96 -11
  61. package/src/machine/withdraw/withdraw_manual_cash.js +1 -1
  62. package/src/request/request.js +7 -258
  63. package/src/util/deviceToken.js +2 -26
  64. package/src/util/index.js +2 -2
  65. package/src/util/storage.js +4 -18
  66. package/src/api/account.js +0 -8
  67. package/src/api/otp.js +0 -5
  68. package/src/machine/game_betslip.js +0 -46
@@ -2,7 +2,6 @@ import { assign, createMachine } from 'xstate'
2
2
  import user from '../api/user.js'
3
3
 
4
4
  export default function (request) {
5
- const { appSecret } = request.config
6
5
  return createMachine(
7
6
  {
8
7
  id: 'user_reset_password',
@@ -208,20 +207,20 @@ export default function (request) {
208
207
  services: {
209
208
  sendOtp: async (context, event) => {
210
209
  const { provider, username, countryCode, phone, email } = context.otpParams
211
- return await request.send(user.passwordV2RecoveryInit({ provider, username, countryCode, phone, email, appSecret }))
210
+ return await request.send(user.passwordV2RecoveryInit({ provider, username, countryCode, phone, email }))
212
211
  },
213
212
  resetOtp: async (context, event) => {
214
213
  const { requestId, target } = context
215
- return await request.send(user.passwordV2ResetOtp({ requestId, target, appSecret }))
214
+ return await request.send(user.passwordV2ResetOtp({ requestId, target }))
216
215
  },
217
216
  acknowledge: async (context, event) => {
218
217
  const { requestId, target } = context
219
218
  const code = event.data
220
- return await request.send(user.passwordV2Acknowledge({ requestId, target, code, appSecret }))
219
+ return await request.send(user.passwordV2Acknowledge({ requestId, target, code }))
221
220
  },
222
221
  change: async (context, event) => {
223
222
  const { requestId, target, newPassword } = context
224
- return await request.send(user.passwordV2Change({ requestId, target, newPassword, appSecret }))
223
+ return await request.send(user.passwordV2Change({ requestId, target, newPassword }))
225
224
  },
226
225
  },
227
226
  }
@@ -1,6 +1,6 @@
1
1
  import { assign, createMachine } from 'xstate'
2
2
  import auth from '../api/auth.js'
3
- import { getDeviceTokenWithRetry } from '../util/deviceToken.js'
3
+ import { getDeviceToken } from '../util/deviceToken.js'
4
4
  import storage from '../util/storage.js'
5
5
 
6
6
  export default function (request) {
@@ -76,7 +76,6 @@ export default function (request) {
76
76
  }),
77
77
  setSignUpId: assign((context, event) => {
78
78
  const {
79
- email,
80
79
  username,
81
80
  nick_name,
82
81
  password,
@@ -94,7 +93,6 @@ export default function (request) {
94
93
  return {
95
94
  signUpData: {
96
95
  provider: 'local',
97
- email,
98
96
  username,
99
97
  nick_name,
100
98
  password,
@@ -113,7 +111,6 @@ export default function (request) {
113
111
  }),
114
112
  setSignUpPhone: assign((context, event) => {
115
113
  const {
116
- email,
117
114
  countryCode,
118
115
  phone,
119
116
  nick_name,
@@ -130,7 +127,6 @@ export default function (request) {
130
127
  return {
131
128
  signUpData: {
132
129
  provider: 'phone',
133
- email,
134
130
  countryCode,
135
131
  phone,
136
132
  nick_name,
@@ -204,7 +200,7 @@ export default function (request) {
204
200
  services: {
205
201
  authenticate: async (context, event) => {
206
202
  const { channel, subchannel, signUpData, deviceTokenEnable } = context
207
- const dt = await getDeviceTokenWithRetry({ fpToken, sentry, hosts: request.hosts, enable: deviceTokenEnable })
203
+ const dt = await getDeviceToken({ fpToken, sentry, hosts: request.hosts, enable: deviceTokenEnable })
208
204
 
209
205
  const affiliateCode = storage.get('ac') || signUpData?.affiliateCode
210
206
  const messages = {
@@ -1,7 +1,6 @@
1
1
  import { assign, createMachine } from 'xstate'
2
2
  import activity from '../api/activity.js'
3
3
  export default function (request) {
4
- const { appSecret } = request.config
5
4
  return createMachine(
6
5
  {
7
6
  id: 'vip_table',
@@ -36,20 +35,14 @@ export default function (request) {
36
35
  },
37
36
  services: {
38
37
  fetchVipTable: async (context, event) => {
39
- const result = await request.send(activity.getVipTable({ appSecret }))
40
- let dataList = []
41
- // V2接口轉換中回傳的資料結構不同
42
- if (!result?.viptable) {
43
- dataList = result.data
44
- } else {
45
- dataList = result.viptable?.data
46
- }
47
- dataList.map((item) => {
38
+ const { viptable = {} } = await request.send(activity.getVipTable())
39
+ const { data = [] } = viptable
40
+ data.map((item) => {
48
41
  item.title = item.title.toLowerCase()
49
42
  return item
50
43
  })
51
44
 
52
- return dataList
45
+ return data
53
46
  },
54
47
  },
55
48
  }
@@ -204,16 +204,8 @@ export default function (request, context) {
204
204
  }
205
205
  }),
206
206
  setCalculation: assign((context, event) => {
207
- // V2接口轉換中回傳的資料結構不同
208
- const { data } = event.data
209
- if (data) {
210
- return {
211
- calculation: data,
212
- }
213
- } else {
214
- return {
215
- calculation: event.data,
216
- }
207
+ return {
208
+ calculation: event.data,
217
209
  }
218
210
  }),
219
211
  resetCharge: assign((context, event) => {
@@ -73,6 +73,88 @@ export default function (request) {
73
73
  },
74
74
  },
75
75
  },
76
+ // mode: {
77
+ // always: [{ target: 'cash' }],
78
+ // },
79
+ // activity: {
80
+ // initial: 'checking',
81
+ // states: {
82
+ // checking: {
83
+ // always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
84
+ // },
85
+ // notConvertible: {
86
+ // on: {
87
+ // GIVE_UP: {
88
+ // target: 'fetchWithdrawRule',
89
+ // },
90
+ // },
91
+ // },
92
+ // fetchWithdrawRule: {
93
+ // invoke: {
94
+ // src: 'fetchWithdrawRulePreview',
95
+ // onDone: {
96
+ // target: 'giveUp',
97
+ // actions: 'setWithdrawRulePreview',
98
+ // },
99
+ // onError: {
100
+ // target: 'notConvertible',
101
+ // },
102
+ // },
103
+ // },
104
+ // giveUp: {
105
+ // on: {
106
+ // CONFIRM: {
107
+ // target: 'givingUp',
108
+ // },
109
+ // BACK: {
110
+ // target: 'notConvertible',
111
+ // },
112
+ // },
113
+ // },
114
+ // givingUp: {
115
+ // invoke: {
116
+ // src: 'giveUp',
117
+ // onDone: {
118
+ // target: 'gaveUp',
119
+ // },
120
+ // onError: {
121
+ // target: 'convertible',
122
+ // },
123
+ // },
124
+ // },
125
+ // gaveUp: {},
126
+ // convertible: {
127
+ // on: {
128
+ // SUBMIT: {
129
+ // target: 'converting',
130
+ // actions: 'setAttachmentType',
131
+ // },
132
+ // },
133
+ // },
134
+ // converting: {
135
+ // invoke: {
136
+ // src: 'convertFreeCredit',
137
+ // onDone: [
138
+ // // {
139
+ // // target: '#withdraw_manual.otp',
140
+ // // actions: 'setOtp',
141
+ // // cond: 'isOtpRequired',
142
+ // // },
143
+ // { target: 'converted' },
144
+ // ],
145
+ // onError: {
146
+ // target: 'convertible',
147
+ // },
148
+ // },
149
+ // },
150
+ // converted: {
151
+ // // always: [
152
+ // // { target: '#withdraw_manual.cash.unbound', cond: 'isBankNotBound' },
153
+ // // { target: '#withdraw_manual.cash.withdrawable', cond: 'hasAttachmentType' },
154
+ // // ],
155
+ // },
156
+ // },
157
+ // },
76
158
  cash: {
77
159
  initial: 'checking',
78
160
  states: {
@@ -251,6 +333,10 @@ export default function (request) {
251
333
  target: 'reset',
252
334
  },
253
335
  BACK: [
336
+ // {
337
+ // target: '#withdraw_manual.activity.convertible',
338
+ // cond: 'isActivity',
339
+ // },
254
340
  {
255
341
  target: '#withdraw_manual.cash.withdrawable',
256
342
  },
@@ -261,6 +347,10 @@ export default function (request) {
261
347
  invoke: {
262
348
  src: 'acknowledge',
263
349
  onDone: [
350
+ // {
351
+ // target: '#withdraw_manual.activity.converted',
352
+ // cond: 'isActivity',
353
+ // },
264
354
  {
265
355
  target: '#withdraw_manual.cash.submitted',
266
356
  },
@@ -384,16 +474,8 @@ export default function (request) {
384
474
  }
385
475
  }),
386
476
  setCalculation: assign((context, event) => {
387
- // V2接口轉換中回傳的資料結構不同
388
- const { data } = event.data
389
- if (data) {
390
- return {
391
- calculation: data,
392
- }
393
- } else {
394
- return {
395
- calculation: event.data,
396
- }
477
+ return {
478
+ calculation: event.data,
397
479
  }
398
480
  }),
399
481
  clearCalculation: assign((context, event) => {
@@ -415,6 +497,9 @@ export default function (request) {
415
497
  const lastMax = Math.min(parseFloat(balance), maximum)
416
498
  return !!currentBank && amount > 0 && minimum <= amount && amount <= lastMax
417
499
  },
500
+ // isActivity: (context, event) => {
501
+ // return context.mode === 'ACTIVITY'
502
+ // },
418
503
  hasAttachmentType: (context, event) => {
419
504
  return ['withdraw', 'pool'].includes(context.attachmentType)
420
505
  },
@@ -494,7 +579,7 @@ export default function (request) {
494
579
  payment.submitWithdrawTransactionManual({
495
580
  method,
496
581
  amount,
497
- applyerBankCode: currentBank.bankCode || currentBank.walletCode,
582
+ applyerBankCode: currentBank.bankCode,
498
583
  applyerAccountNumber: currentBank.accountNumber,
499
584
  applyerIfscCode: currentBank.ifscCode,
500
585
  branch: branchTemp,
@@ -266,7 +266,7 @@ export default function (request, context) {
266
266
  payment.submitWithdrawTransactionVN({
267
267
  method: currentPayment.method,
268
268
  amount: selectedAmount,
269
- applyerBankCode: selectedUserBank.bankCode || selectedUserBank.walletCode,
269
+ applyerBankCode: selectedUserBank.bankCode,
270
270
  applyerAccountNumber: selectedUserBank.accountNumber,
271
271
  applyerIfscCode: selectedUserBank.ifscCode,
272
272
  branch: branchTemp,
@@ -2,158 +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
- // 09/30
144
- 'pixel',
145
- // 10/09
146
- 'account-binding/status',
147
- 'account-binding/bind',
148
- 'account-binding/acknowledge',
149
- 'account-binding/bind-third-party',
150
- 'account-binding/bind-password',
151
- 'account-binding/reset-otp',
152
- // 11/10
153
- 'otp-verification-point/verify',
154
- 'otp-verification-point/acknowledge',
155
- 'otp-verification-point/reset-otp',
156
- ]
157
5
 
158
6
  function isValid(value) {
159
7
  return value !== undefined && value !== null
@@ -168,41 +16,15 @@ export default class Request {
168
16
  this.key = `cuora_${config.clientId}`
169
17
  this.errorHandler = null
170
18
  this.hosts = []
171
- this.isBlocked = false
172
19
  this.initialize()
173
20
  }
174
21
 
175
22
  initialize() {
176
- // 自定義參數序列化器 - 避免使用 URLSearchParams
177
- this.axios.defaults.paramsSerializer = function (params) {
178
- return Object.keys(params)
179
- .map((key) => {
180
- let value = params[key]
181
- if (value === null || value === undefined) {
182
- return null
183
- }
184
- // 針對key為q的參數進行手動編碼,避免雙重編碼
185
- if (key === 'q' && typeof value === 'string') {
186
- // 處理其他需要編碼的字符
187
- value = encodeURIComponent(value).replace(/[!'()*]/g, function (c) {
188
- return '%' + c.charCodeAt(0).toString(16).toUpperCase()
189
- })
190
- } else {
191
- // 對其他參數使用標準編碼
192
- value = encodeURIComponent(value)
193
- }
194
- return `${encodeURIComponent(key)}=${value}`
195
- })
196
- .filter(Boolean)
197
- .join('&')
198
- }
199
-
200
23
  this.axios.interceptors.request.use((axiosConfig) => {
201
24
  axiosConfig.headers['X-TH1GAMES-VERSION'] = this.config.version
202
25
  axiosConfig.headers['X-TH1GAMES-PLATFORM'] = this.config.platform
203
26
  if (this.getToken()) {
204
- // 為了支援V2版本的API接口新增Bearer來進行身份驗證
205
- axiosConfig.headers.Authorization = `Bearer ${this.getToken()}`
27
+ axiosConfig.headers.Authorization = this.getToken()
206
28
  }
207
29
  return axiosConfig
208
30
  })
@@ -239,25 +61,10 @@ export default class Request {
239
61
  try {
240
62
  const cancelToken = customToken || this.source.token
241
63
  this._checkToken(req)
242
-
243
64
  const requestConfig = this._createConfig(req, cancelToken)
244
- // console.log('*請求資料Check', requestConfig)
245
- const configUrls = ['getConfig', 'get-config']
246
- if (this.isBlocked && !configUrls.includes(requestConfig.url)) {
247
- // 狀態是維護中&請求非siteConfig,終止所有的請求,除了維護頁需要的資料(siteConfig)
248
- // console.log('%c*禁止的請求目標', requestConfig)
249
- } else {
250
- // console.log('%c*允許的請求目標', requestConfig)
251
- const { data } = await this.axios.request(requestConfig)
252
- return data
253
- }
65
+ const { data } = await this.axios.request(requestConfig)
66
+ return data
254
67
  } catch (error) {
255
- if (error.code === 'ERR_F108') {
256
- console.log('%c*維護中', 'color: #00ff33ff; font-weight: bold;')
257
- this.isBlocked = true
258
- this.errorHandler && this.errorHandler(error)
259
- throw error
260
- }
261
68
  if (error.code !== 'ERR_800') {
262
69
  if (error.code) {
263
70
  this.errorHandler && this.errorHandler(error)
@@ -278,37 +85,11 @@ export default class Request {
278
85
 
279
86
  _createConfig(req, cancelToken) {
280
87
  const { method, url, params, isPublic, isFormData, headers } = req
281
- let fullURL = this.config.fullURL
282
- let urlName = url
283
- // 有些API會將參數(/?)直接帶在URL上,所以要將參數排除
284
- const cleanUrl = url.split('?')[0]
285
-
286
- const isV2Supported = supportVersion2List.some((supportedUrl) => {
287
- // 如果包含動態參數(:parameter),則使用模式匹配
288
- if (supportedUrl.includes(':')) {
289
- const pattern = supportedUrl.replace(/:[^/]+/g, '[^/]+')
290
- const regex = new RegExp(`^${pattern}$`)
291
- return regex.test(cleanUrl)
292
- }
293
- return supportedUrl === cleanUrl
294
- })
295
-
296
- // 目前全站都支援V2,若有需要限制為V1的站點可以填入,此段等轉換全部完成之後就可以移除了
297
- const supportV2Toggle = [''].includes(this.config?.clientId)
298
-
299
- if (isV2Supported && !supportV2Toggle) {
300
- fullURL = fullURL.replace('/v1/', '/v2/')
301
- urlName = this._convertUrlToKebabCase(url)
302
- // console.log(`*[DEV_ONLY]V2`, 'url:', urlName)
303
- } else {
304
- // console.log(`*[DEV_ONLY]V2-不支援:`, 'url:', urlName)
305
- }
306
-
307
88
  if (isFormData) {
308
89
  return {
309
- baseURL: fullURL,
90
+ baseURL: this.config.fullURL,
310
91
  method,
311
- url: urlName,
92
+ url,
312
93
  cancelToken,
313
94
  isPublic,
314
95
  headers: { 'Content-Type': 'multipart/form-data' },
@@ -316,9 +97,9 @@ export default class Request {
316
97
  }
317
98
  } else {
318
99
  return {
319
- baseURL: fullURL,
100
+ baseURL: this.config.fullURL,
320
101
  method,
321
- url: urlName,
102
+ url,
322
103
  cancelToken,
323
104
  isPublic,
324
105
  headers,
@@ -327,38 +108,6 @@ export default class Request {
327
108
  }
328
109
  }
329
110
 
330
- // 調整API路徑與名稱
331
- _convertUrlToKebabCase(url) {
332
- const specifyingPath = {
333
- 'all-activities/list': 'activities/all-activities-list',
334
- friends: 'activities/friends',
335
- 'friends/home': 'activities/friends/home',
336
- 'friends/reward-list': 'activities/friends/reward-list',
337
- 'friends/dashboard': 'activities/friends/dashboard',
338
- 'friends/dashboard/list': 'activities/friends/dashboard/list',
339
- 'activities/getFreeGameReward': 'activities/free-game/get-free-game-reward',
340
- 'activities/getFreeGameRewardList': 'activities/free-game/get-free-game-reward-list',
341
- 'activities/lose-rebate/history': 'activities/rebate/lose-rebate/history',
342
- 'activities/ranking': 'activities/ranking/promotion-ranking',
343
- 'activities/activity/ranking': 'activities/ranking/basic-ranking',
344
- 'activities/cashRain': 'activities/cash-rain/exchange',
345
- 'tournament/detail': 'activities/tournament/detail',
346
- 'ranking/detail': 'activities/tournament/ranking/detail',
347
- 'ranking/detail/option': 'activities/tournament/ranking/detail/option',
348
- 'hot-game/ranking': 'activities/tournament/ranking/hot-game',
349
- 'activities/rebate/estimate': 'activities/rebate/estimate',
350
- 'activities/exchange/diamond/max-amount': 'activities/diamond/exchange/max-amount',
351
- 'activities/exchange/diamond/settle': 'activities/diamond/exchange/settle',
352
- }
353
- if (specifyingPath[url]) {
354
- // 和原有路徑不同有另外改路徑
355
- return specifyingPath[url]
356
- } else {
357
- // 將API_URL的命名規則由駝峰調整為短橫線(-)
358
- return url.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()
359
- }
360
- }
361
-
362
111
  _checkToken(req) {
363
112
  if (!req.isPublic && !this.getToken()) {
364
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 }