@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,449 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import padStart from 'lodash/padStart.js'
3
+ import payment from '../../api/payment.js'
4
+ import common from '../../api/common.js'
5
+
6
+ export default function (request) {
7
+ const { appSecret } = request.config
8
+ return createMachine(
9
+ {
10
+ id: 'crypro_button',
11
+ initial: 'loading',
12
+ context: {
13
+ siteConfig: null,
14
+ paymentDetails: [],
15
+
16
+ channels: [],
17
+ cryptos: [],
18
+ networks: [],
19
+ options: [],
20
+ sourceAddress: '',
21
+
22
+ selectedAmount: null,
23
+ selectedCrypto: null,
24
+ selectedNetwork: null,
25
+
26
+ currentCategory: 'crypto',
27
+ currentPayment: null,
28
+
29
+ calculation: null,
30
+ result: null,
31
+
32
+ grandTotalEnable: 1,
33
+ },
34
+ states: {
35
+ loading: {
36
+ invoke: {
37
+ src: 'fetchInitData',
38
+ onDone: {
39
+ target: 'checking',
40
+ actions: ['setInitData', 'preset'],
41
+ },
42
+ onError: {
43
+ target: 'fail',
44
+ },
45
+ },
46
+ },
47
+ checking: {
48
+ always: [{ target: 'newWalletMode', cond: 'isNewWalletMode' }, { target: 'defaultMode' }],
49
+ },
50
+ newWalletMode: {
51
+ initial: 'loaded',
52
+ states: {
53
+ loaded: {
54
+ entry: 'reset',
55
+ on: {
56
+ SET_CHANNEL: {
57
+ actions: 'setChannel',
58
+ },
59
+ SET_CRYPTO: {
60
+ actions: 'setCrypto',
61
+ },
62
+ SET_NETWORK: {
63
+ actions: 'setNetwork',
64
+ },
65
+ SET_ADDRESS: {
66
+ actions: 'setAddress',
67
+ },
68
+ CONFIRM: {
69
+ target: 'selecting',
70
+ cond: 'isConfirmable',
71
+ },
72
+ },
73
+ },
74
+ selecting: {
75
+ entry: 'reset',
76
+ on: {
77
+ SELECT_AMOUNT: [
78
+ {
79
+ actions: 'addAmount',
80
+ cond: (context, event) => context.grandTotalEnable === 1,
81
+ },
82
+ {
83
+ actions: 'setAmount',
84
+ },
85
+ ],
86
+ KEY_IN: {
87
+ actions: 'setAmount',
88
+ },
89
+ SUBMIT: {
90
+ target: 'debouncing',
91
+ },
92
+ BACK: {
93
+ target: 'loaded',
94
+ },
95
+ CLEAR_ALL: {
96
+ actions: 'reset',
97
+ },
98
+ },
99
+ },
100
+ debouncing: {
101
+ on: {
102
+ SELECT_AMOUNT: [
103
+ {
104
+ target: 'debouncing',
105
+ actions: 'addAmount',
106
+ cond: (context, event) => context.grandTotalEnable === 1,
107
+ },
108
+ {
109
+ target: 'debouncing',
110
+ actions: 'setAmount',
111
+ },
112
+ ],
113
+ KEY_IN: {
114
+ target: 'debouncing',
115
+ actions: 'setAmount',
116
+ },
117
+ BACK: {
118
+ target: 'loaded',
119
+ },
120
+ CLEAR_ALL: {
121
+ actions: 'reset',
122
+ },
123
+ },
124
+ after: {
125
+ 1000: {
126
+ target: 'calculating',
127
+ },
128
+ },
129
+ },
130
+ calculating: {
131
+ invoke: {
132
+ src: 'fetchCalculation',
133
+ onDone: {
134
+ target: 'submitting',
135
+ actions: 'setCalculation',
136
+ },
137
+ onError: {
138
+ target: 'selecting',
139
+ actions: 'reset',
140
+ },
141
+ },
142
+ },
143
+ submitting: {
144
+ invoke: {
145
+ src: 'submitDeposit',
146
+ onDone: {
147
+ target: '#crypro_button.submitted',
148
+ actions: 'setResult',
149
+ },
150
+ onError: {
151
+ target: 'selecting',
152
+ },
153
+ },
154
+ },
155
+ },
156
+ },
157
+ defaultMode: {
158
+ on: {
159
+ SET_CHANNEL: {
160
+ actions: 'setChannel',
161
+ },
162
+ SET_CRYPTO: {
163
+ actions: 'setCrypto',
164
+ },
165
+ SET_NETWORK: {
166
+ actions: 'setNetwork',
167
+ },
168
+ SET_ADDRESS: {
169
+ actions: 'setAddress',
170
+ },
171
+ CONFIRM: {
172
+ target: 'selecting',
173
+ cond: 'isConfirmable',
174
+ },
175
+ },
176
+ },
177
+ fail: {},
178
+ selecting: {
179
+ entry: 'reset',
180
+ on: {
181
+ SELECT_AMOUNT: [
182
+ {
183
+ target: 'debouncing',
184
+ actions: 'addAmount',
185
+ cond: (context, event) => context.grandTotalEnable === 1,
186
+ },
187
+ {
188
+ target: 'debouncing',
189
+ actions: 'setAmount',
190
+ },
191
+ ],
192
+ KEY_IN: {
193
+ target: 'debouncing',
194
+ actions: 'setAmount',
195
+ },
196
+ BACK: {
197
+ target: 'defaultMode',
198
+ },
199
+ },
200
+ },
201
+ debouncing: {
202
+ on: {
203
+ SELECT_AMOUNT: [
204
+ {
205
+ target: 'debouncing',
206
+ actions: 'addAmount',
207
+ cond: (context, event) => context.grandTotalEnable === 1,
208
+ },
209
+ {
210
+ target: 'debouncing',
211
+ actions: 'setAmount',
212
+ },
213
+ ],
214
+ KEY_IN: {
215
+ target: 'debouncing',
216
+ actions: 'setAmount',
217
+ },
218
+ },
219
+ after: {
220
+ 1000: {
221
+ target: 'calculating',
222
+ },
223
+ },
224
+ },
225
+ calculating: {
226
+ invoke: {
227
+ src: 'fetchCalculation',
228
+ onDone: {
229
+ target: 'calculated',
230
+ actions: 'setCalculation',
231
+ },
232
+ onError: {
233
+ target: 'selecting',
234
+ actions: 'reset',
235
+ },
236
+ },
237
+ },
238
+ calculated: {
239
+ on: {
240
+ SELECT_AMOUNT: [
241
+ {
242
+ target: 'debouncing',
243
+ actions: 'addAmount',
244
+ cond: (context, event) => context.grandTotalEnable === 1,
245
+ },
246
+ {
247
+ target: 'debouncing',
248
+ actions: 'setAmount',
249
+ },
250
+ ],
251
+ KEY_IN: {
252
+ target: 'debouncing',
253
+ actions: 'setAmount',
254
+ },
255
+ SUBMIT: {
256
+ target: 'submitting',
257
+ cond: 'isSubmittable',
258
+ },
259
+ CLEAR_CALCULATION: {
260
+ target: 'debouncing',
261
+ actions: 'clearCalculation',
262
+ },
263
+ CLEAR_ALL: {
264
+ target: 'selecting',
265
+ actions: 'reset',
266
+ },
267
+ },
268
+ },
269
+ submitting: {
270
+ invoke: {
271
+ src: 'submitDeposit',
272
+ onDone: {
273
+ target: 'submitted',
274
+ actions: 'setResult',
275
+ },
276
+ onError: {
277
+ target: 'calculated',
278
+ },
279
+ },
280
+ },
281
+ submitted: {},
282
+ },
283
+ },
284
+ {
285
+ actions: {
286
+ reset: assign((context, event) => {
287
+ return {
288
+ selectedAmount: null,
289
+ calculation: null,
290
+ }
291
+ }),
292
+ setInitData: assign((context, event) => {
293
+ const { paymentDetail } = event.data
294
+ const cryptos = paymentDetail?.map?.((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || []
295
+ const currentPayment = cryptos.find((element) => element.category === context.currentCategory)
296
+ const channels = cryptos.map((item, i) => ({ ...item, label: `Channel ${padStart(String(i + 1), 2, '0')}`, icon: 'channel' }))
297
+ const defaultNetworks =
298
+ cryptos[0].networkName.map((value, i) => {
299
+ return {
300
+ label: cryptos[0].networkOptional?.[i],
301
+ value,
302
+ icon: value,
303
+ }
304
+ }) || []
305
+ const options = cryptos[0].optional
306
+ return {
307
+ channels,
308
+ cryptos,
309
+ networks: defaultNetworks,
310
+ selectedChannel: channels[0],
311
+ selectedCrypto: cryptos[0],
312
+ selectedNetwork: defaultNetworks[0],
313
+ grandTotalEnable: cryptos[0].grandTotalEnable,
314
+ currentPayment,
315
+ options,
316
+ }
317
+ }),
318
+ preset: assign((context, event) => {
319
+ const { siteConfig } = event.data
320
+ return {
321
+ siteConfig,
322
+ }
323
+ }),
324
+ setChannel: assign((context, event) => {
325
+ const { cryptos } = context
326
+ const selectedCrypto = cryptos.find((crypto) => crypto.method === event.data.value)
327
+ const networks =
328
+ selectedCrypto?.networkName.map((value, i) => {
329
+ return {
330
+ label: selectedCrypto?.networkOptional?.[i],
331
+ value,
332
+ icon: value,
333
+ }
334
+ }) || []
335
+ const options = selectedCrypto.optional
336
+ return {
337
+ networks,
338
+ selectedChannel: event.data,
339
+ selectedCrypto: selectedCrypto,
340
+ selectedNetwork: networks[0],
341
+ selectedAmount: null,
342
+ calculation: null,
343
+ grandTotalEnable: selectedCrypto.grandTotalEnable,
344
+ options,
345
+ }
346
+ }),
347
+ setCrypto: assign((context, event) => {
348
+ const { cryptos, selectedNetwork } = context
349
+ const method = cryptos.find((crypto) => crypto.method === event.data.value)
350
+ const networks =
351
+ method?.networkName.map((value, i) => {
352
+ return {
353
+ label: method?.networkOptional?.[i],
354
+ value,
355
+ icon: value,
356
+ }
357
+ }) || []
358
+
359
+ const properties = {
360
+ selectedCrypto: event.data,
361
+ networks,
362
+ }
363
+
364
+ if (!networks.includes(selectedNetwork)) {
365
+ properties.selectedNetwork = null
366
+ properties.selectedAmount = null
367
+ properties.calculation = null
368
+ }
369
+
370
+ return properties
371
+ }),
372
+ setNetwork: assign((context, event) => {
373
+ return { selectedNetwork: event.data }
374
+ }),
375
+ addAmount: assign((context, event) => {
376
+ return { selectedAmount: (context.selectedAmount || 0) + event.data }
377
+ }),
378
+ setAmount: assign((context, event) => {
379
+ return { selectedAmount: event.data }
380
+ }),
381
+ setAddress: assign((context, event) => {
382
+ return {
383
+ sourceAddress: event.data,
384
+ }
385
+ }),
386
+ setCalculation: assign((context, event) => {
387
+ return {
388
+ calculation: event.data,
389
+ }
390
+ }),
391
+ clearCalculation: assign((context, event) => {
392
+ return {
393
+ calculation: null,
394
+ }
395
+ }),
396
+ setResult: assign((context, event) => {
397
+ return {
398
+ result: event.data,
399
+ }
400
+ }),
401
+ },
402
+ guards: {
403
+ isNewWalletMode: (context, event) => {
404
+ return context.siteConfig?.walletMode === '2'
405
+ },
406
+ isConfirmable: (context, event) => {
407
+ const { selectedCrypto, selectedNetwork } = context
408
+ return selectedCrypto && selectedNetwork
409
+ },
410
+ isSubmittable: (context, event) => {
411
+ const { selectedCrypto, selectedNetwork, selectedAmount } = context
412
+ return selectedCrypto && selectedNetwork && selectedAmount
413
+ },
414
+ },
415
+ services: {
416
+ fetchInitData: async (context, event) => {
417
+ const [{ config }, paymentDetail = []] = await Promise.all([
418
+ request.send(common.getConfig({ appSecret })),
419
+ request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
420
+ ])
421
+ const siteConfig = JSON.parse(window.atob(config))
422
+ return { siteConfig, paymentDetail }
423
+ },
424
+ fetchCalculation: async (context, event) => {
425
+ const { selectedCrypto, selectedAmount } = context
426
+ return await request.send(
427
+ payment.getDepositExpectedResult({
428
+ method: selectedCrypto.method,
429
+ amount: selectedAmount,
430
+ cryptoCurrency: selectedCrypto.channel,
431
+ })
432
+ )
433
+ },
434
+ submitDeposit: async (context, event) => {
435
+ const { selectedCrypto, selectedNetwork, calculation, sourceAddress } = context
436
+ return await request.send(
437
+ payment.submitDepositTransactionCrypto({
438
+ method: selectedCrypto.method,
439
+ amount: calculation.actualAmount,
440
+ cryptoCurrency: selectedCrypto.channel,
441
+ cryptoNetwork: selectedNetwork.value,
442
+ sourceAddress: sourceAddress,
443
+ })
444
+ )
445
+ },
446
+ },
447
+ }
448
+ )
449
+ }
@@ -1,6 +1,8 @@
1
1
  import { assign, createMachine } from 'xstate'
2
- import toNumber from 'lodash/toNumber'
3
- import payment from '../api/payment'
2
+ import toNumber from 'lodash/toNumber.js'
3
+ import payment from '../../api/payment.js'
4
+
5
+ // const toNumber = require('lodash/toNumber')
4
6
 
5
7
  export default function (request) {
6
8
  return createMachine(
@@ -56,6 +58,7 @@ export default function (request) {
56
58
  },
57
59
  },
58
60
  checking: {
61
+ entry: 'clearCalculatedResult',
59
62
  always: [{ target: 'debouncing', cond: 'isCalculable' }, { target: 'loaded' }],
60
63
  },
61
64
  debouncing: {
@@ -127,17 +130,23 @@ export default function (request) {
127
130
  actions: {
128
131
  setCryptos: assign((context, event) => {
129
132
  return {
130
- cryptos: event.data.map((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.channel })),
133
+ cryptos: event.data.map((crypto) => ({
134
+ ...crypto,
135
+ label: crypto.channel,
136
+ value: crypto.method,
137
+ icon: crypto.channel,
138
+ })),
131
139
  }
132
140
  }),
133
141
  setCrypto: assign((context, event) => {
134
142
  const { cryptos, currentNetwork } = context
135
- const method = cryptos.find((crypto) => crypto.channel === event.data.value)
143
+ const method = cryptos.find((crypto) => crypto.method === event.data.value)
136
144
  const networks =
137
- method?.optional.map((value, i) => {
145
+ method?.networkName.map((value, i) => {
138
146
  return {
139
- label: method?.originalItem?.[i],
147
+ label: method?.networkOptional?.[i],
140
148
  value,
149
+ icon: value,
141
150
  }
142
151
  }) || []
143
152
 
@@ -180,6 +189,11 @@ export default function (request) {
180
189
  submittedResult: event.data,
181
190
  }
182
191
  }),
192
+ clearCalculatedResult: assign((context, event) => {
193
+ return {
194
+ calculatedResult: null,
195
+ }
196
+ }),
183
197
  toggleBonus: assign((context, event) => {
184
198
  const { bonus } = context
185
199
  return {
@@ -215,24 +229,22 @@ export default function (request) {
215
229
  return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
216
230
  },
217
231
  fetchCalculation: async (context, event) => {
218
- const { cryptos, currentCrypto, currentAmount } = context
219
- const method = cryptos.find((crypto) => crypto.channel === currentCrypto.value)?.method
232
+ const { currentCrypto, currentAmount } = context
220
233
  return await request.send(
221
234
  payment.getDepositExpectedResult({
222
- method,
235
+ method: currentCrypto.method,
223
236
  amount: currentAmount,
224
- cryptoCurrency: currentCrypto.value,
237
+ cryptoCurrency: currentCrypto.channel,
225
238
  })
226
239
  )
227
240
  },
228
241
  submitDeposit: async (context, event) => {
229
- const { cryptos, currentCrypto, currentNetwork, calculatedResult } = context
230
- const method = cryptos.find((crypto) => crypto.channel === currentCrypto.value)?.method
242
+ const { currentCrypto, currentNetwork, calculatedResult } = context
231
243
  return await request.send(
232
- payment.submitDepositTransaction({
233
- method,
244
+ payment.submitDepositTransactionCrypto({
245
+ method: currentCrypto.method,
234
246
  amount: calculatedResult.actualAmount,
235
- cryptoCurrency: currentCrypto.value,
247
+ cryptoCurrency: currentCrypto.channel,
236
248
  cryptoNetwork: currentNetwork.value,
237
249
  })
238
250
  )