@jetthai/cuora 1.0.66-sabai-2 → 1.0.66
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 -640
- package/README.md +0 -6
- package/dist/index.js +2 -0
- package/dist/index.js.LICENSE.txt +30 -0
- package/package.json +11 -13
- package/src/api/activity.js +3 -10
- package/src/api/auth.js +5 -47
- package/src/api/game.js +2 -64
- package/src/api/index.js +8 -8
- package/src/api/payment.js +7 -86
- package/src/api/user.js +0 -18
- package/src/index.js +5 -7
- package/src/machine/activity/activity.js +10 -97
- package/src/machine/activity/continue_deposit_activity.js +1 -1
- package/src/machine/activity/deposit_activity.js +1 -1
- package/src/machine/activity/{diamond_shop_activity_fc.js → diamond_shop_activity.js} +5 -33
- package/src/machine/activity/{diamond_shop_activity_vn.js → diamond_shop_activity_single_exchange.js} +21 -66
- package/src/machine/activity/fafafa_activity.js +2 -4
- package/src/machine/activity/index.js +10 -24
- package/src/machine/activity/invite_friends_activity.js +8 -3
- package/src/machine/activity/ranking_activity.js +46 -40
- package/src/machine/activity/return_bonus_activity.js +3 -5
- package/src/machine/activity/specify_bets_activity.js +1 -1
- package/src/machine/auth.js +79 -234
- package/src/machine/{auth_otp_v3.js → auth_otp.js} +17 -80
- package/src/machine/bank_binding.js +14 -15
- package/src/machine/common.js +17 -80
- package/src/machine/{deposit/deposit_fc.js → deposit.js} +15 -27
- package/src/machine/error.js +1 -1
- package/src/machine/game.js +10 -17
- package/src/machine/game_favorite.js +2 -2
- package/src/machine/game_hot_new.js +1 -1
- package/src/machine/game_search.js +7 -3
- package/src/machine/inbox.js +6 -5
- package/src/machine/index.js +25 -56
- package/src/machine/merge.js +2 -2
- package/src/machine/payment_data.js +5 -6
- package/src/machine/reward.js +3 -84
- package/src/machine/setting.js +2 -5
- package/src/machine/side.js +27 -34
- package/src/machine/user_info.js +1 -1
- package/src/machine/user_reset_password.js +2 -2
- package/src/machine/user_sign_up.js +56 -111
- package/src/machine/welcome.js +8 -6
- package/src/machine/withdraw.js +380 -0
- package/src/machine/withdraw_vn.js +87 -264
- package/src/request/config.js +1 -7
- package/src/request/cookie.js +52 -0
- package/src/request/request.js +15 -11
- package/webpack.config.js +33 -0
- package/.husky/pre-commit +0 -4
- package/.prettierignore +0 -1
- package/dist/bundle.mjs +0 -27623
- package/rollup.config.js +0 -12
- package/src/lib/fingerprint.js +0 -5779
- package/src/machine/activity/affiliate_invite_friends_activity.js +0 -216
- package/src/machine/activity/mini_game_activity.js +0 -68
- package/src/machine/activity/roulette_activity_v2.js +0 -81
- package/src/machine/activity/sign_in_activity.js +0 -149
- package/src/machine/activity/specify_turnover_activity.js +0 -113
- package/src/machine/activity/time_bomb_activity.js +0 -80
- package/src/machine/auth_otp_v2.js +0 -177
- package/src/machine/bank_binding_amb.js +0 -140
- package/src/machine/bonus.js +0 -75
- package/src/machine/deposit/amb.js +0 -90
- package/src/machine/deposit/crypto.js +0 -267
- package/src/machine/deposit/crypto_button.js +0 -449
- package/src/machine/deposit/direct.js +0 -246
- package/src/machine/deposit/float.js +0 -295
- package/src/machine/deposit/index.js +0 -25
- package/src/machine/deposit/loadcard_vn.js +0 -390
- package/src/machine/deposit/manual_vn.js +0 -382
- package/src/machine/deposit/qrcode_v2.js +0 -451
- package/src/machine/deposit/usdt.js +0 -144
- package/src/machine/deposit/vpay.js +0 -292
- package/src/machine/game_favorite_v2.js +0 -119
- package/src/machine/game_search_v2.js +0 -379
- package/src/machine/game_v2.js +0 -381
- package/src/machine/game_v2_1.js +0 -442
- package/src/machine/leaderboard.js +0 -108
- package/src/machine/promotions.js +0 -170
- package/src/machine/reward_fc.js +0 -97
- package/src/machine/roulette_v2.js +0 -271
- package/src/machine/side_v2.js +0 -200
- package/src/machine/vip_table.js +0 -50
- package/src/machine/withdraw_amb.js +0 -373
- package/src/machine/withdraw_crypto.js +0 -560
- package/src/machine/withdraw_fc.js +0 -251
- package/src/util/constant.js +0 -2
- package/src/util/deviceToken.js +0 -33
- package/src/util/index.js +0 -6
- package/src/util/storage.js +0 -28
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import findLastIndex from 'lodash/findLastIndex
|
|
3
|
-
import payment from '../api/payment
|
|
4
|
-
import common from '../api/common
|
|
5
|
-
import user from '../api/user
|
|
2
|
+
import findLastIndex from 'lodash/findLastIndex'
|
|
3
|
+
import payment from '../api/payment'
|
|
4
|
+
import common from '../api/common'
|
|
5
|
+
import user from '../api/user'
|
|
6
|
+
|
|
7
|
+
// todo - noBind -> unbound
|
|
8
|
+
// todo - withdrawLimit, targetWithdrawLimit 轉為正數
|
|
9
|
+
// todo - mod -> mode
|
|
10
|
+
// todo - adjust updateWithdrawCondition
|
|
6
11
|
|
|
7
12
|
export default function (request) {
|
|
8
13
|
const { appSecret } = request.config
|
|
@@ -23,23 +28,14 @@ export default function (request) {
|
|
|
23
28
|
bankList: [],
|
|
24
29
|
withdrawLimit: null,
|
|
25
30
|
targetWithdrawLimit: null,
|
|
26
|
-
attachmentType: null, // null | 'withdraw' | 'pool'
|
|
27
|
-
maximumWithdrawAmount: 0,
|
|
28
|
-
enableWithdrawAmount: 0,
|
|
29
|
-
enableWithdraw: false,
|
|
30
|
-
withdrawRules: [],
|
|
31
31
|
|
|
32
|
-
amount: null,
|
|
33
32
|
bank: null,
|
|
34
33
|
branch: null,
|
|
35
34
|
accountNumber: null,
|
|
36
35
|
holderName: null,
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
status: null,
|
|
41
|
-
target: null,
|
|
42
|
-
ttl: null,
|
|
37
|
+
withdrawDistance: null,
|
|
38
|
+
withdrawAmount: null,
|
|
43
39
|
},
|
|
44
40
|
states: {
|
|
45
41
|
loading: {
|
|
@@ -47,7 +43,7 @@ export default function (request) {
|
|
|
47
43
|
src: 'fetchInitData',
|
|
48
44
|
onDone: {
|
|
49
45
|
target: 'mode',
|
|
50
|
-
actions: ['
|
|
46
|
+
actions: ['setSiteConfig', 'setUserInfo', 'setData', 'preset'],
|
|
51
47
|
},
|
|
52
48
|
onError: {
|
|
53
49
|
target: 'fail',
|
|
@@ -58,69 +54,43 @@ export default function (request) {
|
|
|
58
54
|
always: [{ target: 'free', cond: 'isFree' }, { target: 'cash' }],
|
|
59
55
|
},
|
|
60
56
|
free: {
|
|
61
|
-
initial: '
|
|
57
|
+
initial: 'loading',
|
|
62
58
|
states: {
|
|
63
|
-
|
|
64
|
-
// invoke: {
|
|
65
|
-
// src: 'fetchWithdrawRules',
|
|
66
|
-
// onDone: {
|
|
67
|
-
// target: 'checking',
|
|
68
|
-
// actions: 'updateWithdrawCondition',
|
|
69
|
-
// },
|
|
70
|
-
// onError: {
|
|
71
|
-
// target: 'notConvertible',
|
|
72
|
-
// },
|
|
73
|
-
// },
|
|
74
|
-
// },
|
|
75
|
-
checking: {
|
|
76
|
-
always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
|
|
77
|
-
},
|
|
78
|
-
notConvertible: {
|
|
79
|
-
on: {
|
|
80
|
-
GIVE_UP: {
|
|
81
|
-
target: 'givingUp',
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
givingUp: {
|
|
59
|
+
loading: {
|
|
86
60
|
invoke: {
|
|
87
|
-
src: '
|
|
61
|
+
src: 'fetchWithdrawRules',
|
|
88
62
|
onDone: {
|
|
89
|
-
target: '
|
|
63
|
+
target: 'checking',
|
|
64
|
+
actions: 'updateWithdrawCondition',
|
|
90
65
|
},
|
|
91
66
|
onError: {
|
|
92
|
-
target: '
|
|
67
|
+
target: 'notConvertible',
|
|
93
68
|
},
|
|
94
69
|
},
|
|
95
70
|
},
|
|
96
|
-
|
|
71
|
+
checking: {
|
|
72
|
+
always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
|
|
73
|
+
},
|
|
74
|
+
notConvertible: {},
|
|
97
75
|
convertible: {
|
|
98
76
|
on: {
|
|
99
77
|
SUBMIT: {
|
|
100
78
|
target: 'converting',
|
|
101
|
-
actions: 'setAttachmentType',
|
|
102
79
|
},
|
|
103
80
|
},
|
|
104
81
|
},
|
|
105
82
|
converting: {
|
|
106
83
|
invoke: {
|
|
107
|
-
src: '
|
|
108
|
-
onDone:
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
actions: 'setOtp',
|
|
112
|
-
cond: 'isOtpRequired',
|
|
113
|
-
},
|
|
114
|
-
{ target: 'converted' },
|
|
115
|
-
],
|
|
84
|
+
src: 'submitWithdrawFree',
|
|
85
|
+
onDone: {
|
|
86
|
+
target: 'converted',
|
|
87
|
+
},
|
|
116
88
|
onError: {
|
|
117
89
|
target: 'convertible',
|
|
118
90
|
},
|
|
119
91
|
},
|
|
120
92
|
},
|
|
121
|
-
converted: {
|
|
122
|
-
always: [{ target: '#withdraw_vn.cash.withdrawable', cond: 'hasAttachmentType' }],
|
|
123
|
-
},
|
|
93
|
+
converted: {},
|
|
124
94
|
},
|
|
125
95
|
},
|
|
126
96
|
cash: {
|
|
@@ -141,52 +111,18 @@ export default function (request) {
|
|
|
141
111
|
inProcessing: {},
|
|
142
112
|
withdrawable: {
|
|
143
113
|
on: {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
bank: event.data,
|
|
148
|
-
}
|
|
149
|
-
}),
|
|
150
|
-
},
|
|
151
|
-
SET_AMOUNT: {
|
|
152
|
-
actions: assign((context, event) => {
|
|
153
|
-
return {
|
|
154
|
-
amount: event.data,
|
|
155
|
-
}
|
|
156
|
-
}),
|
|
157
|
-
},
|
|
158
|
-
SET_ATTACHMENT_TYPE: {
|
|
159
|
-
actions: 'setAttachmentType',
|
|
160
|
-
cond: 'isNewWalletMode',
|
|
114
|
+
SUBMIT: {
|
|
115
|
+
target: 'submitting',
|
|
116
|
+
cond: 'isSubmittable',
|
|
161
117
|
},
|
|
162
|
-
SUBMIT: [
|
|
163
|
-
{
|
|
164
|
-
target: 'pooling',
|
|
165
|
-
cond: (context, event) => {
|
|
166
|
-
const { amount, attachmentType } = context
|
|
167
|
-
return attachmentType === 'pool' && amount > 0
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
target: 'submitting',
|
|
172
|
-
cond: 'isSubmittable',
|
|
173
|
-
},
|
|
174
|
-
],
|
|
175
118
|
},
|
|
176
119
|
},
|
|
177
120
|
submitting: {
|
|
178
121
|
invoke: {
|
|
179
122
|
src: 'submitWithdraw',
|
|
180
|
-
onDone:
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
actions: 'setOtp',
|
|
184
|
-
cond: 'isOtpRequired',
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
target: 'submitted',
|
|
188
|
-
},
|
|
189
|
-
],
|
|
123
|
+
onDone: {
|
|
124
|
+
target: 'submitted',
|
|
125
|
+
},
|
|
190
126
|
onError: {
|
|
191
127
|
target: 'withdrawable',
|
|
192
128
|
},
|
|
@@ -200,7 +136,6 @@ export default function (request) {
|
|
|
200
136
|
invoke: {
|
|
201
137
|
src: 'fetchPaymentData',
|
|
202
138
|
onDone: {
|
|
203
|
-
target: 'inProcessing',
|
|
204
139
|
actions: 'setPaymentData',
|
|
205
140
|
},
|
|
206
141
|
onError: {
|
|
@@ -208,81 +143,6 @@ export default function (request) {
|
|
|
208
143
|
},
|
|
209
144
|
},
|
|
210
145
|
},
|
|
211
|
-
pooling: {
|
|
212
|
-
invoke: {
|
|
213
|
-
src: 'pool',
|
|
214
|
-
onDone: { target: 'pooled' },
|
|
215
|
-
onError: {
|
|
216
|
-
target: 'withdrawable',
|
|
217
|
-
},
|
|
218
|
-
},
|
|
219
|
-
},
|
|
220
|
-
pooled: {},
|
|
221
|
-
},
|
|
222
|
-
},
|
|
223
|
-
otp: {
|
|
224
|
-
type: 'parallel',
|
|
225
|
-
states: {
|
|
226
|
-
countdown: {
|
|
227
|
-
after: {
|
|
228
|
-
1000: {
|
|
229
|
-
target: 'countdown',
|
|
230
|
-
actions: 'decreaseTtl',
|
|
231
|
-
cond: (context) => context.ttl > 0,
|
|
232
|
-
},
|
|
233
|
-
},
|
|
234
|
-
},
|
|
235
|
-
verification: {
|
|
236
|
-
initial: 'idle',
|
|
237
|
-
states: {
|
|
238
|
-
idle: {
|
|
239
|
-
on: {
|
|
240
|
-
ACKNOWLEDGE: {
|
|
241
|
-
target: 'acknowledging',
|
|
242
|
-
},
|
|
243
|
-
RESET_OTP: {
|
|
244
|
-
target: 'reset',
|
|
245
|
-
},
|
|
246
|
-
BACK: [
|
|
247
|
-
{
|
|
248
|
-
target: '#withdraw_vn.free.convertible',
|
|
249
|
-
cond: 'isFree',
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
target: '#withdraw_vn.cash.withdrawable',
|
|
253
|
-
},
|
|
254
|
-
],
|
|
255
|
-
},
|
|
256
|
-
},
|
|
257
|
-
acknowledging: {
|
|
258
|
-
invoke: {
|
|
259
|
-
src: 'acknowledge',
|
|
260
|
-
onDone: [
|
|
261
|
-
{
|
|
262
|
-
target: '#withdraw_vn.free.converted',
|
|
263
|
-
cond: 'isFree',
|
|
264
|
-
},
|
|
265
|
-
{
|
|
266
|
-
target: '#withdraw_vn.cash.submitted',
|
|
267
|
-
},
|
|
268
|
-
],
|
|
269
|
-
onError: {
|
|
270
|
-
target: 'idle',
|
|
271
|
-
},
|
|
272
|
-
},
|
|
273
|
-
},
|
|
274
|
-
reset: {
|
|
275
|
-
invoke: {
|
|
276
|
-
src: 'resetOtp',
|
|
277
|
-
onDone: {
|
|
278
|
-
target: 'idle',
|
|
279
|
-
actions: 'setVerificationData',
|
|
280
|
-
},
|
|
281
|
-
onError: { target: 'idle' },
|
|
282
|
-
},
|
|
283
|
-
},
|
|
284
|
-
},
|
|
285
|
-
},
|
|
286
146
|
},
|
|
287
147
|
},
|
|
288
148
|
fail: {},
|
|
@@ -291,15 +151,28 @@ export default function (request) {
|
|
|
291
151
|
REFRESH: {
|
|
292
152
|
target: 'loading',
|
|
293
153
|
},
|
|
154
|
+
SET_CURRENT_BANK: {
|
|
155
|
+
actions: assign((context, event) => {
|
|
156
|
+
return {
|
|
157
|
+
bank: event.data,
|
|
158
|
+
}
|
|
159
|
+
}),
|
|
160
|
+
},
|
|
161
|
+
SET_AMOUNT: {
|
|
162
|
+
actions: assign((context, event) => {
|
|
163
|
+
return {
|
|
164
|
+
amount: event.data,
|
|
165
|
+
}
|
|
166
|
+
}),
|
|
167
|
+
},
|
|
294
168
|
},
|
|
295
169
|
},
|
|
296
170
|
{
|
|
297
171
|
actions: {
|
|
298
|
-
|
|
172
|
+
setData: assign((context, event) => {
|
|
299
173
|
return {
|
|
300
174
|
paymentDetail: event.data.paymentDetail,
|
|
301
175
|
bankInfo: event.data.bankInfo,
|
|
302
|
-
bank: event.data.bankInfo[0],
|
|
303
176
|
bonus: event.data.bonus,
|
|
304
177
|
bankList: event.data.bankList,
|
|
305
178
|
}
|
|
@@ -311,6 +184,16 @@ export default function (request) {
|
|
|
311
184
|
paymentDetail: event.data.paymentDetail,
|
|
312
185
|
}
|
|
313
186
|
}),
|
|
187
|
+
setUserInfo: assign((context, event) => {
|
|
188
|
+
return {
|
|
189
|
+
userInfo: event.data.userInfo,
|
|
190
|
+
}
|
|
191
|
+
}),
|
|
192
|
+
setSiteConfig: assign((context, event) => {
|
|
193
|
+
return {
|
|
194
|
+
siteConfig: event.data.siteConfig,
|
|
195
|
+
}
|
|
196
|
+
}),
|
|
314
197
|
preset: assign((context, event) => {
|
|
315
198
|
const { userInfo, siteConfig } = event.data
|
|
316
199
|
const { withdraw_limit, target_withdraw_limit } = userInfo || {}
|
|
@@ -321,26 +204,24 @@ export default function (request) {
|
|
|
321
204
|
targetWithdrawLimit: Math.abs(target_withdraw_limit),
|
|
322
205
|
methods,
|
|
323
206
|
balance,
|
|
324
|
-
siteConfig,
|
|
325
|
-
userInfo,
|
|
326
|
-
attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
|
|
327
207
|
}
|
|
328
208
|
}),
|
|
329
209
|
updateWithdrawCondition: assign((context, event) => {
|
|
330
|
-
const
|
|
331
|
-
event.data?.withdrawRule
|
|
210
|
+
const rules = event.data.rules.filter((rule) => rule.maxWithdrawAmount > 0)
|
|
332
211
|
|
|
333
|
-
const
|
|
334
|
-
const rules = withdrawRules.filter((rule) => rule.maxWithdrawAmount > 0)
|
|
335
|
-
|
|
336
|
-
const { balance } = context
|
|
212
|
+
const { balance, withdrawLimit } = context
|
|
337
213
|
const lastMatchedIndex = findLastIndex(rules, (rule) => balance >= rule.greaterEqualThen)
|
|
338
214
|
|
|
339
|
-
let maxWithdrawAmount = 0
|
|
215
|
+
let maxWithdrawAmount = 0,
|
|
216
|
+
availableWithdrawAmount = 0
|
|
340
217
|
|
|
341
218
|
if (lastMatchedIndex > -1) {
|
|
342
219
|
rules[lastMatchedIndex].match = true
|
|
343
220
|
maxWithdrawAmount = rules[lastMatchedIndex].maxWithdrawAmount
|
|
221
|
+
|
|
222
|
+
if (withdrawLimit === 0) {
|
|
223
|
+
availableWithdrawAmount = Math.min(balance, maxWithdrawAmount)
|
|
224
|
+
}
|
|
344
225
|
} else if (rules.length > 0) {
|
|
345
226
|
maxWithdrawAmount = rules[0].maxWithdrawAmount
|
|
346
227
|
} else {
|
|
@@ -349,37 +230,7 @@ export default function (request) {
|
|
|
349
230
|
|
|
350
231
|
return {
|
|
351
232
|
maxWithdrawAmount,
|
|
352
|
-
|
|
353
|
-
enableWithdraw,
|
|
354
|
-
withdrawRules,
|
|
355
|
-
}
|
|
356
|
-
}),
|
|
357
|
-
setOtp: assign((context, event) => {
|
|
358
|
-
const { requestId, status, target, ttl } = event.data
|
|
359
|
-
return {
|
|
360
|
-
requestId,
|
|
361
|
-
status,
|
|
362
|
-
target,
|
|
363
|
-
ttl,
|
|
364
|
-
}
|
|
365
|
-
}),
|
|
366
|
-
decreaseTtl: assign((context, evnet) => {
|
|
367
|
-
const second = context.ttl
|
|
368
|
-
return {
|
|
369
|
-
ttl: Math.max(second - 1, 0),
|
|
370
|
-
}
|
|
371
|
-
}),
|
|
372
|
-
setVerificationData: assign((context, event) => {
|
|
373
|
-
const { requestId, ttl, target } = event.data
|
|
374
|
-
return {
|
|
375
|
-
requestId,
|
|
376
|
-
ttl,
|
|
377
|
-
target,
|
|
378
|
-
}
|
|
379
|
-
}),
|
|
380
|
-
setAttachmentType: assign((context, event) => {
|
|
381
|
-
return {
|
|
382
|
-
attachmentType: event.data,
|
|
233
|
+
availableWithdrawAmount,
|
|
383
234
|
}
|
|
384
235
|
}),
|
|
385
236
|
},
|
|
@@ -387,11 +238,11 @@ export default function (request) {
|
|
|
387
238
|
isFree: (context, event) => {
|
|
388
239
|
return context.userInfo?.withdraw_rule !== 'DEFAULT'
|
|
389
240
|
},
|
|
390
|
-
hasAttachmentType: (context, event) => {
|
|
391
|
-
return ['withdraw', 'pool'].includes(context.attachmentType)
|
|
392
|
-
},
|
|
393
241
|
haveProcessing: (context, event) => {
|
|
394
|
-
return
|
|
242
|
+
return context.paymentDetail[0] && context.paymentDetail[0].processing.length > 0
|
|
243
|
+
},
|
|
244
|
+
otherPlace: (context, event) => {
|
|
245
|
+
return context.otherPlace
|
|
395
246
|
},
|
|
396
247
|
isWithdrawDisable: (context, event) => {
|
|
397
248
|
const { siteConfig } = context
|
|
@@ -401,40 +252,36 @@ export default function (request) {
|
|
|
401
252
|
isBankNotBound: (context, event) => {
|
|
402
253
|
return !context.bankInfo?.length
|
|
403
254
|
},
|
|
255
|
+
isBindable: (context, event) => {
|
|
256
|
+
const { bank, accountNumber, branch, holderName } = context
|
|
257
|
+
return bank.bankCode && accountNumber && branch && holderName
|
|
258
|
+
},
|
|
404
259
|
isSubmittable: (context, event) => {
|
|
405
|
-
const {
|
|
406
|
-
return
|
|
260
|
+
const { applyerBankCode, applyerAccountNumber, branch, holderName, amount } = event.data
|
|
261
|
+
return applyerBankCode, applyerAccountNumber, branch, holderName, amount
|
|
407
262
|
},
|
|
408
263
|
isConvertible: (context, event) => {
|
|
409
|
-
const { balance,
|
|
410
|
-
return balance > 0 &&
|
|
264
|
+
const { balance, withdrawLimit } = context
|
|
265
|
+
return balance > 0 && withdrawLimit === 0
|
|
411
266
|
},
|
|
412
267
|
isNotWithdrawable: (context, event) => {
|
|
413
|
-
const { balance,
|
|
268
|
+
const { balance, withdrawLimit, paymentDetail } = context
|
|
414
269
|
const minWithdrawAmount = paymentDetail[0]?.minimum || 0
|
|
415
|
-
return
|
|
270
|
+
return withdrawLimit !== 0 || balance < minWithdrawAmount
|
|
416
271
|
},
|
|
417
|
-
isOtpRequired: (context, event) => {
|
|
418
|
-
return event.data?.status === 'otp-verifying'
|
|
419
|
-
},
|
|
420
|
-
isNewWalletMode: (context, event) => context.siteConfig.walletMode > 0,
|
|
421
272
|
},
|
|
422
273
|
services: {
|
|
423
274
|
fetchInitData: async (context, event) => {
|
|
424
|
-
const [{ config }, userInfo, paymentDetail = [], { bonus, bankInfo }
|
|
275
|
+
const [{ config }, userInfo, paymentDetail = [], { bonus, bankInfo }] = await Promise.all([
|
|
425
276
|
request.send(common.getConfig({ appSecret })),
|
|
426
277
|
request.send(user.getUserInfo()),
|
|
427
278
|
request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' })),
|
|
428
279
|
request.send(payment.getPaymentInfo()),
|
|
429
|
-
request.send(payment.getCurrentWithdrawRule()),
|
|
430
280
|
])
|
|
431
281
|
const siteConfig = JSON.parse(window.atob(config))
|
|
432
|
-
const method = paymentDetail.find((payment) => payment.
|
|
282
|
+
const method = paymentDetail.find((payment) => payment.methodType === 'manual').method
|
|
433
283
|
const bankList = await request.send(payment.getBankList(method))
|
|
434
|
-
|
|
435
|
-
return { ...item, ...bankList.find((bank) => bank.bankCode === item.bankCode) }
|
|
436
|
-
})
|
|
437
|
-
return { siteConfig, userInfo, paymentDetail, bonus, bankInfo: newBankInfo, bankList, withdrawRule }
|
|
284
|
+
return { siteConfig, userInfo, paymentDetail, bonus, bankInfo, bankList }
|
|
438
285
|
},
|
|
439
286
|
fetchPaymentData: async (context, event) => {
|
|
440
287
|
const paymentDetail = await request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' }))
|
|
@@ -456,39 +303,15 @@ export default function (request) {
|
|
|
456
303
|
return await request.send(payment.getCurrentWithdrawRule())
|
|
457
304
|
},
|
|
458
305
|
submitWithdraw: async (context, event) => {
|
|
459
|
-
const {
|
|
306
|
+
const { amount, applyerBankCode, applyerAccountNumber, branch, holderName } = event.data
|
|
460
307
|
const { method } = context.paymentDetail[0]
|
|
461
|
-
const branchTemp = bank.bankCode === 'GCASH' ? '' : bank.branch
|
|
462
308
|
return await request.send(
|
|
463
|
-
payment.submitWithdrawTransactionVN({
|
|
464
|
-
method,
|
|
465
|
-
amount,
|
|
466
|
-
applyerBankCode: bank.bankCode,
|
|
467
|
-
applyerAccountNumber: bank.accountNumber,
|
|
468
|
-
branch: branchTemp,
|
|
469
|
-
holderName: bank.holderName,
|
|
470
|
-
})
|
|
309
|
+
payment.submitWithdrawTransactionVN({ method, amount, applyerBankCode, applyerAccountNumber, branch, holderName })
|
|
471
310
|
)
|
|
472
311
|
},
|
|
473
|
-
|
|
312
|
+
submitWithdrawFree: async (context, event) => {
|
|
474
313
|
return await request.send(payment.convertFreeCredit({ exchangeType: 1 }))
|
|
475
314
|
},
|
|
476
|
-
resetOtp: async (context, event) => {
|
|
477
|
-
const { requestId, target } = context
|
|
478
|
-
return await request.send(user.otpReset({ requestId, target }))
|
|
479
|
-
},
|
|
480
|
-
acknowledge: async (context, event) => {
|
|
481
|
-
const { requestId, target } = context
|
|
482
|
-
const code = event.data
|
|
483
|
-
return await request.send(user.otpAcknowledge({ requestId, target, code }))
|
|
484
|
-
},
|
|
485
|
-
pool: async (context, event) => {
|
|
486
|
-
const { amount } = context
|
|
487
|
-
return await request.send(payment.restore({ amount }))
|
|
488
|
-
},
|
|
489
|
-
giveUp: async (context, event) => {
|
|
490
|
-
return await request.send(payment.giveUp())
|
|
491
|
-
},
|
|
492
315
|
},
|
|
493
316
|
}
|
|
494
317
|
)
|
package/src/request/config.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import urljoin from 'url-join'
|
|
2
2
|
|
|
3
|
-
// const urljoin = require('url-join')
|
|
4
|
-
|
|
5
3
|
export default class Config {
|
|
6
|
-
constructor({ apiURL, apiVersion, clientId, appSecret, platform, version
|
|
4
|
+
constructor({ apiURL, apiVersion, clientId, appSecret, platform, version }) {
|
|
7
5
|
this.apiURL = apiURL
|
|
8
6
|
this.apiVersion = apiVersion
|
|
9
7
|
this.clientId = clientId
|
|
@@ -11,10 +9,6 @@ export default class Config {
|
|
|
11
9
|
this.platform = platform
|
|
12
10
|
this.version = version
|
|
13
11
|
this.fullURL = urljoin(this.apiURL, this.apiVersion, this.clientId)
|
|
14
|
-
this.fpToken = fpToken // fingerprintjs token
|
|
15
|
-
this.sentry = sentry
|
|
16
|
-
this.defaultChannel = defaultChannel
|
|
17
|
-
this.defaultSubchannel = defaultSubchannel
|
|
18
12
|
}
|
|
19
13
|
|
|
20
14
|
setApiURL(url) {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import Cookies from 'universal-cookie'
|
|
2
|
+
|
|
3
|
+
export default class Cookie {
|
|
4
|
+
constructor(tokenKey) {
|
|
5
|
+
this.cookies = new Cookies()
|
|
6
|
+
this.tokenKey = tokenKey
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
setToken(token) {
|
|
10
|
+
this.cookies.set(this.tokenKey, token, {
|
|
11
|
+
path: '/',
|
|
12
|
+
maxAge: 300,
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
prolongToken() {
|
|
17
|
+
const token = this.getToken()
|
|
18
|
+
if (token) {
|
|
19
|
+
this.setToken(token)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getToken() {
|
|
24
|
+
return this.cookies.get(this.tokenKey)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
removeToken() {
|
|
28
|
+
this.cookies.remove(this.tokenKey, {
|
|
29
|
+
path: '/',
|
|
30
|
+
maxAge: 300,
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
setUser(user) {
|
|
35
|
+
this.cookies.set('cuora_tempuser', user, {
|
|
36
|
+
path: '/',
|
|
37
|
+
maxAge: 60 * 60 * 24,
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
getUser() {
|
|
42
|
+
return this.cookies.get('cuora_tempuser')
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
set(name, value, options) {
|
|
46
|
+
this.cookies.set(name, value, options)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
get(name, options) {
|
|
50
|
+
return this.cookies.get(name, options)
|
|
51
|
+
}
|
|
52
|
+
}
|
package/src/request/request.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import pickBy from 'lodash/pickBy
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
// const pickBy = require('lodash/pickBy')
|
|
1
|
+
import pickBy from 'lodash/pickBy'
|
|
2
|
+
import Cookie from './cookie'
|
|
5
3
|
|
|
6
4
|
function isValid(value) {
|
|
7
5
|
return value !== undefined && value !== null
|
|
@@ -12,9 +10,8 @@ export default class Request {
|
|
|
12
10
|
this.axios = axios
|
|
13
11
|
this.source = axios.CancelToken.source()
|
|
14
12
|
this.config = config
|
|
15
|
-
this.
|
|
13
|
+
this.cookie = new Cookie(`cuora_${config.clientId}`)
|
|
16
14
|
this.errorHandler = null
|
|
17
|
-
this.hosts = []
|
|
18
15
|
this.initialize()
|
|
19
16
|
}
|
|
20
17
|
|
|
@@ -22,8 +19,8 @@ export default class Request {
|
|
|
22
19
|
this.axios.interceptors.request.use((axiosConfig) => {
|
|
23
20
|
axiosConfig.headers['X-TH1GAMES-VERSION'] = this.config.version
|
|
24
21
|
axiosConfig.headers['X-TH1GAMES-PLATFORM'] = this.config.platform
|
|
25
|
-
if (
|
|
26
|
-
axiosConfig.headers.Authorization =
|
|
22
|
+
if (this.cookie.getToken()) {
|
|
23
|
+
axiosConfig.headers.Authorization = this.cookie.getToken()
|
|
27
24
|
}
|
|
28
25
|
return axiosConfig
|
|
29
26
|
})
|
|
@@ -51,7 +48,7 @@ export default class Request {
|
|
|
51
48
|
async send(req, customToken) {
|
|
52
49
|
try {
|
|
53
50
|
const cancelToken = customToken || this.source.token
|
|
54
|
-
this._checkToken(req,
|
|
51
|
+
this._checkToken(req, this.cookie.getToken())
|
|
55
52
|
const requestConfig = this._createConfig(req, cancelToken)
|
|
56
53
|
const { data } = await this.axios.request(requestConfig)
|
|
57
54
|
return data
|
|
@@ -73,7 +70,15 @@ export default class Request {
|
|
|
73
70
|
}
|
|
74
71
|
|
|
75
72
|
_createConfig(req, cancelToken) {
|
|
76
|
-
const { method, url, params, isPublic, isFormData
|
|
73
|
+
const { method, url, params, isPublic, isFormData } = req
|
|
74
|
+
// const config = { baseURL: this.config.fullURL, method, url, cancelToken, isPublic: req.isPublic }
|
|
75
|
+
// if (method.toUpperCase() === 'GET') {
|
|
76
|
+
// config.params = pickBy(params, isValid)
|
|
77
|
+
// } else {
|
|
78
|
+
// config.data = pickBy(params, isValid)
|
|
79
|
+
// }
|
|
80
|
+
// return config
|
|
81
|
+
|
|
77
82
|
if (isFormData) {
|
|
78
83
|
return {
|
|
79
84
|
baseURL: this.config.fullURL,
|
|
@@ -91,7 +96,6 @@ export default class Request {
|
|
|
91
96
|
url,
|
|
92
97
|
cancelToken,
|
|
93
98
|
isPublic,
|
|
94
|
-
headers,
|
|
95
99
|
[method.toUpperCase() === 'GET' ? 'params' : 'data']: pickBy(params, isValid),
|
|
96
100
|
}
|
|
97
101
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
mode: 'production',
|
|
5
|
+
entry: {
|
|
6
|
+
main: './src/index.js',
|
|
7
|
+
},
|
|
8
|
+
output: {
|
|
9
|
+
filename: 'index.js',
|
|
10
|
+
path: path.resolve(__dirname, 'dist'),
|
|
11
|
+
clean: true,
|
|
12
|
+
library: {
|
|
13
|
+
type: 'module',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
experiments: {
|
|
17
|
+
outputModule: true,
|
|
18
|
+
},
|
|
19
|
+
module: {
|
|
20
|
+
rules: [
|
|
21
|
+
{
|
|
22
|
+
test: /\.m?js$/,
|
|
23
|
+
exclude: /node_modules/,
|
|
24
|
+
use: {
|
|
25
|
+
loader: 'babel-loader',
|
|
26
|
+
options: {
|
|
27
|
+
presets: [['@babel/preset-env', { targets: 'defaults' }]],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
}
|
package/.husky/pre-commit
DELETED