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