@jetthai/cuora 1.0.204 → 1.0.302-dev-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 (110) hide show
  1. package/.husky/pre-commit +4 -0
  2. package/.prettierignore +1 -0
  3. package/CHANGELOG.md +848 -0
  4. package/README.md +6 -0
  5. package/package.json +6 -9
  6. package/src/api/activity.js +43 -2
  7. package/src/api/auth.js +22 -7
  8. package/src/api/common.js +3 -1
  9. package/src/api/game.js +20 -7
  10. package/src/api/mailbox.js +9 -5
  11. package/src/api/payment.js +167 -19
  12. package/src/api/user.js +7 -0
  13. package/src/lib/fingerprint.js +9779 -0
  14. package/src/machine/activity/activity.js +111 -26
  15. package/src/machine/activity/activity_cash.js +159 -0
  16. package/src/machine/activity/cash_rain_activity.js +153 -0
  17. package/src/machine/activity/continue_deposit_activity.js +11 -2
  18. package/src/machine/activity/deposit_activity.js +13 -4
  19. package/src/machine/activity/diamond_shop_activity_cash.js +179 -0
  20. package/src/machine/activity/diamond_shop_activity_vn.js +54 -89
  21. package/src/machine/activity/fafafa_activity.js +34 -19
  22. package/src/machine/activity/{affiliate_invite_friends_activity.js → friend_invite_friends_activity.js} +72 -45
  23. package/src/machine/activity/index.js +22 -4
  24. package/src/machine/activity/instant_rebate_activity.js +217 -0
  25. package/src/machine/activity/invite_friends_activity.js +14 -14
  26. package/src/machine/activity/jackpot.js +74 -0
  27. package/src/machine/activity/otp_verified_activity.js +74 -0
  28. package/src/machine/activity/ranking_activity.js +11 -2
  29. package/src/machine/activity/roulette_activity_v2.js +90 -0
  30. package/src/machine/activity/sign_in_activity.js +21 -14
  31. package/src/machine/activity/sign_in_monthly_activity.js +65 -0
  32. package/src/machine/activity/specify_bets_activity.js +25 -3
  33. package/src/machine/activity/specify_turnover_activity.js +25 -3
  34. package/src/machine/activity/time_bomb_activity.js +11 -2
  35. package/src/machine/activity/vip_card_activity.js +140 -0
  36. package/src/machine/auth.js +141 -27
  37. package/src/machine/auth_otp_v2.js +10 -4
  38. package/src/machine/auth_otp_v3.js +11 -3
  39. package/src/machine/bank_binding.js +112 -12
  40. package/src/machine/bank_binding_amb.js +145 -0
  41. package/src/machine/common.js +113 -25
  42. package/src/machine/deposit/amb.js +92 -0
  43. package/src/machine/deposit/crypto.js +50 -29
  44. package/src/machine/deposit/crypto_bank.js +317 -0
  45. package/src/machine/deposit/crypto_bank_cash.js +287 -0
  46. package/src/machine/deposit/crypto_button.js +174 -39
  47. package/src/machine/deposit/crypto_cash.js +255 -0
  48. package/src/machine/deposit/crypto_qrcode.js +148 -0
  49. package/src/machine/deposit/crypto_qrcode_cash.js +131 -0
  50. package/src/machine/deposit/crypto_way.js +239 -0
  51. package/src/machine/deposit/crypto_way_cash.js +256 -0
  52. package/src/machine/deposit/deposit_fc.js +8 -5
  53. package/src/machine/deposit/direct.js +111 -16
  54. package/src/machine/deposit/direct_cash.js +217 -0
  55. package/src/machine/deposit/float.js +366 -0
  56. package/src/machine/deposit/index.js +43 -2
  57. package/src/machine/deposit/krway.js +151 -0
  58. package/src/machine/deposit/loadcard_cash.js +207 -0
  59. package/src/machine/deposit/loadcard_vn.js +191 -43
  60. package/src/machine/deposit/manual_cash.js +356 -0
  61. package/src/machine/deposit/manual_vn.js +182 -60
  62. package/src/machine/deposit/qrcode_cash.js +217 -0
  63. package/src/machine/deposit/qrcode_v2.js +285 -52
  64. package/src/machine/deposit/usdt.js +144 -0
  65. package/src/machine/deposit/usdt_cash.js +138 -0
  66. package/src/machine/deposit/vpay.js +359 -0
  67. package/src/machine/game_favorite_v2.js +70 -28
  68. package/src/machine/game_info.js +57 -0
  69. package/src/machine/game_search_cash.js +390 -0
  70. package/src/machine/game_search_v2.js +64 -24
  71. package/src/machine/game_v2_1.js +662 -0
  72. package/src/machine/honor_board_cash.js +63 -0
  73. package/src/machine/inbox.js +259 -34
  74. package/src/machine/index.js +24 -17
  75. package/src/machine/leaderboard.js +31 -8
  76. package/src/machine/navbar.js +57 -0
  77. package/src/machine/promotions.js +171 -0
  78. package/src/machine/reward.js +74 -7
  79. package/src/machine/reward_cash.js +219 -0
  80. package/src/machine/roulette_v2.js +276 -0
  81. package/src/machine/setting.js +5 -2
  82. package/src/machine/side_cash.js +110 -0
  83. package/src/machine/side_v2.js +33 -28
  84. package/src/machine/user_photo.js +65 -0
  85. package/src/machine/user_sign_up.js +117 -17
  86. package/src/machine/withdraw/index.js +23 -0
  87. package/src/machine/{withdraw_vn.js → withdraw/withdraw_amb.js} +146 -78
  88. package/src/machine/{withdraw_crypto.js → withdraw/withdraw_crypto.js} +220 -69
  89. package/src/machine/withdraw/withdraw_crypto2.js +540 -0
  90. package/src/machine/withdraw/withdraw_crypto_cash.js +319 -0
  91. package/src/machine/{withdraw_fc.js → withdraw/withdraw_fc.js} +2 -2
  92. package/src/machine/withdraw/withdraw_krway.js +207 -0
  93. package/src/machine/withdraw/withdraw_manual.js +595 -0
  94. package/src/machine/withdraw/withdraw_manual_cash.js +303 -0
  95. package/src/machine/withdraw/withdraw_vn.js +533 -0
  96. package/src/machine/withdraw/withdraw_vn2.js +548 -0
  97. package/src/request/request.js +10 -5
  98. package/src/util/constant.js +19 -1
  99. package/src/util/deviceToken.js +18 -8
  100. package/src/util/index.js +2 -1
  101. package/src/util/math.js +4 -0
  102. package/src/util/storage.js +22 -22
  103. package/dist/bundle.mjs +0 -18462
  104. package/rollup.config.js +0 -16
  105. package/src/machine/auth_otp.js +0 -201
  106. package/src/machine/deposit/qrcode_vn.js +0 -206
  107. package/src/machine/game.js +0 -285
  108. package/src/machine/game_favorite.js +0 -123
  109. package/src/machine/game_search.js +0 -244
  110. package/src/machine/game_v2.js +0 -356
