@jetthai/cuora 1.0.204 → 1.0.302-dev-1

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 (110) hide show
  1. package/.husky/pre-commit +4 -0
  2. package/.prettierignore +1 -0
  3. package/CHANGELOG.md +848 -0
  4. package/README.md +6 -0
  5. package/package.json +6 -9
  6. package/src/api/activity.js +43 -2
  7. package/src/api/auth.js +22 -7
  8. package/src/api/common.js +3 -1
  9. package/src/api/game.js +20 -7
  10. package/src/api/mailbox.js +9 -5
  11. package/src/api/payment.js +167 -19
  12. package/src/api/user.js +7 -0
  13. package/src/lib/fingerprint.js +9779 -0
  14. package/src/machine/activity/activity.js +111 -26
  15. package/src/machine/activity/activity_cash.js +159 -0
  16. package/src/machine/activity/cash_rain_activity.js +153 -0
  17. package/src/machine/activity/continue_deposit_activity.js +11 -2
  18. package/src/machine/activity/deposit_activity.js +13 -4
  19. package/src/machine/activity/diamond_shop_activity_cash.js +179 -0
  20. package/src/machine/activity/diamond_shop_activity_vn.js +54 -89
  21. package/src/machine/activity/fafafa_activity.js +34 -19
  22. package/src/machine/activity/{affiliate_invite_friends_activity.js → friend_invite_friends_activity.js} +72 -45
  23. package/src/machine/activity/index.js +22 -4
  24. package/src/machine/activity/instant_rebate_activity.js +217 -0
  25. package/src/machine/activity/invite_friends_activity.js +14 -14
  26. package/src/machine/activity/jackpot.js +74 -0
  27. package/src/machine/activity/otp_verified_activity.js +74 -0
  28. package/src/machine/activity/ranking_activity.js +11 -2
  29. package/src/machine/activity/roulette_activity_v2.js +90 -0
  30. package/src/machine/activity/sign_in_activity.js +21 -14
  31. package/src/machine/activity/sign_in_monthly_activity.js +65 -0
  32. package/src/machine/activity/specify_bets_activity.js +25 -3
  33. package/src/machine/activity/specify_turnover_activity.js +25 -3
  34. package/src/machine/activity/time_bomb_activity.js +11 -2
  35. package/src/machine/activity/vip_card_activity.js +140 -0
  36. package/src/machine/auth.js +141 -27
  37. package/src/machine/auth_otp_v2.js +10 -4
  38. package/src/machine/auth_otp_v3.js +11 -3
  39. package/src/machine/bank_binding.js +112 -12
  40. package/src/machine/bank_binding_amb.js +145 -0
  41. package/src/machine/common.js +113 -25
  42. package/src/machine/deposit/amb.js +92 -0
  43. package/src/machine/deposit/crypto.js +50 -29
  44. package/src/machine/deposit/crypto_bank.js +317 -0
  45. package/src/machine/deposit/crypto_bank_cash.js +287 -0
  46. package/src/machine/deposit/crypto_button.js +174 -39
  47. package/src/machine/deposit/crypto_cash.js +255 -0
  48. package/src/machine/deposit/crypto_qrcode.js +148 -0
  49. package/src/machine/deposit/crypto_qrcode_cash.js +131 -0
  50. package/src/machine/deposit/crypto_way.js +239 -0
  51. package/src/machine/deposit/crypto_way_cash.js +256 -0
  52. package/src/machine/deposit/deposit_fc.js +8 -5
  53. package/src/machine/deposit/direct.js +111 -16
  54. package/src/machine/deposit/direct_cash.js +217 -0
  55. package/src/machine/deposit/float.js +366 -0
  56. package/src/machine/deposit/index.js +43 -2
  57. package/src/machine/deposit/krway.js +151 -0
  58. package/src/machine/deposit/loadcard_cash.js +207 -0
  59. package/src/machine/deposit/loadcard_vn.js +191 -43
  60. package/src/machine/deposit/manual_cash.js +356 -0
  61. package/src/machine/deposit/manual_vn.js +182 -60
  62. package/src/machine/deposit/qrcode_cash.js +217 -0
  63. package/src/machine/deposit/qrcode_v2.js +285 -52
  64. package/src/machine/deposit/usdt.js +144 -0
  65. package/src/machine/deposit/usdt_cash.js +138 -0
  66. package/src/machine/deposit/vpay.js +359 -0
  67. package/src/machine/game_favorite_v2.js +70 -28
  68. package/src/machine/game_info.js +57 -0
  69. package/src/machine/game_search_cash.js +390 -0
  70. package/src/machine/game_search_v2.js +64 -24
  71. package/src/machine/game_v2_1.js +662 -0
  72. package/src/machine/honor_board_cash.js +63 -0
  73. package/src/machine/inbox.js +259 -34
  74. package/src/machine/index.js +24 -17
  75. package/src/machine/leaderboard.js +31 -8
  76. package/src/machine/navbar.js +57 -0
  77. package/src/machine/promotions.js +171 -0
  78. package/src/machine/reward.js +74 -7
  79. package/src/machine/reward_cash.js +219 -0
  80. package/src/machine/roulette_v2.js +276 -0
  81. package/src/machine/setting.js +5 -2
  82. package/src/machine/side_cash.js +110 -0
  83. package/src/machine/side_v2.js +33 -28
  84. package/src/machine/user_photo.js +65 -0
  85. package/src/machine/user_sign_up.js +117 -17
  86. package/src/machine/withdraw/index.js +23 -0
  87. package/src/machine/{withdraw_vn.js → withdraw/withdraw_amb.js} +146 -78
  88. package/src/machine/{withdraw_crypto.js → withdraw/withdraw_crypto.js} +220 -69
  89. package/src/machine/withdraw/withdraw_crypto2.js +540 -0
  90. package/src/machine/withdraw/withdraw_crypto_cash.js +319 -0
  91. package/src/machine/{withdraw_fc.js → withdraw/withdraw_fc.js} +2 -2
  92. package/src/machine/withdraw/withdraw_krway.js +207 -0
  93. package/src/machine/withdraw/withdraw_manual.js +595 -0
  94. package/src/machine/withdraw/withdraw_manual_cash.js +303 -0
  95. package/src/machine/withdraw/withdraw_vn.js +533 -0
  96. package/src/machine/withdraw/withdraw_vn2.js +548 -0
  97. package/src/request/request.js +10 -5
  98. package/src/util/constant.js +19 -1
  99. package/src/util/deviceToken.js +18 -8
  100. package/src/util/index.js +2 -1
  101. package/src/util/math.js +4 -0
  102. package/src/util/storage.js +22 -22
  103. package/dist/bundle.mjs +0 -18462
  104. package/rollup.config.js +0 -16
  105. package/src/machine/auth_otp.js +0 -201
  106. package/src/machine/deposit/qrcode_vn.js +0 -206
  107. package/src/machine/game.js +0 -285
  108. package/src/machine/game_favorite.js +0 -123
  109. package/src/machine/game_search.js +0 -244
  110. package/src/machine/game_v2.js +0 -356
