@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
@@ -1,11 +1,9 @@
1
1
  import { assign, createMachine } from 'xstate'
2
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
- import api from '../api/payment.js'
7
-
8
- // const findLastIndex = require('lodash/findLastIndex')
3
+ import payment from '../../api/payment.js'
4
+ import common from '../../api/common.js'
5
+ import user from '../../api/user.js'
6
+ import api from '../../api/payment.js'
9
7
 
10
8
  export default function (request) {
11
9
  const { appSecret } = request.config
@@ -25,7 +23,10 @@ export default function (request) {
25
23
  targetWithdrawLimit: null,
26
24
 
27
25
  maxWithdrawAmount: null,
28
- availableWithdrawAmount: null,
26
+ enableWithdraw: false,
27
+ withdrawRules: [],
28
+
29
+ attachmentType: null, // null | 'withdraw' | 'pool'
29
30
 
30
31
  networks: [],
31
32
  selectedNetwork: null,
@@ -34,6 +35,12 @@ export default function (request) {
34
35
 
35
36
  charge: null,
36
37
  realAmount: null,
38
+
39
+ // otp
40
+ requestId: null,
41
+ status: null,
42
+ target: null,
43
+ ttl: null,
37
44
  },
38
45
  states: {
39
46
  loading: {
@@ -41,7 +48,7 @@ export default function (request) {
41
48
  src: 'fetchInitData',
42
49
  onDone: {
43
50
  target: 'mode',
44
- actions: ['setInitData', 'preset'],
51
+ actions: ['setInitData', 'preset', 'updateWithdrawCondition'],
45
52
  },
46
53
  onError: {
47
54
  target: 'fail',
@@ -52,43 +59,59 @@ export default function (request) {
52
59
  always: [{ target: 'free', cond: 'isFree' }, { target: 'cash' }],
53
60
  },
54
61
  free: {
55
- initial: 'loading',
62
+ initial: 'checking',
56
63
  states: {
57
- loading: {
64
+ checking: {
65
+ always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
66
+ },
67
+ notConvertible: {
68
+ on: {
69
+ GIVE_UP: {
70
+ target: 'givingUp',
71
+ },
72
+ },
73
+ },
74
+ givingUp: {
58
75
  invoke: {
59
- src: 'fetchWithdrawRules',
76
+ src: 'giveUp',
60
77
  onDone: {
61
- target: 'checking',
62
- actions: 'updateWithdrawCondition',
78
+ target: 'gaveUp',
63
79
  },
64
80
  onError: {
65
- target: 'notConvertible',
81
+ target: 'convertible',
66
82
  },
67
83
  },
68
84
  },
69
- checking: {
70
- always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
71
- },
72
- notConvertible: {},
85
+ gaveUp: {},
73
86
  convertible: {
74
87
  on: {
75
88
  SUBMIT: {
76
89
  target: 'converting',
90
+ actions: 'setAttachmentType',
77
91
  },
78
92
  },
79
93
  },
80
94
  converting: {
81
95
  invoke: {
82
- src: 'submitWithdrawFree',
83
- onDone: {
84
- target: 'converted',
85
- },
96
+ src: 'convertFreeCredit',
97
+ onDone: [
98
+ {
99
+ target: '#withdraw_crypto.otp',
100
+ actions: 'setOtp',
101
+ cond: 'isOtpRequired',
102
+ },
103
+ {
104
+ target: 'converted',
105
+ },
106
+ ],
86
107
  onError: {
87
108
  target: 'convertible',
88
109
  },
89
110
  },
90
111
  },
91
- converted: {},
112
+ converted: {
113
+ always: [{ target: '#withdraw_crypto.cash.withdrawable', cond: 'hasAttachmentType' }],
114
+ },
92
115
  },
93
116
  },
94
117
  cash: {
@@ -122,6 +145,17 @@ export default function (request) {
122
145
  target: 'submittable',
123
146
  cond: 'isSubmittable',
124
147
  },
148
+ SET_ATTACHMENT_TYPE: {
149
+ actions: 'setAttachmentType',
150
+ cond: 'isNewWalletMode',
151
+ },
152
+ POOL: {
153
+ target: 'pooling',
154
+ cond: (context, event) => {
155
+ const { amount, attachmentType } = context
156
+ return attachmentType === 'pool' && amount > 0
157
+ },
158
+ },
125
159
  },
126
160
  },
127
161
  calculating: {
@@ -139,9 +173,18 @@ export default function (request) {
139
173
  },
140
174
  submittable: {
141
175
  on: {
142
- SUBMIT: {
143
- target: 'submitting',
144
- },
176
+ SUBMIT: [
177
+ {
178
+ target: 'pooling',
179
+ cond: (context, event) => {
180
+ const { amount, attachmentType } = context
181
+ return attachmentType === 'pool' && amount > 0
182
+ },
183
+ },
184
+ {
185
+ target: 'submitting',
186
+ },
187
+ ],
145
188
  BACK: {
146
189
  target: 'withdrawable',
147
190
  },
@@ -150,16 +193,97 @@ export default function (request) {
150
193
  submitting: {
151
194
  invoke: {
152
195
  src: 'submitWithdraw',
153
- onDone: {
154
- target: 'submitted',
155
- actions: 'setResult',
156
- },
196
+ onDone: [
197
+ {
198
+ target: '#withdraw_crypto.otp',
199
+ actions: 'setOtp',
200
+ cond: 'isOtpRequired',
201
+ },
202
+ {
203
+ target: 'submitted',
204
+ },
205
+ ],
157
206
  onError: {
158
207
  target: 'withdrawable',
159
208
  },
160
209
  },
161
210
  },
162
211
  submitted: {},
212
+ pooling: {
213
+ invoke: {
214
+ src: 'pool',
215
+ onDone: { target: 'pooled' },
216
+ onError: {
217
+ target: 'withdrawable',
218
+ },
219
+ },
220
+ },
221
+ pooled: {},
222
+ },
223
+ },
224
+ otp: {
225
+ type: 'parallel',
226
+ states: {
227
+ countdown: {
228
+ after: {
229
+ 1000: {
230
+ target: 'countdown',
231
+ actions: 'decreaseTtl',
232
+ cond: (context) => context.ttl > 0,
233
+ },
234
+ },
235
+ },
236
+ verification: {
237
+ initial: 'idle',
238
+ states: {
239
+ idle: {
240
+ on: {
241
+ ACKNOWLEDGE: {
242
+ target: 'acknowledging',
243
+ },
244
+ RESET_OTP: {
245
+ target: 'reset',
246
+ },
247
+ BACK: [
248
+ {
249
+ target: '#withdraw_crypto.free.convertible',
250
+ cond: 'isFree',
251
+ },
252
+ {
253
+ target: '#withdraw_crypto.cash.submittable',
254
+ },
255
+ ],
256
+ },
257
+ },
258
+ acknowledging: {
259
+ invoke: {
260
+ src: 'acknowledge',
261
+ onDone: [
262
+ {
263
+ target: '#withdraw_crypto.free.converted',
264
+ cond: 'isFree',
265
+ },
266
+ {
267
+ target: '#withdraw_crypto.cash.submitted',
268
+ },
269
+ ],
270
+ onError: {
271
+ target: 'idle',
272
+ },
273
+ },
274
+ },
275
+ reset: {
276
+ invoke: {
277
+ src: 'resetOtp',
278
+ onDone: {
279
+ target: 'idle',
280
+ actions: 'setVerificationData',
281
+ },
282
+ onError: { target: 'idle' },
283
+ },
284
+ },
285
+ },
286
+ },
163
287
  },
164
288
  },
165
289
  fail: {},
@@ -187,11 +311,6 @@ export default function (request) {
187
311
  }) || [],
188
312
  }
189
313
  }),
190
- setPaymentData: assign((context, event) => {
191
- return {
192
- paymentDetail: event.data.paymentDetail,
193
- }
194
- }),
195
314
  preset: assign((context, event) => {
196
315
  const { userInfo, siteConfig } = event.data
197
316
  const { withdraw_limit, target_withdraw_limit } = userInfo || {}
@@ -204,24 +323,21 @@ export default function (request) {
204
323
  balance,
205
324
  siteConfig,
206
325
  userInfo,
326
+ attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
207
327
  }
208
328
  }),
209
329
  updateWithdrawCondition: assign((context, event) => {
210
- const rules = event.data.rules.filter((rule) => rule.maxWithdrawAmount > 0)
211
-
212
- const { balance, withdrawLimit } = context
330
+ const { enableWithdraw, enableWithdrawAmount } = event.data?.withdrawRule
331
+ const withdrawRules = event.data?.withdrawRule?.rules || []
332
+ const rules = withdrawRules.filter((rule) => rule.maxWithdrawAmount > 0)
333
+ const { balance } = context
213
334
  const lastMatchedIndex = findLastIndex(rules, (rule) => balance >= rule.greaterEqualThen)
214
335
 
215
- let maxWithdrawAmount = 0,
216
- availableWithdrawAmount = 0
336
+ let maxWithdrawAmount = 0
217
337
 
218
338
  if (lastMatchedIndex > -1) {
219
339
  rules[lastMatchedIndex].match = true
220
340
  maxWithdrawAmount = rules[lastMatchedIndex].maxWithdrawAmount
221
-
222
- if (withdrawLimit === 0) {
223
- availableWithdrawAmount = Math.min(balance, maxWithdrawAmount)
224
- }
225
341
  } else if (rules.length > 0) {
226
342
  maxWithdrawAmount = rules[0].maxWithdrawAmount
227
343
  } else {
@@ -230,7 +346,9 @@ export default function (request) {
230
346
 
231
347
  return {
232
348
  maxWithdrawAmount,
233
- availableWithdrawAmount,
349
+ enableWithdrawAmount: +enableWithdrawAmount,
350
+ enableWithdraw,
351
+ withdrawRules,
234
352
  }
235
353
  }),
236
354
  setNetwork: assign((context, event) => {
@@ -258,10 +376,32 @@ export default function (request) {
258
376
  charge: null,
259
377
  }
260
378
  }),
261
- setTransaction: assign((context, event) => {
262
- const { realAmount } = event.data
379
+ setOtp: assign((context, event) => {
380
+ const { requestId, status, target, ttl } = event.data
381
+ return {
382
+ requestId,
383
+ status,
384
+ target,
385
+ ttl,
386
+ }
387
+ }),
388
+ decreaseTtl: assign((context, evnet) => {
389
+ const second = context.ttl
263
390
  return {
264
- realAmount,
391
+ ttl: Math.max(second - 1, 0),
392
+ }
393
+ }),
394
+ setVerificationData: assign((context, event) => {
395
+ const { requestId, ttl, target } = event.data
396
+ return {
397
+ requestId,
398
+ ttl,
399
+ target,
400
+ }
401
+ }),
402
+ setAttachmentType: assign((context, event) => {
403
+ return {
404
+ attachmentType: event.data,
265
405
  }
266
406
  }),
267
407
  },
@@ -269,53 +409,48 @@ export default function (request) {
269
409
  isFree: (context, event) => {
270
410
  return context.userInfo?.withdraw_rule !== 'DEFAULT'
271
411
  },
412
+ hasAttachmentType: (context, event) => {
413
+ return ['withdraw', 'pool'].includes(context.attachmentType)
414
+ },
272
415
  haveProcessing: (context, event) => {
273
416
  return (context.paymentDetail?.[0]?.processing || []).length > 0
274
417
  },
275
- isWithdrawDisable: (context, event) => {
276
- const { siteConfig } = context
277
- const methods = siteConfig?.paymentMethods?.withdraw || []
278
- return methods.length === 0
279
- },
280
418
  isSubmittable: (context, event) => {
281
419
  const { selectedNetwork, address, amount, charge } = context
282
420
  return selectedNetwork && address && amount && charge
283
421
  },
284
422
  isConvertible: (context, event) => {
285
- const { balance, withdrawLimit } = context
286
- return balance > 0 && withdrawLimit === 0
423
+ const { enableWithdraw } = context
424
+ return enableWithdraw
287
425
  },
288
426
  isNotWithdrawable: (context, event) => {
289
- const { balance, withdrawLimit, paymentDetail } = context
290
- const minWithdrawAmount = paymentDetail[0]?.minimum || 0
291
- return withdrawLimit !== 0 || balance < minWithdrawAmount
427
+ const { enableWithdraw } = context
428
+ return !enableWithdraw
292
429
  },
293
430
  isCalculable: (context, event) => {
294
431
  const { selectedNetwork, amount } = context
295
432
  return selectedNetwork && amount
296
433
  },
434
+ isOtpRequired: (context, event) => {
435
+ return event.data?.status === 'otp-verifying'
436
+ },
437
+ isNewWalletMode: (context, event) => context.siteConfig.walletMode > 0,
297
438
  },
298
439
  services: {
299
440
  fetchInitData: async (context, event) => {
300
- const [{ config }, userInfo, paymentDetail = []] = await Promise.all([
441
+ const [{ config }, userInfo, paymentDetail = [], withdrawRule] = await Promise.all([
301
442
  request.send(common.getConfig({ appSecret })),
302
443
  request.send(user.getUserInfo()),
303
444
  request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' })),
445
+ request.send(payment.getCurrentWithdrawRule()),
304
446
  ])
305
447
  const siteConfig = JSON.parse(window.atob(config))
306
- return { siteConfig, userInfo, paymentDetail }
307
- },
308
- fetchPaymentData: async (context, event) => {
309
- const paymentDetail = await request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' }))
310
- return { paymentDetail }
311
- },
312
- fetchWithdrawRules: async (context, event) => {
313
- return await request.send(payment.getCurrentWithdrawRule())
448
+ return { siteConfig, userInfo, paymentDetail, withdrawRule }
314
449
  },
315
450
  submitWithdraw: async (context, event) => {
316
451
  const { crypto, selectedNetwork, address, amount } = context
317
452
  return await request.send(
318
- api.submitWithdrawTransaction({
453
+ api.submitWithdrawTransactionCrypto({
319
454
  method: crypto.method,
320
455
  amount,
321
456
  cryptoCurrency: crypto.channel,
@@ -324,7 +459,7 @@ export default function (request) {
324
459
  })
325
460
  )
326
461
  },
327
- submitWithdrawFree: async (context, event) => {
462
+ convertFreeCredit: async (context, event) => {
328
463
  return await request.send(payment.convertFreeCredit({ exchangeType: 1 }))
329
464
  },
330
465
  fetchCalculation: async (context, event) => {
@@ -338,6 +473,22 @@ export default function (request) {
338
473
  })
339
474
  )
340
475
  },
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
+ },
341
492
  },
342
493
  }
343
494
  )