@jetthai/cuora 1.0.65 → 1.0.66-sabai-2

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/.husky/pre-commit +4 -0
  2. package/.prettierignore +1 -0
  3. package/CHANGELOG.md +642 -0
  4. package/README.md +6 -0
  5. package/dist/bundle.mjs +27623 -0
  6. package/package.json +13 -11
  7. package/rollup.config.js +12 -0
  8. package/src/api/activity.js +10 -3
  9. package/src/api/auth.js +47 -5
  10. package/src/api/game.js +64 -2
  11. package/src/api/index.js +9 -9
  12. package/src/api/payment.js +91 -7
  13. package/src/api/user.js +18 -0
  14. package/src/index.js +7 -5
  15. package/src/lib/fingerprint.js +5779 -0
  16. package/src/machine/activity/activity.js +97 -10
  17. package/src/machine/activity/affiliate_invite_friends_activity.js +216 -0
  18. package/src/machine/activity/continue_deposit_activity.js +1 -1
  19. package/src/machine/activity/deposit_activity.js +1 -1
  20. package/src/machine/activity/{diamond_shop_activity.js → diamond_shop_activity_fc.js} +33 -5
  21. package/src/machine/activity/{diamond_shop_activity_single_exchange.js → diamond_shop_activity_vn.js} +66 -21
  22. package/src/machine/activity/fafafa_activity.js +4 -2
  23. package/src/machine/activity/index.js +24 -10
  24. package/src/machine/activity/invite_friends_activity.js +3 -8
  25. package/src/machine/activity/mini_game_activity.js +68 -0
  26. package/src/machine/activity/ranking_activity.js +40 -46
  27. package/src/machine/activity/return_bonus_activity.js +5 -3
  28. package/src/machine/activity/roulette_activity_v2.js +81 -0
  29. package/src/machine/activity/sign_in_activity.js +149 -0
  30. package/src/machine/activity/specify_bets_activity.js +1 -1
  31. package/src/machine/activity/specify_turnover_activity.js +113 -0
  32. package/src/machine/activity/time_bomb_activity.js +80 -0
  33. package/src/machine/auth.js +234 -79
  34. package/src/machine/auth_otp_v2.js +177 -0
  35. package/src/machine/{auth_otp.js → auth_otp_v3.js} +80 -17
  36. package/src/machine/bank_binding.js +120 -0
  37. package/src/machine/bank_binding_amb.js +140 -0
  38. package/src/machine/bonus.js +75 -0
  39. package/src/machine/common.js +80 -17
  40. package/src/machine/deposit/amb.js +90 -0
  41. package/src/machine/deposit/crypto.js +267 -0
  42. package/src/machine/deposit/crypto_button.js +449 -0
  43. package/src/machine/{deposit.js → deposit/deposit_fc.js} +27 -15
  44. package/src/machine/deposit/direct.js +246 -0
  45. package/src/machine/deposit/float.js +295 -0
  46. package/src/machine/deposit/index.js +25 -0
  47. package/src/machine/deposit/loadcard_vn.js +390 -0
  48. package/src/machine/deposit/manual_vn.js +382 -0
  49. package/src/machine/deposit/qrcode_v2.js +451 -0
  50. package/src/machine/deposit/usdt.js +144 -0
  51. package/src/machine/deposit/vpay.js +292 -0
  52. package/src/machine/error.js +1 -1
  53. package/src/machine/game.js +17 -10
  54. package/src/machine/game_favorite.js +2 -2
  55. package/src/machine/game_favorite_v2.js +119 -0
  56. package/src/machine/game_hot_new.js +1 -1
  57. package/src/machine/game_search.js +3 -7
  58. package/src/machine/game_search_v2.js +379 -0
  59. package/src/machine/game_v2.js +381 -0
  60. package/src/machine/game_v2_1.js +442 -0
  61. package/src/machine/inbox.js +5 -6
  62. package/src/machine/index.js +58 -23
  63. package/src/machine/leaderboard.js +108 -0
  64. package/src/machine/merge.js +2 -2
  65. package/src/machine/payment_data.js +6 -5
  66. package/src/machine/promotions.js +170 -0
  67. package/src/machine/reward.js +84 -3
  68. package/src/machine/reward_fc.js +97 -0
  69. package/src/machine/roulette_v2.js +271 -0
  70. package/src/machine/setting.js +5 -2
  71. package/src/machine/side.js +34 -27
  72. package/src/machine/side_v2.js +200 -0
  73. package/src/machine/user_info.js +1 -1
  74. package/src/machine/user_reset_password.js +2 -2
  75. package/src/machine/user_sign_up.js +111 -56
  76. package/src/machine/vip_table.js +50 -0
  77. package/src/machine/welcome.js +6 -8
  78. package/src/machine/withdraw_amb.js +373 -0
  79. package/src/machine/withdraw_crypto.js +560 -0
  80. package/src/machine/withdraw_fc.js +251 -0
  81. package/src/machine/withdraw_vn.js +495 -0
  82. package/src/request/config.js +7 -1
  83. package/src/request/request.js +11 -15
  84. package/src/util/constant.js +2 -0
  85. package/src/util/deviceToken.js +33 -0
  86. package/src/util/index.js +6 -0
  87. package/src/util/storage.js +28 -0
  88. package/dist/index.js +0 -2
  89. package/dist/index.js.LICENSE.txt +0 -30
  90. package/src/machine/withdraw.js +0 -380
  91. package/src/request/cookie.js +0 -52
  92. package/webpack.config.js +0 -33
