@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,90 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import payment from '../../api/payment.js'
3
+
4
+ export default function (request) {
5
+ return createMachine(
6
+ {
7
+ id: 'amb',
8
+ initial: 'loading',
9
+ context: {
10
+ bankList: [],
11
+ userAccount: {},
12
+ houseAccountName: null,
13
+ houseAccountNumber: null,
14
+ houseBankName: null,
15
+ method: 'amb',
16
+ },
17
+ states: {
18
+ loading: {
19
+ initial: 'checkingUserAccount',
20
+ states: {
21
+ checkingUserAccount: {
22
+ invoke: {
23
+ src: 'fetchPaymentInfo',
24
+ onDone: [
25
+ {
26
+ target: 'initializing',
27
+ actions: 'setUserAccount',
28
+ cond: 'hasUserAccount',
29
+ },
30
+ { target: '#amb.accountUnbound' },
31
+ ],
32
+ onError: {
33
+ target: '#amb.unavailable',
34
+ },
35
+ },
36
+ },
37
+ initializing: {
38
+ invoke: {
39
+ src: 'initialize',
40
+ onDone: { target: '#amb.finish', actions: 'setInitialization' },
41
+ onError: {
42
+ target: '#amb.unavailable',
43
+ },
44
+ },
45
+ },
46
+ },
47
+ },
48
+ finish: {},
49
+ accountUnbound: {},
50
+ unavailable: {},
51
+ },
52
+ },
53
+ {
54
+ actions: {
55
+ setUserAccount: assign((context, event) => {
56
+ return {
57
+ userAccount: event.data.bankInfo?.[0],
58
+ }
59
+ }),
60
+ setInitialization: assign((context, event) => {
61
+ const { houseAccount, bankList } = event.data
62
+ return {
63
+ houseAccountName: houseAccount.accountName,
64
+ houseAccountNumber: houseAccount.accountNumber,
65
+ houseBankName: houseAccount.bankName,
66
+ bankList,
67
+ }
68
+ }),
69
+ },
70
+ guards: {
71
+ hasUserAccount: (context, event) => {
72
+ return event.data.bankInfo?.[0]
73
+ },
74
+ },
75
+ services: {
76
+ fetchPaymentInfo: async (context, event) => {
77
+ return await request.send(payment.getPaymentInfo())
78
+ },
79
+ initialize: async (context, event) => {
80
+ const { method } = context
81
+ const [houseAccount, bankList] = await Promise.all([
82
+ request.send(payment.submitDepositTransaction({ method })),
83
+ request.send(payment.getBankList(method)),
84
+ ])
85
+ return { houseAccount, bankList }
86
+ },
87
+ },
88
+ }
89
+ )
90
+ }
@@ -0,0 +1,267 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import padStart from 'lodash/padStart.js'
3
+ import payment from '@jetthai/cuora/src/api/payment.js'
4
+
5
+ // const padStart = require('lodash/padStart')
6
+
7
+ export default function (request) {
8
+ return createMachine(
9
+ {
10
+ id: 'crypto',
11
+ initial: 'loading',
12
+ context: {
13
+ paymentDetails: [],
14
+
15
+ channels: [],
16
+ cryptos: [],
17
+ networks: [],
18
+ sourceAddress: '',
19
+
20
+ amount: null,
21
+ selectedCrypto: null,
22
+ selectedNetwork: null,
23
+
24
+ currentCategory: 'crypto',
25
+ currentPayment: null,
26
+
27
+ calculation: null,
28
+ result: null,
29
+ },
30
+ states: {
31
+ loading: {
32
+ invoke: {
33
+ src: 'fetchPayments',
34
+ onDone: {
35
+ target: 'idle',
36
+ actions: 'setCryptos',
37
+ },
38
+ onError: {
39
+ target: '#crypto.fail',
40
+ },
41
+ },
42
+ },
43
+ idle: {
44
+ always: [{ target: 'debouncing', cond: 'isCalculable' }],
45
+ },
46
+ debouncing: {
47
+ after: {
48
+ 1000: {
49
+ target: 'calculating',
50
+ },
51
+ },
52
+ },
53
+ // calculable: {
54
+ // on: {
55
+ // CALCULATE: {
56
+ // target: 'calculating',
57
+ // },
58
+ // },
59
+ // },
60
+ calculating: {
61
+ invoke: {
62
+ src: 'fetchCalculation',
63
+ onDone: {
64
+ target: 'calculated',
65
+ actions: 'setCalculation',
66
+ },
67
+ onError: {
68
+ target: 'idle',
69
+ },
70
+ },
71
+ },
72
+ calculated: {
73
+ on: {
74
+ SUBMIT: {
75
+ target: 'submitting',
76
+ cond: 'isSubmittable',
77
+ },
78
+ },
79
+ },
80
+ submitting: {
81
+ invoke: {
82
+ src: 'submitDeposit',
83
+ onDone: {
84
+ target: 'submitted',
85
+ actions: 'setResult',
86
+ },
87
+ onError: {
88
+ target: 'idle',
89
+ },
90
+ },
91
+ },
92
+ submitted: {},
93
+ fail: {},
94
+ },
95
+ on: {
96
+ SET_CHANNEL: {
97
+ target: '.idle',
98
+ actions: 'setChannel',
99
+ },
100
+ SET_CRYPTO: {
101
+ target: '.idle',
102
+ actions: 'setCrypto',
103
+ },
104
+ SET_NETWORK: {
105
+ target: '.idle',
106
+ actions: 'setNetwork',
107
+ },
108
+ SET_ADDRESS: {
109
+ actions: 'setAddress',
110
+ },
111
+ SET_AMOUNT: {
112
+ target: '.idle',
113
+ actions: ['setAmount', 'clearCalculation'],
114
+ },
115
+ // CLEAR_CALCULATION: {
116
+ // target: '.idle',
117
+ // actions: 'clearCalculation',
118
+ // },
119
+ CALCULATE: {
120
+ target: '.debouncing',
121
+ actions: 'clearCalculation',
122
+ },
123
+ },
124
+ },
125
+ {
126
+ actions: {
127
+ setCryptos: assign((context, event) => {
128
+ const cryptos = event.data?.map?.((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || []
129
+ const currentPayment = cryptos.find((element) => element.category === context.currentCategory)
130
+ const channels = cryptos.map((item, i) => ({ ...item, label: `Channel ${padStart(String(i + 1), 2, '0')}`, icon: 'channel' }))
131
+ const defaultNetworks =
132
+ cryptos[0].networkName.map((value, i) => {
133
+ return {
134
+ label: cryptos[0].networkOptional?.[i],
135
+ value,
136
+ icon: value,
137
+ }
138
+ }) || []
139
+ return {
140
+ channels,
141
+ cryptos,
142
+ networks: defaultNetworks,
143
+ selectedChannel: channels[0],
144
+ selectedCrypto: cryptos[0],
145
+ selectedNetwork: defaultNetworks[0],
146
+ currentPayment,
147
+ }
148
+ }),
149
+ setChannel: assign((context, event) => {
150
+ const { cryptos } = context
151
+ const selectedCrypto = cryptos.find((crypto) => crypto.method === event.data.value)
152
+ const networks =
153
+ selectedCrypto?.networkName.map((value, i) => {
154
+ return {
155
+ label: selectedCrypto?.networkOptional?.[i],
156
+ value,
157
+ icon: value,
158
+ }
159
+ }) || []
160
+ return {
161
+ networks,
162
+ selectedChannel: event.data,
163
+ selectedCrypto: selectedCrypto,
164
+ selectedNetwork: networks[0],
165
+ amount: null,
166
+ calculation: null,
167
+ }
168
+ }),
169
+ setCrypto: assign((context, event) => {
170
+ const { cryptos, selectedNetwork } = context
171
+ const method = cryptos.find((crypto) => crypto.method === event.data.value)
172
+ const networks =
173
+ method?.networkName.map((value, i) => {
174
+ return {
175
+ label: method?.networkOptional?.[i],
176
+ value,
177
+ icon: value,
178
+ }
179
+ }) || []
180
+
181
+ const properties = {
182
+ selectedCrypto: event.data,
183
+ networks,
184
+ }
185
+
186
+ if (!networks.includes(selectedNetwork)) {
187
+ properties.selectedNetwork = null
188
+ properties.amount = null
189
+ properties.calculation = null
190
+ }
191
+
192
+ return properties
193
+ }),
194
+ setNetwork: assign((context, event) => {
195
+ return { selectedNetwork: event.data }
196
+ }),
197
+ setAmount: assign((context, event) => {
198
+ return {
199
+ amount: event.data,
200
+ }
201
+ }),
202
+ setAddress: assign((context, event) => {
203
+ return {
204
+ sourceAddress: event.data,
205
+ }
206
+ }),
207
+ setCalculation: assign((context, event) => {
208
+ return {
209
+ calculation: event.data,
210
+ }
211
+ }),
212
+ clearCalculation: assign((context, event) => {
213
+ return {
214
+ calculation: null,
215
+ }
216
+ }),
217
+ setResult: assign((context, event) => {
218
+ return {
219
+ result: event.data,
220
+ }
221
+ }),
222
+ },
223
+ guards: {
224
+ isCalculable: (context, event) => {
225
+ const {
226
+ selectedCrypto,
227
+ selectedNetwork,
228
+ amount,
229
+ currentPayment: { maximum, minimum },
230
+ } = context
231
+ return selectedCrypto && selectedNetwork && amount && minimum <= +amount && +amount <= maximum
232
+ },
233
+ isSubmittable: (context, event) => {
234
+ const { selectedCrypto, selectedNetwork, amount } = context
235
+ return selectedCrypto && selectedNetwork && amount
236
+ },
237
+ },
238
+ services: {
239
+ fetchPayments: async (context, event) => {
240
+ return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
241
+ },
242
+ fetchCalculation: async (context, event) => {
243
+ const { selectedCrypto, amount } = context
244
+ return await request.send(
245
+ payment.getDepositExpectedResult({
246
+ method: selectedCrypto.method,
247
+ amount,
248
+ cryptoCurrency: selectedCrypto.channel,
249
+ })
250
+ )
251
+ },
252
+ submitDeposit: async (context, event) => {
253
+ const { selectedCrypto, selectedNetwork, calculation, sourceAddress } = context
254
+ return await request.send(
255
+ payment.submitDepositTransactionCrypto({
256
+ method: selectedCrypto.method,
257
+ amount: calculation.actualAmount,
258
+ cryptoCurrency: selectedCrypto.channel,
259
+ cryptoNetwork: selectedNetwork.value,
260
+ sourceAddress: sourceAddress,
261
+ })
262
+ )
263
+ },
264
+ },
265
+ }
266
+ )
267
+ }