@jetthai/cuora 1.0.307-dev-2 → 1.1.0

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 (111) hide show
  1. package/CHANGELOG.md +3 -854
  2. package/README.md +0 -6
  3. package/dist/bundle.mjs +18461 -0
  4. package/package.json +9 -6
  5. package/rollup.config.js +16 -0
  6. package/src/api/activity.js +2 -43
  7. package/src/api/auth.js +7 -22
  8. package/src/api/common.js +1 -3
  9. package/src/api/game.js +7 -20
  10. package/src/api/mailbox.js +5 -9
  11. package/src/api/payment.js +19 -167
  12. package/src/api/user.js +0 -7
  13. package/src/machine/activity/activity.js +26 -111
  14. package/src/machine/activity/{friend_invite_friends_activity.js → affiliate_invite_friends_activity.js} +41 -70
  15. package/src/machine/activity/continue_deposit_activity.js +2 -11
  16. package/src/machine/activity/deposit_activity.js +4 -13
  17. package/src/machine/activity/diamond_shop_activity_vn.js +89 -54
  18. package/src/machine/activity/fafafa_activity.js +19 -34
  19. package/src/machine/activity/index.js +4 -22
  20. package/src/machine/activity/invite_friends_activity.js +14 -14
  21. package/src/machine/activity/ranking_activity.js +2 -11
  22. package/src/machine/activity/sign_in_activity.js +14 -21
  23. package/src/machine/activity/specify_bets_activity.js +3 -25
  24. package/src/machine/activity/specify_turnover_activity.js +3 -25
  25. package/src/machine/activity/time_bomb_activity.js +2 -11
  26. package/src/machine/auth.js +21 -146
  27. package/src/machine/auth_otp.js +201 -0
  28. package/src/machine/auth_otp_v2.js +4 -10
  29. package/src/machine/auth_otp_v3.js +3 -11
  30. package/src/machine/bank_binding.js +12 -112
  31. package/src/machine/common.js +25 -113
  32. package/src/machine/deposit/crypto.js +29 -50
  33. package/src/machine/deposit/crypto_button.js +39 -174
  34. package/src/machine/deposit/deposit_fc.js +5 -8
  35. package/src/machine/deposit/direct.js +16 -111
  36. package/src/machine/deposit/index.js +2 -43
  37. package/src/machine/deposit/loadcard_vn.js +43 -191
  38. package/src/machine/deposit/manual_vn.js +60 -182
  39. package/src/machine/deposit/qrcode_v2.js +52 -285
  40. package/src/machine/deposit/qrcode_vn.js +206 -0
  41. package/src/machine/game.js +285 -0
  42. package/src/machine/game_favorite.js +123 -0
  43. package/src/machine/game_favorite_v2.js +28 -74
  44. package/src/machine/game_search.js +244 -0
  45. package/src/machine/game_search_v2.js +24 -64
  46. package/src/machine/game_v2.js +356 -0
  47. package/src/machine/inbox.js +34 -259
  48. package/src/machine/index.js +17 -26
  49. package/src/machine/leaderboard.js +8 -31
  50. package/src/machine/reward.js +7 -74
  51. package/src/machine/setting.js +2 -5
  52. package/src/machine/side_v2.js +28 -33
  53. package/src/machine/user_sign_up.js +17 -117
  54. package/src/machine/{withdraw/withdraw_crypto.js → withdraw_crypto.js} +69 -220
  55. package/src/machine/{withdraw/withdraw_fc.js → withdraw_fc.js} +2 -2
  56. package/src/machine/{withdraw/withdraw_amb.js → withdraw_vn.js} +78 -146
  57. package/src/request/request.js +5 -10
  58. package/src/util/constant.js +1 -19
  59. package/src/util/deviceToken.js +8 -18
  60. package/src/util/index.js +1 -2
  61. package/src/util/storage.js +22 -22
  62. package/.husky/pre-commit +0 -4
  63. package/.prettierignore +0 -1
  64. package/src/lib/fingerprint.js +0 -9779
  65. package/src/machine/activity/activity_cash.js +0 -159
  66. package/src/machine/activity/cash_rain_activity.js +0 -153
  67. package/src/machine/activity/diamond_shop_activity_cash.js +0 -179
  68. package/src/machine/activity/instant_rebate_activity.js +0 -195
  69. package/src/machine/activity/jackpot.js +0 -74
  70. package/src/machine/activity/otp_verified_activity.js +0 -74
  71. package/src/machine/activity/roulette_activity_v2.js +0 -90
  72. package/src/machine/activity/sign_in_monthly_activity.js +0 -65
  73. package/src/machine/activity/vip_card_activity.js +0 -140
  74. package/src/machine/bank_binding_amb.js +0 -145
  75. package/src/machine/deposit/amb.js +0 -92
  76. package/src/machine/deposit/crypto_bank.js +0 -317
  77. package/src/machine/deposit/crypto_bank_cash.js +0 -287
  78. package/src/machine/deposit/crypto_cash.js +0 -255
  79. package/src/machine/deposit/crypto_qrcode.js +0 -148
  80. package/src/machine/deposit/crypto_qrcode_cash.js +0 -131
  81. package/src/machine/deposit/crypto_way.js +0 -239
  82. package/src/machine/deposit/crypto_way_cash.js +0 -256
  83. package/src/machine/deposit/direct_cash.js +0 -217
  84. package/src/machine/deposit/float.js +0 -366
  85. package/src/machine/deposit/krway.js +0 -151
  86. package/src/machine/deposit/loadcard_cash.js +0 -207
  87. package/src/machine/deposit/manual_cash.js +0 -356
  88. package/src/machine/deposit/qrcode_cash.js +0 -217
  89. package/src/machine/deposit/usdt.js +0 -144
  90. package/src/machine/deposit/usdt_cash.js +0 -138
  91. package/src/machine/deposit/vpay.js +0 -359
  92. package/src/machine/game_info.js +0 -57
  93. package/src/machine/game_search_cash.js +0 -390
  94. package/src/machine/game_v2_1.js +0 -662
  95. package/src/machine/honor_board.js +0 -118
  96. package/src/machine/honor_board_cash.js +0 -89
  97. package/src/machine/navbar.js +0 -57
  98. package/src/machine/promotions.js +0 -171
  99. package/src/machine/reward_cash.js +0 -219
  100. package/src/machine/roulette_v2.js +0 -276
  101. package/src/machine/side_cash.js +0 -110
  102. package/src/machine/user_photo.js +0 -65
  103. package/src/machine/withdraw/index.js +0 -23
  104. package/src/machine/withdraw/withdraw_crypto2.js +0 -540
  105. package/src/machine/withdraw/withdraw_crypto_cash.js +0 -319
  106. package/src/machine/withdraw/withdraw_krway.js +0 -220
  107. package/src/machine/withdraw/withdraw_manual.js +0 -610
  108. package/src/machine/withdraw/withdraw_manual_cash.js +0 -303
  109. package/src/machine/withdraw/withdraw_vn.js +0 -546
  110. package/src/machine/withdraw/withdraw_vn2.js +0 -561
  111. package/src/util/math.js +0 -4