@@ -0,0 +1,548 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import findLastIndex from 'lodash/findLastIndex.js'
3
+ import payment from '../../api/payment.js'
4
+ import user from '../../api/user.js'
5
+
6
+ export default function (request) {
7
+ const { appSecret } = request.config
8
+ return createMachine(
9
+ {
10
+ id: 'withdraw_vn2',
11
+ initial: 'loading',
12
+ context: {
13
+ mode: null,
14
+ siteConfig: null,
15
+ balance: null,
16
+ charge: null,
17
+ realAmount: null,
18
+ applyId: null,
19
+ methods: [],
20
+ paymentDetail: [],
21
+ bankInfo: [],
22
+ bankList: [],
23
+ currentWithdrawLimit: null,
24
+ targetWithdrawLimit: null,
25
+ attachmentType: null, // null | 'withdraw' | 'pool'
26
+ enableWithdrawAmount: 0,
27
+ enableWithdraw: false,
28
+ withdrawRules: [],
29
+ withdrawRule: {},
30
+ withdrawCheck: {},
31
+
32
+ amount: null,
33
+ bank: null,
34
+ branch: null,
35
+ holderName: null,
36
+
37
+ // otp
38
+ requestId: null,
39
+ status: null,
40
+ target: null,
41
+ ttl: null,
42
+ },
43
+ states: {
44
+ loading: {
45
+ invoke: {
46
+ src: 'fetchInitData',
47
+ onDone: {
48
+ target: 'pending',
49
+ actions: ['setInitData', 'preset'],
50
+ },
51
+ onError: {
52
+ target: 'fail',
53
+ },
54
+ },
55
+ },
56
+ pending: {
57
+ on: {
58
+ SET_MODE: {
59
+ target: 'fetching',
60
+ actions: 'setMode',
61
+ },
62
+ },
63
+ },
64
+ fetching: {
65
+ invoke: {
66
+ src: 'fetchWithdrawRules',
67
+ onDone: {
68
+ target: 'mode',
69
+ actions: 'updateWithdrawCondition',
70
+ },
71
+ onError: {
72
+ target: '#withdraw_vn2.fail',
73
+ },
74
+ },
75
+ },
76
+ mode: {
77
+ always: [{ target: 'activity', cond: 'isActivity' }, { target: 'cash' }],
78
+ },
79
+ activity: {
80
+ initial: 'checking',
81
+ states: {
82
+ checking: {
83
+ always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
84
+ },
85
+ notConvertible: {
86
+ on: {
87
+ GIVE_UP: {
88
+ target: 'fetchWithdrawRule',
89
+ },
90
+ },
91
+ },
92
+ fetchWithdrawRule: {
93
+ invoke: {
94
+ src: 'fetchWithdrawRulePreview',
95
+ onDone: {
96
+ target: 'giveUp',
97
+ actions: 'setWithdrawRulePreview',
98
+ },
99
+ onError: {
100
+ target: 'notConvertible',
101
+ },
102
+ },
103
+ },
104
+ giveUp: {
105
+ on: {
106
+ CONFIRM: {
107
+ target: 'givingUp',
108
+ },
109
+ BACK: {
110
+ target: 'notConvertible',
111
+ },
112
+ },
113
+ },
114
+ givingUp: {
115
+ invoke: {
116
+ src: 'giveUp',
117
+ onDone: {
118
+ target: 'gaveUp',
119
+ },
120
+ onError: {
121
+ target: 'convertible',
122
+ },
123
+ },
124
+ },
125
+ gaveUp: {},
126
+ convertible: {
127
+ on: {
128
+ SUBMIT: {
129
+ target: 'converting',
130
+ actions: 'setAttachmentType',
131
+ },
132
+ },
133
+ },
134
+ converting: {
135
+ invoke: {
136
+ src: 'convertFreeCredit',
137
+ onDone: [
138
+ {
139
+ target: '#withdraw_vn2.otp',
140
+ actions: 'setOtp',
141
+ cond: 'isOtpRequired',
142
+ },
143
+ { target: 'converted' },
144
+ ],
145
+ onError: {
146
+ target: 'convertible',
147
+ },
148
+ },
149
+ },
150
+ converted: {
151
+ always: [
152
+ { target: '#withdraw_vn2.cash.unbound', cond: 'isBankNotBound' },
153
+ { target: '#withdraw_vn2.cash.withdrawable', cond: 'hasAttachmentType' },
154
+ ],
155
+ },
156
+ },
157
+ },
158
+ cash: {
159
+ initial: 'checking',
160
+ states: {
161
+ checking: {
162
+ always: [
163
+ { target: 'inProcessing', cond: 'haveProcessing' },
164
+ { target: 'unbound', cond: 'isBankNotBound' },
165
+ { target: 'withdrawCheck' },
166
+ ],
167
+ },
168
+ withdrawCheck: {
169
+ invoke: {
170
+ src: 'withdrawCheck',
171
+ onDone: [
172
+ {
173
+ target: 'notWithdrawMinDepositAmount',
174
+ cond: 'isNotWithdrawMinDepositAmount',
175
+ actions: assign((context, event) => {
176
+ return {
177
+ withdrawCheck: event.data,
178
+ }
179
+ }),
180
+ },
181
+ {
182
+ target: 'notWithdrawable',
183
+ cond: 'isNotWithdrawable',
184
+ },
185
+ {
186
+ target: 'withdrawable',
187
+ },
188
+ ],
189
+ onError: {
190
+ target: '#withdraw_vn2.fail',
191
+ },
192
+ },
193
+ },
194
+ notWithdrawMinDepositAmount: {},
195
+ notWithdrawable: {},
196
+ unbound: {
197
+ // to bank_binding.js
198
+ },
199
+ inProcessing: {},
200
+ withdrawable: {
201
+ on: {
202
+ SET_CURRENT_BANK: {
203
+ actions: assign((context, event) => {
204
+ return {
205
+ bank: event.data,
206
+ }
207
+ }),
208
+ },
209
+ SET_AMOUNT: {
210
+ actions: assign((context, event) => {
211
+ return {
212
+ amount: event.data,
213
+ }
214
+ }),
215
+ },
216
+ SET_ATTACHMENT_TYPE: {
217
+ actions: 'setAttachmentType',
218
+ },
219
+ SUBMIT: [
220
+ {
221
+ target: 'pooling',
222
+ cond: (context, event) => {
223
+ const { amount, attachmentType } = context
224
+ return attachmentType === 'pool' && amount > 0
225
+ },
226
+ },
227
+ {
228
+ target: 'submitting',
229
+ cond: 'isSubmittable',
230
+ },
231
+ ],
232
+ },
233
+ },
234
+ submitting: {
235
+ invoke: {
236
+ src: 'submitWithdraw',
237
+ onDone: [
238
+ {
239
+ target: '#withdraw_vn2.otp',
240
+ actions: 'setOtp',
241
+ cond: 'isOtpRequired',
242
+ },
243
+ {
244
+ target: 'submitted',
245
+ },
246
+ ],
247
+ onError: {
248
+ target: 'withdrawable',
249
+ },
250
+ },
251
+ },
252
+ submitted: {
253
+ entry: assign((context, event) => {
254
+ const { applyId, balance, realAmount, charge } = event.data
255
+ return { applyId, balance, realAmount, charge }
256
+ }),
257
+ invoke: {
258
+ src: 'fetchPaymentData',
259
+ onDone: {
260
+ target: 'inProcessing',
261
+ actions: 'setPaymentData',
262
+ },
263
+ onError: {
264
+ target: '#withdraw_vn2.fail',
265
+ },
266
+ },
267
+ },
268
+ pooling: {
269
+ invoke: {
270
+ src: 'pool',
271
+ onDone: { target: 'pooled' },
272
+ onError: {
273
+ target: 'withdrawable',
274
+ },
275
+ },
276
+ },
277
+ pooled: {},
278
+ },
279
+ },
280
+ otp: {
281
+ type: 'parallel',
282
+ states: {
283
+ countdown: {
284
+ after: {
285
+ 1000: {
286
+ target: 'countdown',
287
+ actions: 'decreaseTtl',
288
+ cond: (context) => context.ttl > 0,
289
+ },
290
+ },
291
+ },
292
+ verification: {
293
+ initial: 'idle',
294
+ states: {
295
+ idle: {
296
+ on: {
297
+ ACKNOWLEDGE: {
298
+ target: 'acknowledging',
299
+ },
300
+ RESET_OTP: {
301
+ target: 'reset',
302
+ },
303
+ BACK: [
304
+ {
305
+ target: '#withdraw_vn2.activity.convertible',
306
+ cond: 'isActivity',
307
+ },
308
+ {
309
+ target: '#withdraw_vn2.cash.withdrawable',
310
+ },
311
+ ],
312
+ },
313
+ },
314
+ acknowledging: {
315
+ invoke: {
316
+ src: 'acknowledge',
317
+ onDone: [
318
+ {
319
+ target: '#withdraw_vn2.activity.converted',
320
+ cond: 'isActivity',
321
+ },
322
+ {
323
+ target: '#withdraw_vn2.cash.submitted',
324
+ },
325
+ ],
326
+ onError: {
327
+ target: 'idle',
328
+ },
329
+ },
330
+ },
331
+ reset: {
332
+ invoke: {
333
+ src: 'resetOtp',
334
+ onDone: {
335
+ target: 'idle',
336
+ actions: 'setVerificationData',
337
+ },
338
+ onError: { target: 'idle' },
339
+ },
340
+ },
341
+ },
342
+ },
343
+ },
344
+ },
345
+ fail: {},
346
+ },
347
+ on: {
348
+ REFRESH: {
349
+ target: 'loading',
350
+ },
351
+ },
352
+ },
353
+ {
354
+ actions: {
355
+ setInitData: assign((context, event) => {
356
+ const { paymentDetail, bankInfo, bonus, bankList } = event.data
357
+ return {
358
+ paymentDetail,
359
+ bankInfo,
360
+ bank: bankInfo[0],
361
+ bonus,
362
+ bankList,
363
+ }
364
+ }),
365
+ preset: assign((context, event) => {
366
+ const { siteConfig } = context
367
+ const methods = siteConfig?.paymentMethods?.withdraw || []
368
+ return {
369
+ methods,
370
+ attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
371
+ }
372
+ }),
373
+ setMode: assign((context, event) => {
374
+ return {
375
+ mode: event.data,
376
+ }
377
+ }),
378
+ updateWithdrawCondition: assign((context, event) => {
379
+ const { enableWithdraw, enableWithdrawAmount, currentWithdrawLimit, targetWithdrawLimit, balance } = event.data
380
+ const withdrawRules = event.data?.rules || []
381
+ const rules = withdrawRules.filter((rule) => rule.maxWithdrawAmount > 0)
382
+ const lastMatchedIndex = findLastIndex(rules, (rule) => balance >= rule.greaterEqualThen)
383
+
384
+ let maxWithdrawAmount = 0
385
+
386
+ if (lastMatchedIndex > -1) {
387
+ rules[lastMatchedIndex].match = true
388
+ maxWithdrawAmount = rules[lastMatchedIndex].maxWithdrawAmount
389
+ } else if (rules.length > 0) {
390
+ maxWithdrawAmount = rules[0].maxWithdrawAmount
391
+ } else {
392
+ maxWithdrawAmount = balance
393
+ }
394
+
395
+ return {
396
+ balance,
397
+ currentWithdrawLimit,
398
+ targetWithdrawLimit,
399
+ maxWithdrawAmount,
400
+ enableWithdrawAmount: +enableWithdrawAmount,
401
+ enableWithdraw,
402
+ withdrawRules,
403
+ }
404
+ }),
405
+ setWithdrawRulePreview: assign((context, event) => {
406
+ return {
407
+ withdrawRule: event.data,
408
+ }
409
+ }),
410
+ setPaymentData: assign((context, event) => {
411
+ const { bankInfo, bonus, paymentDetail } = event.data
412
+ return {
413
+ bankInfo,
414
+ bonus,
415
+ paymentDetail,
416
+ }
417
+ }),
418
+ setOtp: assign((context, event) => {
419
+ const { requestId, status, target, ttl } = event.data
420
+ return {
421
+ requestId,
422
+ status,
423
+ target,
424
+ ttl,
425
+ }
426
+ }),
427
+ decreaseTtl: assign((context, evnet) => {
428
+ const second = context.ttl
429
+ return {
430
+ ttl: Math.max(second - 1, 0),
431
+ }
432
+ }),
433
+ setVerificationData: assign((context, event) => {
434
+ const { requestId, ttl, target } = event.data
435
+ return {
436
+ requestId,
437
+ ttl,
438
+ target,
439
+ }
440
+ }),
441
+ setAttachmentType: assign((context, event) => {
442
+ return {
443
+ attachmentType: event.data,
444
+ }
445
+ }),
446
+ },
447
+ guards: {
448
+ isActivity: (context, event) => {
449
+ return context.mode === 'ACTIVITY'
450
+ },
451
+ hasAttachmentType: (context, event) => {
452
+ return ['withdraw', 'pool'].includes(context.attachmentType)
453
+ },
454
+ haveProcessing: (context, event) => {
455
+ return (context.paymentDetail?.[0]?.processing || []).length > 0
456
+ },
457
+ isBankNotBound: (context, event) => {
458
+ return !context.bankInfo?.length
459
+ },
460
+ isSubmittable: (context, event) => {
461
+ const { bank, amount } = context
462
+ return bank && amount > 0
463
+ },
464
+ isConvertible: (context, event) => {
465
+ const { balance, enableWithdraw } = context
466
+ return balance > 0 && enableWithdraw
467
+ },
468
+ isNotWithdrawable: (context, event) => {
469
+ const { balance, enableWithdraw, paymentDetail } = context
470
+ const minWithdrawAmount = paymentDetail[0]?.minimum || 0
471
+ return !enableWithdraw || balance < minWithdrawAmount
472
+ },
473
+ isOtpRequired: (context, event) => {
474
+ return event.data?.status === 'otp-verifying'
475
+ },
476
+ isNotWithdrawMinDepositAmount: (context, event) => {
477
+ return !event.data?.enableWithdraw
478
+ },
479
+ },
480
+ services: {
481
+ fetchInitData: async (context, event) => {
482
+ const [paymentDetail = [], { bonus, bankInfo }] = await Promise.all([
483
+ request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' })),
484
+ request.send(payment.getPaymentInfo()),
485
+ ])
486
+ const bankList = await request.send(payment.getWithdrawBankList())
487
+ const newBankInfo = bankInfo
488
+ .map((item) => {
489
+ const matchedBank = bankList.find((bank) => bank.bankCode === item.bankCode)
490
+ return matchedBank ? { ...item, ...matchedBank } : null
491
+ })
492
+ .filter(Boolean)
493
+ return { paymentDetail, bonus, bankInfo: newBankInfo, bankList }
494
+ },
495
+ fetchPaymentData: async (context, event) => {
496
+ const paymentDetail = await request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' }))
497
+ const { bonus, bankInfo } = await request.send(payment.getPaymentInfo())
498
+ return { bonus, bankInfo, paymentDetail }
499
+ },
500
+ fetchWithdrawRules: async (context, event) => {
501
+ const { mode } = context
502
+ return await request.send(payment.getDoubleWalletWithdrawRule({ walletType: mode }))
503
+ },
504
+ fetchWithdrawRulePreview: async (context, event) => {
505
+ const data = await request.send(payment.getWithdrawRulePreview({ applyType: 'giveup' }))
506
+ return data
507
+ },
508
+ submitWithdraw: async (context, event) => {
509
+ const { bank, amount } = context
510
+ const { method } = context.paymentDetail[0]
511
+ const branchTemp = ['GCASH', 'PAYM', 'PIX'].includes(bank.bankCode) ? '' : bank.branch
512
+ return await request.send(
513
+ payment.submitWithdrawTransactionVN({
514
+ method,
515
+ amount,
516
+ applyerBankCode: bank.bankCode,
517
+ applyerAccountNumber: bank.accountNumber,
518
+ branch: branchTemp,
519
+ holderName: bank.holderName,
520
+ })
521
+ )
522
+ },
523
+ convertFreeCredit: async (context, event) => {
524
+ return await request.send(payment.convertFreeCredit({ exchangeType: 1 }))
525
+ },
526
+ resetOtp: async (context, event) => {
527
+ const { requestId, target } = context
528
+ return await request.send(user.otpReset({ requestId, target }))
529
+ },
530
+ acknowledge: async (context, event) => {
531
+ const { requestId, target } = context
532
+ const code = event.data
533
+ return await request.send(user.otpAcknowledge({ requestId, target, code }))
534
+ },
535
+ pool: async (context, event) => {
536
+ const { amount } = context
537
+ return await request.send(payment.restore({ amount }))
538
+ },
539
+ giveUp: async (context, event) => {
540
+ return await request.send(payment.giveUp())
541
+ },
542
+ withdrawCheck: async (context, event) => {
543
+ return await request.send(payment.withdrawCheck())
544
+ },
545
+ },
546
+ }
547
+ )
548
+ }
@@ -14,6 +14,7 @@ export default class Request {
14
14
  this.config = config
15
15
  this.key = `cuora_${config.clientId}`
16
16
  this.errorHandler = null
17
+ this.hosts = []
17
18
  this.initialize()
18
19
  }
