@jetthai/cuora 1.0.302-sl-2 → 1.1.0

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/CHANGELOG.md +3 -848
  2. package/README.md +0 -6
  3. package/dist/bundle.mjs +18461 -0
  4. package/package.json +9 -6
  5. package/rollup.config.js +16 -0
  6. package/src/api/activity.js +2 -43
  7. package/src/api/auth.js +7 -22
  8. package/src/api/common.js +1 -3
  9. package/src/api/game.js +7 -20
  10. package/src/api/mailbox.js +5 -9
  11. package/src/api/payment.js +19 -167
  12. package/src/api/user.js +0 -7
  13. package/src/machine/activity/activity.js +26 -111
  14. package/src/machine/activity/{friend_invite_friends_activity.js → affiliate_invite_friends_activity.js} +41 -70
  15. package/src/machine/activity/continue_deposit_activity.js +2 -11
  16. package/src/machine/activity/deposit_activity.js +4 -13
  17. package/src/machine/activity/diamond_shop_activity_vn.js +89 -54
  18. package/src/machine/activity/fafafa_activity.js +19 -34
  19. package/src/machine/activity/index.js +4 -22
  20. package/src/machine/activity/invite_friends_activity.js +14 -14
  21. package/src/machine/activity/ranking_activity.js +2 -11
  22. package/src/machine/activity/sign_in_activity.js +14 -21
  23. package/src/machine/activity/specify_bets_activity.js +3 -25
  24. package/src/machine/activity/specify_turnover_activity.js +3 -25
  25. package/src/machine/activity/time_bomb_activity.js +2 -11
  26. package/src/machine/auth.js +21 -134
  27. package/src/machine/auth_otp.js +201 -0
  28. package/src/machine/auth_otp_v2.js +4 -10
  29. package/src/machine/auth_otp_v3.js +3 -11
  30. package/src/machine/bank_binding.js +12 -112
  31. package/src/machine/common.js +25 -113
  32. package/src/machine/deposit/crypto.js +29 -50
  33. package/src/machine/deposit/crypto_button.js +39 -174
  34. package/src/machine/deposit/deposit_fc.js +5 -8
  35. package/src/machine/deposit/direct.js +16 -111
  36. package/src/machine/deposit/index.js +2 -43
  37. package/src/machine/deposit/loadcard_vn.js +43 -191
  38. package/src/machine/deposit/manual_vn.js +60 -182
  39. package/src/machine/deposit/qrcode_v2.js +52 -285
  40. package/src/machine/deposit/qrcode_vn.js +206 -0
  41. package/src/machine/game.js +285 -0
  42. package/src/machine/game_favorite.js +123 -0
  43. package/src/machine/game_favorite_v2.js +28 -74
  44. package/src/machine/game_search.js +244 -0
  45. package/src/machine/game_search_v2.js +24 -64
  46. package/src/machine/game_v2.js +356 -0
  47. package/src/machine/inbox.js +34 -259
  48. package/src/machine/index.js +17 -24
  49. package/src/machine/leaderboard.js +8 -31
  50. package/src/machine/reward.js +7 -74
  51. package/src/machine/setting.js +2 -5
  52. package/src/machine/side_v2.js +28 -33
  53. package/src/machine/user_sign_up.js +17 -117
  54. package/src/machine/{withdraw/withdraw_crypto.js → withdraw_crypto.js} +69 -220
  55. package/src/machine/{withdraw/withdraw_fc.js → withdraw_fc.js} +2 -2
  56. package/src/machine/{withdraw/withdraw_amb.js → withdraw_vn.js} +78 -146
  57. package/src/request/request.js +5 -10
  58. package/src/util/constant.js +1 -19
  59. package/src/util/deviceToken.js +8 -18
  60. package/src/util/index.js +1 -2
  61. package/src/util/storage.js +22 -22
  62. package/.husky/pre-commit +0 -4
  63. package/.prettierignore +0 -1
  64. package/src/lib/fingerprint.js +0 -9779
  65. package/src/machine/activity/activity_cash.js +0 -159
  66. package/src/machine/activity/cash_rain_activity.js +0 -153
  67. package/src/machine/activity/diamond_shop_activity_cash.js +0 -179
  68. package/src/machine/activity/instant_rebate_activity.js +0 -217
  69. package/src/machine/activity/jackpot.js +0 -74
  70. package/src/machine/activity/otp_verified_activity.js +0 -74
  71. package/src/machine/activity/roulette_activity_v2.js +0 -90
  72. package/src/machine/activity/sign_in_monthly_activity.js +0 -65
  73. package/src/machine/activity/vip_card_activity.js +0 -140
  74. package/src/machine/bank_binding_amb.js +0 -145
  75. package/src/machine/deposit/amb.js +0 -92
  76. package/src/machine/deposit/crypto_bank.js +0 -317
  77. package/src/machine/deposit/crypto_bank_cash.js +0 -287
  78. package/src/machine/deposit/crypto_cash.js +0 -255
  79. package/src/machine/deposit/crypto_qrcode.js +0 -148
  80. package/src/machine/deposit/crypto_qrcode_cash.js +0 -131
  81. package/src/machine/deposit/crypto_way.js +0 -239
  82. package/src/machine/deposit/crypto_way_cash.js +0 -256
  83. package/src/machine/deposit/direct_cash.js +0 -217
  84. package/src/machine/deposit/float.js +0 -366
  85. package/src/machine/deposit/krway.js +0 -151
  86. package/src/machine/deposit/loadcard_cash.js +0 -207
  87. package/src/machine/deposit/manual_cash.js +0 -356
  88. package/src/machine/deposit/qrcode_cash.js +0 -217
  89. package/src/machine/deposit/usdt.js +0 -144
  90. package/src/machine/deposit/usdt_cash.js +0 -138
  91. package/src/machine/deposit/vpay.js +0 -359
  92. package/src/machine/game_info.js +0 -57
  93. package/src/machine/game_search_cash.js +0 -390
  94. package/src/machine/game_v2_1.js +0 -662
  95. package/src/machine/honor_board_cash.js +0 -63
  96. package/src/machine/navbar.js +0 -57
  97. package/src/machine/promotions.js +0 -171
  98. package/src/machine/reward_cash.js +0 -219
  99. package/src/machine/roulette_v2.js +0 -276
  100. package/src/machine/side_cash.js +0 -110
  101. package/src/machine/user_photo.js +0 -65
  102. package/src/machine/withdraw/index.js +0 -23
  103. package/src/machine/withdraw/withdraw_crypto2.js +0 -540
  104. package/src/machine/withdraw/withdraw_crypto_cash.js +0 -319
  105. package/src/machine/withdraw/withdraw_krway.js +0 -207
  106. package/src/machine/withdraw/withdraw_manual.js +0 -595
  107. package/src/machine/withdraw/withdraw_manual_cash.js +0 -303
  108. package/src/machine/withdraw/withdraw_vn.js +0 -533
  109. package/src/machine/withdraw/withdraw_vn2.js +0 -548
  110. package/src/util/math.js +0 -4
@@ -1,533 +0,0 @@
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
- }