@jetthai/cuora 1.0.307-dev-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 (111) hide show
  1. package/CHANGELOG.md +3 -854
  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 -146
  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 -26
  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 -195
  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.js +0 -118
  96. package/src/machine/honor_board_cash.js +0 -89
  97. package/src/machine/navbar.js +0 -57
  98. package/src/machine/promotions.js +0 -171
  99. package/src/machine/reward_cash.js +0 -219
  100. package/src/machine/roulette_v2.js +0 -276
  101. package/src/machine/side_cash.js +0 -110
  102. package/src/machine/user_photo.js +0 -65
  103. package/src/machine/withdraw/index.js +0 -23
  104. package/src/machine/withdraw/withdraw_crypto2.js +0 -540
  105. package/src/machine/withdraw/withdraw_crypto_cash.js +0 -319
  106. package/src/machine/withdraw/withdraw_krway.js +0 -220
  107. package/src/machine/withdraw/withdraw_manual.js +0 -610
  108. package/src/machine/withdraw/withdraw_manual_cash.js +0 -303
  109. package/src/machine/withdraw/withdraw_vn.js +0 -546
  110. package/src/machine/withdraw/withdraw_vn2.js +0 -561
  111. package/src/util/math.js +0 -4
@@ -1,546 +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: 'passWithdrawCooldownTime',
155
- cond: 'isPassWithdrawCooldownTime',
156
- actions: assign((context, event) => {
157
- return {
158
- withdrawCheck: event.data,
159
- }
160
- }),
161
- },
162
- {
163
- target: 'notWithdrawable',
164
- cond: 'isNotWithdrawable',
165
- },
166
- {
167
- target: 'withdrawable',
168
- },
169
- ],
170
- onError: {
171
- target: '#withdraw_vn.fail',
172
- },
173
- },
174
- },
175
- notWithdrawMinDepositAmount: {},
176
- passWithdrawCooldownTime: {},
177
- notWithdrawable: {},
178
- unbound: {
179
- // to bank_binding.js
180
- },
181
- inProcessing: {},
182
- withdrawable: {
183
- on: {
184
- SET_CURRENT_BANK: {
185
- actions: assign((context, event) => {
186
- return {
187
- bank: event.data,
188
- }
189
- }),
190
- },
191
- SET_AMOUNT: {
192
- actions: assign((context, event) => {
193
- return {
194
- amount: event.data,
195
- }
196
- }),
197
- },
198
- SET_ATTACHMENT_TYPE: {
199
- actions: 'setAttachmentType',
200
- cond: 'isNewWalletMode',
201
- },
202
- SUBMIT: [
203
- {
204
- target: 'pooling',
205
- cond: (context, event) => {
206
- const { amount, attachmentType } = context
207
- return attachmentType === 'pool' && amount > 0
208
- },
209
- },
210
- {
211
- target: 'submitting',
212
- cond: 'isSubmittable',
213
- },
214
- ],
215
- },
216
- },
217
- submitting: {
218
- invoke: {
219
- src: 'submitWithdraw',
220
- onDone: [
221
- {
222
- target: '#withdraw_vn.otp',
223
- actions: 'setOtp',
224
- cond: 'isOtpRequired',
225
- },
226
- {
227
- target: 'submitted',
228
- },
229
- ],
230
- onError: {
231
- target: 'withdrawable',
232
- },
233
- },
234
- },
235
- submitted: {
236
- entry: assign((context, event) => {
237
- const { applyId, balance, realAmount, charge } = event.data
238
- return { applyId, balance, realAmount, charge }
239
- }),
240
- invoke: {
241
- src: 'fetchPaymentData',
242
- onDone: {
243
- target: 'inProcessing',
244
- actions: 'setPaymentData',
245
- },
246
- onError: {
247
- target: '#withdraw_vn.fail',
248
- },
249
- },
250
- },
251
- pooling: {
252
- invoke: {
253
- src: 'pool',
254
- onDone: { target: 'pooled' },
255
- onError: {
256
- target: 'withdrawable',
257
- },
258
- },
259
- },
260
- pooled: {},
261
- },
262
- },
263
- otp: {
264
- type: 'parallel',
265
- states: {
266
- countdown: {
267
- after: {
268
- 1000: {
269
- target: 'countdown',
270
- actions: 'decreaseTtl',
271
- cond: (context) => context.ttl > 0,
272
- },
273
- },
274
- },
275
- verification: {
276
- initial: 'idle',
277
- states: {
278
- idle: {
279
- on: {
280
- ACKNOWLEDGE: {
281
- target: 'acknowledging',
282
- },
283
- RESET_OTP: {
284
- target: 'reset',
285
- },
286
- BACK: [
287
- {
288
- target: '#withdraw_vn.free.convertible',
289
- cond: 'isFree',
290
- },
291
- {
292
- target: '#withdraw_vn.cash.withdrawable',
293
- },
294
- ],
295
- },
296
- },
297
- acknowledging: {
298
- invoke: {
299
- src: 'acknowledge',
300
- onDone: [
301
- {
302
- target: '#withdraw_vn.free.converted',
303
- cond: 'isFree',
304
- },
305
- {
306
- target: '#withdraw_vn.cash.submitted',
307
- },
308
- ],
309
- onError: {
310
- target: 'idle',
311
- },
312
- },
313
- },
314
- reset: {
315
- invoke: {
316
- src: 'resetOtp',
317
- onDone: {
318
- target: 'idle',
319
- actions: 'setVerificationData',
320
- },
321
- onError: { target: 'idle' },
322
- },
323
- },
324
- },
325
- },
326
- },
327
- },
328
- fail: {},
329
- },
330
- on: {
331
- REFRESH: {
332
- target: 'loading',
333
- },
334
- },
335
- },
336
- {
337
- actions: {
338
- setInitData: assign((context, event) => {
339
- return {
340
- paymentDetail: event.data.paymentDetail,
341
- bankInfo: event.data.bankInfo,
342
- bank: event.data.bankInfo[0],
343
- bonus: event.data.bonus,
344
- bankList: event.data.bankList,
345
- }
346
- }),
347
- setPaymentData: assign((context, event) => {
348
- return {
349
- bankInfo: event.data.bankInfo,
350
- bonus: event.data.bonus,
351
- paymentDetail: event.data.paymentDetail,
352
- }
353
- }),
354
- preset: assign((context, event) => {
355
- const { userInfo, siteConfig } = event.data
356
- const { withdraw_limit, target_withdraw_limit } = userInfo || {}
357
- const balance = parseFloat(userInfo?.balance)
358
- const methods = siteConfig?.paymentMethods?.withdraw || []
359
- return {
360
- withdrawLimit: Math.abs(withdraw_limit),
361
- targetWithdrawLimit: Math.abs(target_withdraw_limit),
362
- methods,
363
- balance,
364
- siteConfig,
365
- userInfo,
366
- attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
367
- }
368
- }),
369
- updateWithdrawCondition: assign((context, event) => {
370
- const { differAmountLimit, enableWithdraw, enableWithdrawAmount, maxWithdrawStatus, maximumWithdrawAmount, minimumWithdrawAmount } =
371
- event.data?.withdrawRule
372
-
373
- const withdrawRules = event.data?.withdrawRule?.rules || []
374
- const rules = withdrawRules.filter((rule) => rule.maxWithdrawAmount > 0)
375
-
376
- const { balance } = context
377
- const lastMatchedIndex = findLastIndex(rules, (rule) => balance >= rule.greaterEqualThen)
378
-
379
- let maxWithdrawAmount = 0
380
-
381
- if (lastMatchedIndex > -1) {
382
- rules[lastMatchedIndex].match = true
383
- maxWithdrawAmount = rules[lastMatchedIndex].maxWithdrawAmount
384
- } else if (rules.length > 0) {
385
- maxWithdrawAmount = rules[0].maxWithdrawAmount
386
- } else {
387
- maxWithdrawAmount = balance
388
- }
389
-
390
- return {
391
- maxWithdrawAmount,
392
- enableWithdrawAmount: +enableWithdrawAmount,
393
- enableWithdraw,
394
- withdrawRules,
395
- }
396
- }),
397
- setOtp: assign((context, event) => {
398
- const { requestId, status, target, ttl } = event.data
399
- return {
400
- requestId,
401
- status,
402
- target,
403
- ttl,
404
- }
405
- }),
406
- decreaseTtl: assign((context, evnet) => {
407
- const second = context.ttl
408
- return {
409
- ttl: Math.max(second - 1, 0),
410
- }
411
- }),
412
- setVerificationData: assign((context, event) => {
413
- const { requestId, ttl, target } = event.data
414
- return {
415
- requestId,
416
- ttl,
417
- target,
418
- }
419
- }),
420
- setAttachmentType: assign((context, event) => {
421
- return {
422
- attachmentType: event.data,
423
- }
424
- }),
425
- },
426
- guards: {
427
- isFree: (context, event) => {
428
- return context.userInfo?.withdraw_rule !== 'DEFAULT'
429
- },
430
- hasAttachmentType: (context, event) => {
431
- return ['withdraw', 'pool'].includes(context.attachmentType)
432
- },
433
- haveProcessing: (context, event) => {
434
- return (context.paymentDetail?.[0]?.processing || []).length > 0
435
- },
436
- isWithdrawDisable: (context, event) => {
437
- const { siteConfig } = context
438
- const methods = siteConfig?.paymentMethods?.withdraw || []
439
- return methods.length === 0
440
- },
441
- isBankNotBound: (context, event) => {
442
- return !context.bankInfo?.length
443
- },
444
- isSubmittable: (context, event) => {
445
- const { bank, amount } = context
446
- return bank && amount > 0
447
- },
448
- isConvertible: (context, event) => {
449
- const { balance, enableWithdraw } = context
450
- return balance > 0 && enableWithdraw
451
- },
452
- isNotWithdrawable: (context, event) => {
453
- const { balance, enableWithdraw, paymentDetail } = context
454
- const minWithdrawAmount = paymentDetail[0]?.minimum || 0
455
- return !enableWithdraw || balance < minWithdrawAmount
456
- },
457
- isOtpRequired: (context, event) => {
458
- return event.data?.status === 'otp-verifying'
459
- },
460
- isNewWalletMode: (context, event) => context.siteConfig.walletMode > 0,
461
- isNotWithdrawMinDepositAmount: (context, event) => {
462
- return !event.data?.passDepositeLimit
463
- },
464
- isPassWithdrawCooldownTime: (context, event) => {
465
- return !event.data?.passWithdrawCooldownTime
466
- },
467
- },
468
- services: {
469
- fetchInitData: async (context, event) => {
470
- const [{ config }, userInfo, paymentDetail = [], { bonus, bankInfo }, withdrawRule] = await Promise.all([
471
- request.send(common.getConfig({ appSecret })),
472
- request.send(user.getUserInfo()),
473
- request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' })),
474
- request.send(payment.getPaymentInfo()),
475
- request.send(payment.getCurrentWithdrawRule()),
476
- ])
477
- const siteConfig = JSON.parse(window.atob(config))
478
- const bankList = await request.send(payment.getWithdrawBankList())
479
- const newBankInfo = bankInfo
480
- .map((item) => {
481
- const matchedBank = bankList.find((bank) => bank.bankCode === item.bankCode)
482
- return matchedBank ? { ...item, ...matchedBank } : null
483
- })
484
- .filter(Boolean)
485
- return { siteConfig, userInfo, paymentDetail, bonus, bankInfo: newBankInfo, bankList, withdrawRule }
486
- },
487
- fetchPaymentData: async (context, event) => {
488
- const paymentDetail = await request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' }))
489
- const { bonus, bankInfo } = await request.send(payment.getPaymentInfo())
490
- return { bonus, bankInfo, paymentDetail }
491
- },
492
- updatePaymentInfo: async (context, event) => {
493
- const { bank, branch, accountNumber, holderName } = context
494
- return await request.send(
495
- payment.updatePaymentInfo({
496
- bankCode: bank.bankCode,
497
- branch,
498
- bankAccount: accountNumber,
499
- holderName,
500
- })
501
- )
502
- },
503
- fetchWithdrawRules: async (context, event) => {
504
- return await request.send(payment.getCurrentWithdrawRule())
505
- },
506
- submitWithdraw: async (context, event) => {
507
- const { bank, amount } = context
508
- const { method } = context.paymentDetail[0]
509
- const branchTemp = ['GCASH', 'PAYM', 'PIX'].includes(bank.bankCode) ? '' : bank.branch
510
- return await request.send(
511
- payment.submitWithdrawTransactionVN({
512
- method,
513
- amount,
514
- applyerBankCode: bank.bankCode,
515
- applyerAccountNumber: bank.accountNumber,
516
- branch: branchTemp,
517
- holderName: bank.holderName,
518
- })
519
- )
520
- },
521
- convertFreeCredit: async (context, event) => {
522
- return await request.send(payment.convertFreeCredit({ exchangeType: 1 }))
523
- },
524
- resetOtp: async (context, event) => {
525
- const { requestId, target } = context
526
- return await request.send(user.otpReset({ requestId, target }))
527
- },
528
- acknowledge: async (context, event) => {
529
- const { requestId, target } = context
530
- const code = event.data
531
- return await request.send(user.otpAcknowledge({ requestId, target, code }))
532
- },
533
- pool: async (context, event) => {
534
- const { amount } = context
535
- return await request.send(payment.restore({ amount }))
536
- },
537
- giveUp: async (context, event) => {
538
- return await request.send(payment.giveUp())
539
- },
540
- withdrawCheck: async (context, event) => {
541
- return await request.send(payment.withdrawCheck())
542
- },
543
- },
544
- }
545
- )
546
- }