@@ -0,0 +1,251 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import api from '../api/payment.js'
3
+
4
+ export default function (request) {
5
+ return createMachine(
6
+ {
7
+ id: 'withdraw',
8
+ initial: 'loading',
9
+ context: {
10
+ crypto: null,
11
+ networks: [],
12
+ currentNetwork: null,
13
+ currentAddress: '',
14
+ withdrawMethods: [],
15
+ withdrawRules: [],
16
+ withdrawLimit: null,
17
+ withdrawAmount: null,
18
+ differAmountLimit: null,
19
+ tutorialUrls: [],
20
+ enableWithdraw: false,
21
+ description: {},
22
+ policy: '',
23
+ ruleName: '',
24
+ balance: null,
25
+ charge: null,
26
+ isFree: false,
27
+ },
28
+ states: {
29
+ loading: {
30
+ invoke: {
31
+ src: 'preset',
32
+ onDone: {
33
+ target: 'checking',
34
+ actions: ['setCrypto', 'setWithdrawCondition', 'checkMinimumWithdraw'],
35
+ },
36
+ onError: {
37
+ target: 'fail',
38
+ },
39
+ },
40
+ },
41
+ fail: {},
42
+ checking: {
43
+ always: [{ target: 'transferable', cond: 'isTransferable' }, { target: 'notTransferable' }],
44
+ },
45
+ notTransferable: {},
46
+ transferable: {
47
+ initial: 'operation',
48
+ states: {
49
+ operation: {
50
+ on: {
51
+ SUBMIT: [
52
+ {
53
+ target: '#withdraw.exchanging',
54
+ cond: 'isFree',
55
+ },
56
+ {
57
+ target: '#withdraw.transferring',
58
+ },
59
+ ],
60
+ },
61
+ },
62
+ calculating: {
63
+ entry: 'resetCharge',
64
+ invoke: {
65
+ src: 'fetchCalculation',
66
+ onDone: {
67
+ target: 'operation',
68
+ actions: 'setCalculatedResult',
69
+ },
70
+ onError: {
71
+ target: 'operation',
72
+ },
73
+ },
74
+ },
75
+ },
76
+ on: {
77
+ SET_NETWORK: {
78
+ actions: 'setNetwork',
79
+ },
80
+ SET_ADDRESS: {
81
+ actions: 'setAddress',
82
+ },
83
+ CALCULATE: {
84
+ target: '.calculating',
85
+ cond: 'isCalculable',
86
+ },
87
+ },
88
+ },
89
+ exchanging: {
90
+ invoke: {
91
+ src: 'submitWithdrawFree',
92
+ onDone: {
93
+ target: 'transferred',
94
+ actions: 'setOtp',
95
+ },
96
+ onError: {
97
+ target: 'transferable.operation',
98
+ },
99
+ },
100
+ },
101
+ transferring: {
102
+ invoke: {
103
+ src: 'submitWithdraw',
104
+ onDone: {
105
+ target: 'transferred',
106
+ actions: 'setOtp',
107
+ },
108
+ onError: {
109
+ target: 'transferable.operation',
110
+ },
111
+ },
112
+ },
113
+ transferred: {},
114
+ },
115
+ },
116
+ {
117
+ actions: {
118
+ setWithdrawCondition: assign((context, event) => {
119
+ const { adUrl, balance, description, differAmountLimit, enableWithdraw, enableWithdrawAmount, policy, ruleName, rules } =
120
+ event.data.withdraw
121
+
122
+ return {
123
+ differAmountLimit: differAmountLimit,
124
+ withdrawAmount: enableWithdrawAmount,
125
+ withdrawLimit: enableWithdraw
126
+ ? 0
127
+ : rules.find((rule) => balance < rule.greaterEqualThen)?.greaterEqualThen || parseFloat(balance) + parseFloat(differAmountLimit),
128
+ withdrawRules: rules.filter((rule) => rule.maxWithdrawAmount > 0),
129
+ tutorialUrls: adUrl.map((item) => item.url),
130
+ enableWithdraw,
131
+ description,
132
+ policy,
133
+ ruleName,
134
+ balance,
135
+ isFree: policy === 'FREE',
136
+ }
137
+ }),
138
+ setCrypto: assign((context, event) => {
139
+ const method = event.data.payment?.[0]
140
+ return {
141
+ crypto: method,
142
+ networks:
143
+ method?.networkName?.map?.((value, i) => {
144
+ return {
145
+ label: method?.networkOptional?.[i],
146
+ value,
147
+ icon: value,
148
+ }
149
+ }) || [],
150
+ }
151
+ }),
152
+ setNetwork: assign((context, event) => {
153
+ return {
154
+ currentNetwork: event.data,
155
+ }
156
+ }),
157
+ setAddress: assign((context, event) => {
158
+ return {
159
+ currentAddress: event.data,
160
+ }
161
+ }),
162
+ setCalculatedResult: assign((context, event) => {
163
+ return {
164
+ charge: event.data.charge,
165
+ }
166
+ }),
167
+ resetCharge: assign((context, event) => {
168
+ return {
169
+ charge: null,
170
+ }
171
+ }),
172
+ checkMinimumWithdraw: assign((context, event) => {
173
+ const { balance, withdrawLimit, crypto, isFree } = context
174
+ if (!isFree && crypto?.minimum > withdrawLimit) {
175
+ const limit = crypto?.minimum
176
+ const distance = Math.max(limit - balance, 0)
177
+ return {
178
+ differAmountLimit: distance,
179
+ withdrawLimit: limit,
180
+ }
181
+ }
182
+ }),
183
+ setOtp: assign((context, event) => {
184
+ const { requestId, status, target, ttl } = event.data
185
+ return {
186
+ requestId,
187
+ status,
188
+ target,
189
+ ttl,
190
+ }
191
+ }),
192
+ },
193
+ guards: {
194
+ isFree: (context, event) => {
195
+ return context.isFree
196
+ },
197
+ isTransferable: (context, event) => {
198
+ const { enableWithdraw, balance, withdrawLimit } = context
199
+ return enableWithdraw && balance >= withdrawLimit
200
+ },
201
+ isCalculable: (context, event) => {
202
+ const { currentNetwork, balance } = context
203
+ return currentNetwork && balance
204
+ },
205
+ },
206
+ services: {
207
+ preset: async (context, event) => {
208
+ const [withdraw, payment] = await Promise.all([
209
+ request.send(api.getCurrentWithdrawRule()),
210
+ request.send(api.getPaymentDetail({ transferType: 'WITHDRAW' })),
211
+ ])
212
+ return { withdraw, payment }
213
+ },
214
+ submitWithdraw: async (context, event) => {
215
+ const { crypto, currentNetwork, currentAddress, withdrawAmount } = context
216
+ const method = crypto.method
217
+ return await request.send(
218
+ api.submitWithdrawTransactionCrypto({
219
+ method,
220
+ amount: withdrawAmount,
221
+ cryptoCurrency: crypto.channel,
222
+ cryptoNetwork: currentNetwork.value,
223
+ targetAddress: currentAddress,
224
+ })
225
+ )
226
+ },
227
+ submitWithdrawFree: async (context, event) => {
228
+ const { currentNetwork, currentAddress } = context
229
+ return await request.send(
230
+ api.convertFreeCredit({
231
+ exchangeType: 1,
232
+ cryptoNetwork: currentNetwork.value,
233
+ targetAddress: currentAddress,
234
+ })
235
+ )
236
+ },
237
+ fetchCalculation: async (context, event) => {
238
+ const { crypto, currentNetwork, withdrawAmount } = context
239
+ const method = crypto.method
240
+ return await request.send(
241
+ api.getWithdrawExpectedResult({
242
+ method,
243
+ amount: withdrawAmount,
244
+ cryptoNetwork: currentNetwork.value,
245
+ })
246
+ )
247
+ },
248
+ },
249
+ }
250
+ )
251
+ }