@@ -0,0 +1,356 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import api from '../api/game.js'
3
+ import UAParser from 'ua-parser-js'
4
+ import { GAME_SEARCH } from '../util/constant.js'
5
+
6
+ export default function (request) {
7
+ return createMachine(
8
+ {
9
+ id: 'game',
10
+ type: 'parallel',
11
+ context: {
12
+ room: null,
13
+ index: 0,
14
+ content: {
15
+ data: [],
16
+ timestamp: null,
17
+ parentCategoryId: null,
18
+ totalPage: 1,
19
+ },
20
+ // play params
21
+ game: {
22
+ providerId: null,
23
+ gameId: null,
24
+ gameTypeId: null,
25
+ mappingId: null,
26
+ portrait: null,
27
+ },
28
+ lang: 'en_US',
29
+ isMobile: new UAParser().getResult().device.type,
30
+ gameURL: null,
31
+ ...oldContext
32
+ },
33
+ states: {
34
+ flow: {
35
+ initial: 'idle',
36
+ states: {
37
+ idle: {
38
+ enter: 'clearGameInfo',
39
+ on: {
40
+ ENTER_ROOM: {
41
+ target: 'loading',
42
+ cond: 'isDifferentRoom',
43
+ actions: ['setRoom', 'resetContent'],
44
+ },
45
+ NEXT_PAGE: {
46
+ target: 'loading',
47
+ cond: 'hasNext',
48
+ actions: 'increaseIndex',
49
+ },
50
+ ENTER_GAME: {
51
+ target: 'connecting',
52
+ actions: ['setGameInfo', 'setLang'],
53
+ },
54
+ },
55
+ },
56
+ loading: {
57
+ invoke: {
58
+ src: 'getPageContent',
59
+ onDone: {
60
+ target: 'idle',
61
+ actions: 'appendContent',
62
+ },
63
+ onError: {
64
+ target: 'idle',
65
+ },
66
+ },
67
+ },
68
+ connecting: {
69
+ invoke: {
70
+ src: 'connectGame',
71
+ onDone: {
72
+ target: 'playing',
73
+ actions: 'setGameURL',
74
+ },
75
+ onError: {
76
+ target: 'idle',
77
+ },
78
+ },
79
+ },
80
+ playing: {
81
+ on: {
82
+ EXIT_GAME: {
83
+ target: 'disconnect',
84
+ },
85
+ },
86
+ },
87
+ disconnect: {
88
+ invoke: {
89
+ src: 'disconnectGame',
90
+ onDone: {
91
+ target: 'idle',
92
+ },
93
+ onError: {
94
+ target: 'idle',
95
+ },
96
+ },
97
+ },
98
+ },
99
+ },
100
+ timer: {
101
+ initial: 'pending',
102
+ states: {
103
+ pending: {
104
+ after: {
105
+ 20000: [
106
+ {
107
+ target: 'updating',
108
+ cond: 'hasRoom',
109
+ },
110
+ {
111
+ target: 'pending',
112
+ },
113
+ ],
114
+ },
115
+ },
116
+ updating: {
117
+ invoke: {
118
+ src: 'updatePageContent',
119
+ onDone: {
120
+ target: 'pending',
121
+ actions: 'swapContent',
122
+ },
123
+ onError: {
124
+ target: 'pending',
125
+ },
126
+ },
127
+ },
128
+ },
129
+ },
130
+ oldTimer: {
131
+ initial: 'fetchingGameSHA',
132
+ states: {
133
+ fetchingGameSHA: {
134
+ invoke: {
135
+ src: 'fetchGameSHA',
136
+ onDone: {
137
+ target: 'checking',
138
+ actions: 'setGameSHA',
139
+ },
140
+ onError: {
141
+ target: 'pending',
142
+ },
143
+ },
144
+ },
145
+ checking: {
146
+ always: [
147
+ { target: 'updatingStatus', cond: 'isStatusChanged' },
148
+ { target: 'pending' },
149
+ ],
150
+ },
151
+ updatingStatus: {
152
+ invoke: {
153
+ src: 'fetchStatus',
154
+ onDone: {
155
+ target: 'updatingOption',
156
+ actions: ['setStatus'],
157
+ },
158
+ onError: {
159
+ target: 'pending',
160
+ },
161
+ },
162
+ },
163
+ updatingOption: {
164
+ invoke: {
165
+ src: 'fetchOption',
166
+ onDone: {
167
+ target: 'pending',
168
+ actions: 'mergeOption',
169
+ },
170
+ onError: {
171
+ target: 'pending',
172
+ },
173
+ },
174
+ },
175
+ pending: {
176
+ after: {
177
+ 20000: {
178
+ target: 'fetchingGameSHA',
179
+ },
180
+ },
181
+ },
182
+ },
183
+ },
184
+ },
185
+ },
186
+ {
187
+ actions: {
188
+ setFavoriteList: assign((context, event) => {
189
+ return {
190
+ favoriteList: event.data.data || [],
191
+ }
192
+ }),
193
+ setRoom: assign((context, event) => {
194
+ return {
195
+ room: event.data,
196
+ }
197
+ }),
198
+ resetContent: assign((context, event) => {
199
+ return {
200
+ index: 0,
201
+ content: {
202
+ data: [],
203
+ timestamp: null,
204
+ parentCategoryId: null,
205
+ totalPage: 1,
206
+ },
207
+ }
208
+ }),
209
+ appendContent: assign((context, event) => {
210
+ const { room, favoriteList } = context
211
+ if (room.categoryId === GAME_SEARCH) {
212
+ return
213
+ } else {
214
+ const { data, ...rest } = event.data
215
+ return {
216
+ content: {
217
+ ...context.content,
218
+ ...rest,
219
+ data: context.content.data.concat(data),
220
+ },
221
+ }
222
+ }
223
+ }),
224
+ swapContent: assign((context, event) => {
225
+ const item = event.data
226
+ if (item.data?.length) {
227
+ return {
228
+ content: event.data,
229
+ }
230
+ }
231
+ }),
232
+ increaseIndex: assign((context, event) => {
233
+ return {
234
+ index: context.index + 1,
235
+ }
236
+ }),
237
+ setGameURL: assign({
238
+ gameURL: (context, event) => {
239
+ return event.data.gameURL
240
+ },
241
+ }),
242
+ clearGameInfo: assign((context, event) => {
243
+ return { game: { providerId: null, gameId: null, gameTypeId: null, mappingId: null } }
244
+ }),
245
+ setGameInfo: assign((context, event) => {
246
+ const { providerId, gameId, gameTypeId, mappingId, portrait } = event.data.game
247
+ return { game: { providerId, gameId, gameTypeId, mappingId, portrait: portrait ? 1 : 0 } }
248
+ }),
249
+ setLang: assign((context, event) => {
250
+ const lang = event.data.locale.replace('-', '_')
251
+ return { lang }
252
+ }),
253
+ ...oldActions
254
+ },
255
+ guards: {
256
+ isDifferentRoom: (context, event) => context.room?.categoryId !== event.data?.categoryId,
257
+ hasNext: (context, event) => context.index < context?.content?.totalPage - 1,
258
+ hasRoom: (context, event) => context.room?.categoryId,
259
+ ...oldGuards
260
+ },
261
+ services: {
262
+ getPageContent: async (context, event) => {
263
+ const { room, index } = context
264
+ if (room.categoryId === GAME_SEARCH) {
265
+ return
266
+ } else {
267
+ return await request.send(api.getListCategory({ categoryId: room.categoryId, index }))
268
+ }
269
+ },
270
+ updatePageContent: async (context, event) => {
271
+ const { room, content, index } = context
272
+ if (room.categoryId === GAME_SEARCH) {
273
+ return
274
+ } else {
275
+ return await request.send(
276
+ api.getListCategoryByRange({
277
+ categoryId: room.categoryId,
278
+ end: index,
279
+ timestamp: content.timestamp,
280
+ })
281
+ )
282
+ }
283
+ },
284
+ connectGame: async (context, event) => {
285
+ const { lang, isMobile } = context
286
+ const { providerId, gameId, gameTypeId, mappingId } = context.game
287
+ const params = {
288
+ provider_id: providerId,
289
+ game_id: gameId,
290
+ gametype_id: gameTypeId,
291
+ mapping_id: mappingId,
292
+ is_demo: false,
293
+ is_mobile: isMobile,
294
+ lang,
295
+ return_url: window.location.href,
296
+ }
297
+ const { redirect_url } = await request.send(api.playGame(params))
298
+ return { gameURL: redirect_url }
299
+ },
300
+ disconnectGame: async (context, event) => {
301
+ const uid_site = event.data
302
+ const provider_id = context.game.providerId
303
+ return await request.send(api.logoutGame({ uid_site, provider_id }))
304
+ },
305
+ ...oldServices(request)
306
+ },
307
+ }
308
+ )
309
+ }
310
+
311
+ const oldContext = {
312
+ sha: {
313
+ status: null,
314
+ },
315
+ isStatusChanged: false,
316
+ statusMap: {},
317
+ optionMap: {},
318
+ }
319
+
320
+ const oldActions = {
321
+ setGameSHA: assign((context, event) => {
322
+ const { sha } = context
323
+ const newSha = event.data
324
+ return {
325
+ sha: newSha,
326
+ isStatusChanged: !sha.status || sha.status !== newSha.status,
327
+ }
328
+ }),
329
+ setStatus: assign((context, event) => {
330
+ return {
331
+ statusMap: event.data,
332
+ }
333
+ }),
334
+ mergeOption: assign((context, event) => {
335
+ const { optionMap } = context
336
+ return {
337
+ optionMap: { ...optionMap, ...event.data },
338
+ }
339
+ }),
340
+ }
341
+
342
+ const oldGuards = {
343
+ isStatusChanged: (context, event) => context.isStatusChanged,
344
+ }
345
+
346
+ const oldServices = (request) => ({
347
+ fetchOption: async (context, event) => {
348
+ return await request.send(api.getOptionMap())
349
+ },
350
+ fetchGameSHA: async (context, event) => {
351
+ return await request.send(api.getGameSHA())
352
+ },
353
+ fetchStatus: async (context, event) => {
354
+ return await request.send(api.getGameStatus())
355
+ },
356
+ })