19
20
 
@@ -21,8 +22,8 @@ export default class Request {
21
22
  this.axios.interceptors.request.use((axiosConfig) => {
22
23
  axiosConfig.headers['X-TH1GAMES-VERSION'] = this.config.version
23
24
  axiosConfig.headers['X-TH1GAMES-PLATFORM'] = this.config.platform
24
- if (storage.get(this.key)) {
25
- axiosConfig.headers.Authorization = storage.get(this.key)
25
+ if (this.getToken()) {
26
+ axiosConfig.headers.Authorization = this.getToken()
26
27
  }
27
28
  return axiosConfig
28
29
  })
@@ -50,7 +51,7 @@ export default class Request {
50
51
  async send(req, customToken) {
51
52
  try {
52
53
  const cancelToken = customToken || this.source.token
53
- this._checkToken(req, storage.get(this.key))
54
+ this._checkToken(req)
54
55
  const requestConfig = this._createConfig(req, cancelToken)
55
56
  const { data } = await this.axios.request(requestConfig)
56
57
  return data
@@ -96,10 +97,14 @@ export default class Request {
96
97
  }
97
98
  }
98
99
 
99
- _checkToken(req, token) {
100
- if (!req.isPublic && !token) {
100
+ _checkToken(req) {
101
+ if (!req.isPublic && !this.getToken()) {
101
102
  console.error(req)
102
103
  throw { code: 'ERR_A103', url: req.url }
103
104
  }
104
105
  }
106
+
107
+ getToken() {
108
+ return storage.get(this.key)
109
+ }
105
110
  }
@@ -1,2 +1,20 @@
1
1
  export const MY_FAVORITE = 'MyFavorite'
2
- export const GAME_SEARCH = 'GameSearch'
2
+ export const GAME_SEARCH = 'GameSearch'
3
+ export const GAME_TYPE_LIST = [
4
+ { typeId: 'SLOT', name: 'Slots', gameTypeMappingId: 1 },
5
+ { typeId: 'FISH', name: 'Fishing', gameTypeMappingId: 2 },
6
+ { typeId: 'ARCADE', name: 'Arcades', gameTypeMappingId: 3 },
7
+ { typeId: 'LOTTERY', name: 'Lottery', gameTypeMappingId: 4 },
8
+ { typeId: 'CARD', name: 'Card', gameTypeMappingId: 5 },
9
+ { typeId: 'TABLE', name: 'Table', gameTypeMappingId: 6 },
10
+ { typeId: 'BINGO', name: 'Bingo', gameTypeMappingId: 7 },
11
+ { typeId: 'LIVE', name: 'Live', gameTypeMappingId: 8 },
12
+ { typeId: 'SCRATCHCARDS', name: 'Scratch Cards', gameTypeMappingId: 9 },
13
+ { typeId: 'EGAME', name: 'E-Game', gameTypeMappingId: 10 },
14
+ { typeId: 'BONUS', name: 'Bonus', gameTypeMappingId: 11 },
15
+ { typeId: 'BALL', name: 'Ball', gameTypeMappingId: 12 },
16
+ { typeId: 'PACHINKO', name: 'Pachinko', gameTypeMappingId: 13 },
17
+ { typeId: 'GRAPH', name: 'Graph', gameTypeMappingId: 14 },
18
+ { typeId: 'TURBO', name: 'Turbo', gameTypeMappingId: 15 },
19
+ { typeId: 'SPORT', name: 'Sports', gameTypeMappingId: 16 },
20
+ ]
@@ -1,12 +1,21 @@
1
- import FingerprintJS from '@fingerprintjs/fingerprintjs-pro'
1
+ import uniqBy from 'lodash/uniqBy'
2
+ import { load, defaultEndpoint } from '../lib/fingerprint.js'
3
+
2
4
  const reg = /fnapi\d*/
3
- // const reg = /(?<=https:\/\/)\w+(?=(\.\w+\.\w+))/
4
5
 
5
- const getDeviceToken = async ({ fpToken, sentry, apiURL }) => {
6
- let dt, endpoint
6
+ const getDeviceToken = async ({ fpToken, sentry, hosts, enable = true }) => {
7
+ if (!enable) {
8
+ return
9
+ }
10
+
11
+ let dt, endpoints
7
12
  try {
8
- endpoint = apiURL.replace(reg, 'fp')
9
- const fp = await FingerprintJS.load({ apiKey: fpToken, endpoint })
13
+ endpoints = uniqBy(
14
+ hosts.map((host) => host.replace(reg, 'fp')),
15
+ (url) => url
16
+ )
17
+
18
+ const fp = await load({ endpoint: [...endpoints, defaultEndpoint] })
10
19
  const result = await fp.get({ timeout: 30000 })
11
20
  dt = result.visitorId
12
21
 
@@ -14,9 +23,10 @@ const getDeviceToken = async ({ fpToken, sentry, apiURL }) => {
14
23
  throw new Error('[Device Token] No token from FingerprintJS.')
15
24
  }
16
25
 
17
- console.log('[Device Token]', `${dt} from ${endpoint}`)
26
+ console.log('[Device Token]', `${dt} from ${endpoints}`)
27
+ sentry?.setTag('dt', dt)
18
28
  } catch (error) {
19
- console.error('[Device Token]', `${dt} from ${endpoint}`)
29
+ console.error('[Device Token]', `${dt} from ${endpoints}`, error)
20
30
  sentry?.captureException(error)
21
31
  } finally {
22
32
  return dt
package/src/util/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { getDeviceToken } from './deviceToken.js'
2
2
  import storage from './storage.js'
3
3
  import * as constant from './constant.js'
4
+ import { max } from './math.js'
4
5
 
5
6
  export default { getDeviceToken }
6
- export { constant, storage }
7
+ export { constant, storage, max }
@@ -0,0 +1,4 @@
1
+ export function max(...args) {
2
+ const casted = args.map((arg) => arg || 0)
3
+ return Math.max(...casted)
4
+ }