@@ -0,0 +1,533 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import findLastIndex from 'lodash/findLastIndex.js'
3
+ import payment from '../../api/payment.js'
4
+ import common from '../../api/common.js'
5
+ import user from '../../api/user.js'
6
+
7
+ export default function (request) {
8
+ const { appSecret } = request.config
9
+ return createMachine(
10
+ {
11
+ id: 'withdraw_vn',
12
+ initial: 'loading',
13
+ context: {
14
+ siteConfig: null,
15
+ userInfo: null,
16
+ balance: null,
17
+ charge: null,
18
+ realAmount: null,
19
+ applyId: null,
20
+ methods: [],
21
+ paymentDetail: [],
22
+ bankInfo: [],
23
+ bankList: [],
24
+ withdrawLimit: null,
25
+ targetWithdrawLimit: null,
26
+ attachmentType: null, // null | 'withdraw' | 'pool'
27
+ maximumWithdrawAmount: 0,
28
+ enableWithdrawAmount: 0,
29
+ enableWithdraw: false,
30
+ withdrawRules: [],
31
+ withdrawCheck: null,
32
+
33
+ amount: null,
34
+ bank: null,
35
+ branch: null,
36
+ accountNumber: null,
37
+ holderName: null,
38
+
39
+ // otp
40
+ requestId: null,
41
+ status: null,
42
+ target: null,
43
+ ttl: null,
44
+ },
45
+ states: {
46
+ loading: {
47
+ invoke: {
48
+ src: 'fetchInitData',
49
+ onDone: {
50
+ target: 'mode',
51
+ actions: ['setInitData', 'preset', 'updateWithdrawCondition'],
52
+ },
53
+ onError: {
54
+ target: 'fail',
55
+ },
56
+ },
57
+ },
58
+ mode: {
59
+ always: [{ target: 'free', cond: 'isFree' }, { target: 'cash' }],
60
+ },
61
+ free: {
62
+ initial: 'checking',
63
+ states: {
64
+ // loading: {
65
+ // invoke: {
66
+ // src: 'fetchWithdrawRules',
67
+ // onDone: {
68
+ // target: 'checking',
69
+ // actions: 'updateWithdrawCondition',
70
+ // },
71
+ // onError: {
72
+ // target: 'notConvertible',
73
+ // },
74
+ // },
75
+ // },
76
+ checking: {
77
+ always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
78
+ },
79
+ notConvertible: {
80
+ on: {
81
+ GIVE_UP: {
82
+ target: 'givingUp',
83
+ },
84
+ },
85
+ },
86
+ givingUp: {
87
+ invoke: {
88
+ src: 'giveUp',
89
+ onDone: {
90
+ target: 'gaveUp',
91
+ },
92
+ onError: {
93
+ target: 'convertible',
94
+ },
95
+ },
96
+ },
97
+ gaveUp: {},
98
+ convertible: {
99
+ on: {
100
+ SUBMIT: {
101
+ target: 'converting',
102
+ actions: 'setAttachmentType',
103
+ },
104
+ },
105
+ },
106
+ converting: {
107
+ invoke: {
108
+ src: 'convertFreeCredit',
109
+ onDone: [
110
+ {
111
+ target: '#withdraw_vn.otp',
112
+ actions: 'setOtp',
113
+ cond: 'isOtpRequired',
114
+ },
115
+ { target: 'converted' },
116
+ ],
117
+ onError: {
118
+ target: 'convertible',
119
+ },
120
+ },
121
+ },
122
+ converted: {
123
+ always: [
124
+ { target: '#withdraw_vn.cash.unbound', cond: 'isBankNotBound' },
125
+ { target: '#withdraw_vn.cash.withdrawable', cond: 'hasAttachmentType' },
126
+ ],
127
+ },
128
+ },
129
+ },
130
+ cash: {
131
+ initial: 'checking',
132
+ states: {
133
+ checking: {
134
+ always: [
135
+ { target: 'inProcessing', cond: 'haveProcessing' },
136
+ { target: 'unbound', cond: 'isBankNotBound' },
137
+ { target: 'withdrawCheck' },
138
+ ],
139
+ },
140
+ withdrawCheck: {
141
+ invoke: {
142
+ src: 'withdrawCheck',
143
+ onDone: [
144
+ {
145
+ target: 'notWithdrawMinDepositAmount',
146
+ cond: 'isNotWithdrawMinDepositAmount',
147
+ actions: assign((context, event) => {
148
+ return {
149
+ withdrawCheck: event.data,
150
+ }
151
+ }),
152
+ },
153
+ {
154
+ target: 'notWithdrawable',
155
+ cond: 'isNotWithdrawable',
156
+ },
157
+ {
158
+ target: 'withdrawable',
159
+ },
160
+ ],
161
+ onError: {
162
+ target: '#withdraw_vn.fail',
163
+ },
164
+ },
165
+ },
166
+ notWithdrawMinDepositAmount: {},
167
+ notWithdrawable: {},
168
+ unbound: {
169
+ // to bank_binding.js
170
+ },
171
+ inProcessing: {},
172
+ withdrawable: {
173
+ on: {
174
+ SET_CURRENT_BANK: {
175
+ actions: assign((context, event) => {
176
+ return {
177
+ bank: event.data,
178
+ }
179
+ }),
180
+ },
181
+ SET_AMOUNT: {
182
+ actions: assign((context, event) => {
183
+ return {
184
+ amount: event.data,
185
+ }
186
+ }),
187
+ },
188
+ SET_ATTACHMENT_TYPE: {
189
+ actions: 'setAttachmentType',
190
+ cond: 'isNewWalletMode',
191
+ },
192
+ SUBMIT: [
193
+ {
194
+ target: 'pooling',
195
+ cond: (context, event) => {
196
+ const { amount, attachmentType } = context
197
+ return attachmentType === 'pool' && amount > 0
198
+ },
199
+ },
200
+ {
201
+ target: 'submitting',
202
+ cond: 'isSubmittable',
203
+ },
204
+ ],
205
+ },
206
+ },
207
+ submitting: {
208
+ invoke: {
209
+ src: 'submitWithdraw',
210
+ onDone: [
211
+ {
212
+ target: '#withdraw_vn.otp',
213
+ actions: 'setOtp',
214
+ cond: 'isOtpRequired',
215
+ },
216
+ {
217
+ target: 'submitted',
218
+ },
219
+ ],
220
+ onError: {
221
+ target: 'withdrawable',
222
+ },
223
+ },
224
+ },
225
+ submitted: {
226
+ entry: assign((context, event) => {
227
+ const { applyId, balance, realAmount, charge } = event.data
228
+ return { applyId, balance, realAmount, charge }
229
+ }),
230
+ invoke: {
231
+ src: 'fetchPaymentData',
232
+ onDone: {
233
+ target: 'inProcessing',
234
+ actions: 'setPaymentData',
235
+ },
236
+ onError: {
237
+ target: '#withdraw_vn.fail',
238
+ },
239
+ },
240
+ },
241
+ pooling: {
242
+ invoke: {
243
+ src: 'pool',
244
+ onDone: { target: 'pooled' },
245
+ onError: {
246
+ target: 'withdrawable',
247
+ },
248
+ },
249
+ },
250
+ pooled: {},
251
+ },
252
+ },
253
+ otp: {
254
+ type: 'parallel',
255
+ states: {
256
+ countdown: {
257
+ after: {
258
+ 1000: {
259
+ target: 'countdown',
260
+ actions: 'decreaseTtl',
261
+ cond: (context) => context.ttl > 0,
262
+ },
263
+ },
264
+ },
265
+ verification: {
266
+ initial: 'idle',
267
+ states: {
268
+ idle: {
269
+ on: {
270
+ ACKNOWLEDGE: {
271
+ target: 'acknowledging',
272
+ },
273
+ RESET_OTP: {
274
+ target: 'reset',
275
+ },
276
+ BACK: [
277
+ {
278
+ target: '#withdraw_vn.free.convertible',
279
+ cond: 'isFree',
280
+ },
281
+ {
282
+ target: '#withdraw_vn.cash.withdrawable',
283
+ },
284
+ ],
285
+ },
286
+ },
287
+ acknowledging: {
288
+ invoke: {
289
+ src: 'acknowledge',
290
+ onDone: [
291
+ {
292
+ target: '#withdraw_vn.free.converted',
293
+ cond: 'isFree',
294
+ },
295
+ {
296
+ target: '#withdraw_vn.cash.submitted',
297
+ },
298
+ ],
299
+ onError: {
300
+ target: 'idle',
301
+ },
302
+ },
303
+ },
304
+ reset: {
305
+ invoke: {
306
+ src: 'resetOtp',
307
+ onDone: {
308
+ target: 'idle',
309
+ actions: 'setVerificationData',
310
+ },
311
+ onError: { target: 'idle' },
312
+ },
313
+ },
314
+ },
315
+ },
316
+ },
317
+ },
318
+ fail: {},
319
+ },
320
+ on: {
321
+ REFRESH: {
322
+ target: 'loading',
323
+ },
324
+ },
325
+ },
326
+ {
327
+ actions: {
328
+ setInitData: assign((context, event) => {
329
+ return {
330
+ paymentDetail: event.data.paymentDetail,
331
+ bankInfo: event.data.bankInfo,
332
+ bank: event.data.bankInfo[0],
333
+ bonus: event.data.bonus,
334
+ bankList: event.data.bankList,
335
+ }
336
+ }),
337
+ setPaymentData: assign((context, event) => {
338
+ return {
339
+ bankInfo: event.data.bankInfo,
340
+ bonus: event.data.bonus,
341
+ paymentDetail: event.data.paymentDetail,
342
+ }
343
+ }),
344
+ preset: assign((context, event) => {
345
+ const { userInfo, siteConfig } = event.data
346
+ const { withdraw_limit, target_withdraw_limit } = userInfo || {}
347
+ const balance = parseFloat(userInfo?.balance)
348
+ const methods = siteConfig?.paymentMethods?.withdraw || []
349
+ return {
350
+ withdrawLimit: Math.abs(withdraw_limit),
351
+ targetWithdrawLimit: Math.abs(target_withdraw_limit),
352
+ methods,
353
+ balance,
354
+ siteConfig,
355
+ userInfo,
356
+ attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
357
+ }
358
+ }),
359
+ updateWithdrawCondition: assign((context, event) => {
360
+ const { differAmountLimit, enableWithdraw, enableWithdrawAmount, maxWithdrawStatus, maximumWithdrawAmount, minimumWithdrawAmount } =
361
+ event.data?.withdrawRule
362
+
363
+ const withdrawRules = event.data?.withdrawRule?.rules || []
364
+ const rules = withdrawRules.filter((rule) => rule.maxWithdrawAmount > 0)
365
+
366
+ const { balance } = context
367
+ const lastMatchedIndex = findLastIndex(rules, (rule) => balance >= rule.greaterEqualThen)
368
+
369
+ let maxWithdrawAmount = 0
370
+
371
+ if (lastMatchedIndex > -1) {
372
+ rules[lastMatchedIndex].match = true
373
+ maxWithdrawAmount = rules[lastMatchedIndex].maxWithdrawAmount
374
+ } else if (rules.length > 0) {
375
+ maxWithdrawAmount = rules[0].maxWithdrawAmount
376
+ } else {
377
+ maxWithdrawAmount = balance
378
+ }
379
+
380
+ return {
381
+ maxWithdrawAmount,
382
+ enableWithdrawAmount: +enableWithdrawAmount,
383
+ enableWithdraw,
384
+ withdrawRules,
385
+ }
386
+ }),
387
+ setOtp: assign((context, event) => {
388
+ const { requestId, status, target, ttl } = event.data
389
+ return {
390
+ requestId,
391
+ status,
392
+ target,
393
+ ttl,
394
+ }
395
+ }),
396
+ decreaseTtl: assign((context, evnet) => {
397
+ const second = context.ttl
398
+ return {
399
+ ttl: Math.max(second - 1, 0),
400
+ }
401
+ }),
402
+ setVerificationData: assign((context, event) => {
403
+ const { requestId, ttl, target } = event.data
404
+ return {
405
+ requestId,
406
+ ttl,
407
+ target,
408
+ }
409
+ }),
410
+ setAttachmentType: assign((context, event) => {
411
+ return {
412
+ attachmentType: event.data,
413
+ }
414
+ }),
415
+ },
416
+ guards: {
417
+ isFree: (context, event) => {
418
+ return context.userInfo?.withdraw_rule !== 'DEFAULT'
419
+ },
420
+ hasAttachmentType: (context, event) => {
421
+ return ['withdraw', 'pool'].includes(context.attachmentType)
422
+ },
423
+ haveProcessing: (context, event) => {
424
+ return (context.paymentDetail?.[0]?.processing || []).length > 0
425
+ },
426
+ isWithdrawDisable: (context, event) => {
427
+ const { siteConfig } = context
428
+ const methods = siteConfig?.paymentMethods?.withdraw || []
429
+ return methods.length === 0
430
+ },
431
+ isBankNotBound: (context, event) => {
432
+ return !context.bankInfo?.length
433
+ },
434
+ isSubmittable: (context, event) => {
435
+ const { bank, amount } = context
436
+ return bank && amount > 0
437
+ },
438
+ isConvertible: (context, event) => {
439
+ const { balance, enableWithdraw } = context
440
+ return balance > 0 && enableWithdraw
441
+ },
442
+ isNotWithdrawable: (context, event) => {
443
+ const { balance, enableWithdraw, paymentDetail } = context
444
+ const minWithdrawAmount = paymentDetail[0]?.minimum || 0
445
+ return !enableWithdraw || balance < minWithdrawAmount
446
+ },
447
+ isOtpRequired: (context, event) => {
448
+ return event.data?.status === 'otp-verifying'
449
+ },
450
+ isNewWalletMode: (context, event) => context.siteConfig.walletMode > 0,
451
+ isNotWithdrawMinDepositAmount: (context, event) => {
452
+ return !event.data?.enableWithdraw
453
+ },
454
+ },
455
+ services: {
456
+ fetchInitData: async (context, event) => {
457
+ const [{ config }, userInfo, paymentDetail = [], { bonus, bankInfo }, withdrawRule] = await Promise.all([
458
+ request.send(common.getConfig({ appSecret })),
459
+ request.send(user.getUserInfo()),
460
+ request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' })),
461
+ request.send(payment.getPaymentInfo()),
462
+ request.send(payment.getCurrentWithdrawRule()),
463
+ ])
464
+ const siteConfig = JSON.parse(window.atob(config))
465
+ const bankList = await request.send(payment.getWithdrawBankList())
466
+ const newBankInfo = bankInfo
467
+ .map((item) => {
468
+ const matchedBank = bankList.find((bank) => bank.bankCode === item.bankCode)
469
+ return matchedBank ? { ...item, ...matchedBank } : null
470
+ })
471
+ .filter(Boolean)
472
+ return { siteConfig, userInfo, paymentDetail, bonus, bankInfo: newBankInfo, bankList, withdrawRule }
473
+ },
474
+ fetchPaymentData: async (context, event) => {
475
+ const paymentDetail = await request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' }))
476
+ const { bonus, bankInfo } = await request.send(payment.getPaymentInfo())
477
+ return { bonus, bankInfo, paymentDetail }
478
+ },
479
+ updatePaymentInfo: async (context, event) => {
480
+ const { bank, branch, accountNumber, holderName } = context
481
+ return await request.send(
482
+ payment.updatePaymentInfo({
483
+ bankCode: bank.bankCode,
484
+ branch,
485
+ bankAccount: accountNumber,
486
+ holderName,
487
+ })
488
+ )
489
+ },
490
+ fetchWithdrawRules: async (context, event) => {
491
+ return await request.send(payment.getCurrentWithdrawRule())
492
+ },
493
+ submitWithdraw: async (context, event) => {
494
+ const { bank, amount } = context
495
+ const { method } = context.paymentDetail[0]
496
+ const branchTemp = ['GCASH', 'PAYM', 'PIX'].includes(bank.bankCode) ? '' : bank.branch
497
+ return await request.send(
498
+ payment.submitWithdrawTransactionVN({
499
+ method,
500
+ amount,
501
+ applyerBankCode: bank.bankCode,
502
+ applyerAccountNumber: bank.accountNumber,
503
+ branch: branchTemp,
504
+ holderName: bank.holderName,
505
+ })
506
+ )
507
+ },
508
+ convertFreeCredit: async (context, event) => {
509
+ return await request.send(payment.convertFreeCredit({ exchangeType: 1 }))
510
+ },
511
+ resetOtp: async (context, event) => {
512
+ const { requestId, target } = context
513
+ return await request.send(user.otpReset({ requestId, target }))
514
+ },
515
+ acknowledge: async (context, event) => {
516
+ const { requestId, target } = context
517
+ const code = event.data
518
+ return await request.send(user.otpAcknowledge({ requestId, target, code }))
519
+ },
520
+ pool: async (context, event) => {
521
+ const { amount } = context
522
+ return await request.send(payment.restore({ amount }))
523
+ },
524
+ giveUp: async (context, event) => {
525
+ return await request.send(payment.giveUp())
526
+ },
527
+ withdrawCheck: async (context, event) => {
528
+ return await request.send(payment.withdrawCheck())
529
+ },
530
+ },
531
+ }
532
+ )
533
+ }