@jetthai/cuora 1.1.366 → 1.1.368-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.
- package/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/api/activity.js +2 -2
- package/src/api/game.js +12 -0
- package/src/lib/{fingerprint_v3_11_5.js → fingerprint_v3_11_12.js} +3749 -4212
- package/src/machine/auth.js +7 -4
- package/src/machine/common.js +3 -2
- package/src/machine/game_betslip.js +46 -0
- package/src/machine/inbox.js +13 -2
- package/src/machine/index.js +2 -0
- package/src/machine/reward.js +15 -5
- package/src/machine/reward_cash.js +15 -3
- package/src/machine/user_sign_up.js +2 -2
- package/src/util/deviceToken.js +26 -2
- package/src/util/index.js +2 -2
- package/src/util/sessionStorage.js +28 -0
package/src/machine/auth.js
CHANGED
|
@@ -3,7 +3,7 @@ import { assign, createMachine } from 'xstate'
|
|
|
3
3
|
import auth from '../api/auth.js'
|
|
4
4
|
import user from '../api/user.js'
|
|
5
5
|
import storage from '../util/storage.js'
|
|
6
|
-
import {
|
|
6
|
+
import { getDeviceTokenWithRetry } from '../util/deviceToken.js'
|
|
7
7
|
import common from '../api/common.js'
|
|
8
8
|
import pickBy from 'lodash/pickBy.js'
|
|
9
9
|
|
|
@@ -432,7 +432,7 @@ export default function (request) {
|
|
|
432
432
|
const { provider, channel, subchannel, fc } = event.data
|
|
433
433
|
const deviceTokenEnable = context.siteConfig?.dtVerify
|
|
434
434
|
|
|
435
|
-
const dt = await
|
|
435
|
+
const dt = await getDeviceTokenWithRetry({
|
|
436
436
|
fpToken,
|
|
437
437
|
sentry,
|
|
438
438
|
hosts: request.hosts,
|
|
@@ -517,8 +517,11 @@ export default function (request) {
|
|
|
517
517
|
if (deviceTokenEnable) {
|
|
518
518
|
const { exist } = await request.send(user.checkDt())
|
|
519
519
|
if (!exist) {
|
|
520
|
-
const dt = await
|
|
521
|
-
|
|
520
|
+
const dt = await getDeviceTokenWithRetry({ fpToken, sentry, hosts: request.hosts, enable: deviceTokenEnable })
|
|
521
|
+
// 確定有dt再取得updateDt
|
|
522
|
+
if (dt) {
|
|
523
|
+
await request.send(user.updateDt({ dt }))
|
|
524
|
+
}
|
|
522
525
|
}
|
|
523
526
|
}
|
|
524
527
|
},
|
package/src/machine/common.js
CHANGED
|
@@ -3,6 +3,7 @@ import { assign, createMachine } from 'xstate'
|
|
|
3
3
|
import pickBy from 'lodash/pickBy.js'
|
|
4
4
|
import api from '../api/common.js'
|
|
5
5
|
import storage from '../util/storage.js'
|
|
6
|
+
import sessionStorage from '../util/sessionStorage.js'
|
|
6
7
|
|
|
7
8
|
export default function (request) {
|
|
8
9
|
const { appSecret, defaultChannel, defaultSubchannel } = request.config
|
|
@@ -258,7 +259,7 @@ export default function (request) {
|
|
|
258
259
|
const channel = urlParams.get('channel') || storage.get('channel') || defaultChannel || 'official'
|
|
259
260
|
const subchannel = urlParams.get('subchannel') || storage.get('subchannel') || defaultSubchannel || 'pwa'
|
|
260
261
|
const affiliateCode = urlParams.get('ac') || urlParams.get('referralCode') || storage.get('ac') || storage.get('referralCode')
|
|
261
|
-
const friendCode = urlParams.get('fc') || urlParams.get('affiliate') ||
|
|
262
|
+
const friendCode = urlParams.get('fc') || urlParams.get('affiliate') || sessionStorage.get('fc') || sessionStorage.get('affiliate')
|
|
262
263
|
|
|
263
264
|
storage.set('channel', channel, {
|
|
264
265
|
path: '/',
|
|
@@ -272,7 +273,7 @@ export default function (request) {
|
|
|
272
273
|
path: '/',
|
|
273
274
|
maxAge: 60 * 60 * 24 * 7,
|
|
274
275
|
})
|
|
275
|
-
|
|
276
|
+
sessionStorage.set('fc', friendCode, {
|
|
276
277
|
path: '/',
|
|
277
278
|
maxAge: 60 * 60 * 24 * 7,
|
|
278
279
|
})
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import game from '../api/game.js'
|
|
3
|
+
|
|
4
|
+
export default function (request, context) {
|
|
5
|
+
const { appSecret } = request.config
|
|
6
|
+
const { providerId, seqNo, lang } = context
|
|
7
|
+
return createMachine(
|
|
8
|
+
{
|
|
9
|
+
id: 'game_betslip',
|
|
10
|
+
initial: 'fetching',
|
|
11
|
+
context: {
|
|
12
|
+
gameBetSlip: {},
|
|
13
|
+
},
|
|
14
|
+
states: {
|
|
15
|
+
fetching: {
|
|
16
|
+
invoke: {
|
|
17
|
+
src: 'fetchBetslip',
|
|
18
|
+
onDone: {
|
|
19
|
+
target: 'idle',
|
|
20
|
+
actions: 'setBetslip',
|
|
21
|
+
},
|
|
22
|
+
onError: {
|
|
23
|
+
target: 'idle',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
idle: {},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
actions: {
|
|
32
|
+
setBetslip: assign((context, event) => {
|
|
33
|
+
return {
|
|
34
|
+
gameBetSlip: event.data,
|
|
35
|
+
}
|
|
36
|
+
}),
|
|
37
|
+
},
|
|
38
|
+
services: {
|
|
39
|
+
// 取得遊戲注單
|
|
40
|
+
fetchBetslip: async (context, event) => {
|
|
41
|
+
return await request.send(game.getBetslip({ providerId, seqNo, lang, appSecret }))
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
}
|
package/src/machine/inbox.js
CHANGED
|
@@ -247,6 +247,9 @@ export default function (request) {
|
|
|
247
247
|
CLEAR: {
|
|
248
248
|
actions: 'hideMessage',
|
|
249
249
|
},
|
|
250
|
+
SET_LANG: {
|
|
251
|
+
actions: 'setLang',
|
|
252
|
+
},
|
|
250
253
|
},
|
|
251
254
|
},
|
|
252
255
|
{
|
|
@@ -276,6 +279,10 @@ export default function (request) {
|
|
|
276
279
|
},
|
|
277
280
|
},
|
|
278
281
|
actions: {
|
|
282
|
+
setLang: assign((context, event) => {
|
|
283
|
+
const lang = event.data.locale || context.lang || 'en-US'
|
|
284
|
+
return { lang }
|
|
285
|
+
}),
|
|
279
286
|
reset: assign((context, event) => {
|
|
280
287
|
return {
|
|
281
288
|
currentTab: null,
|
|
@@ -415,9 +422,10 @@ export default function (request) {
|
|
|
415
422
|
return tabs
|
|
416
423
|
},
|
|
417
424
|
fetchMessages: async (context, event) => {
|
|
425
|
+
const lang = context.lang
|
|
418
426
|
const { isRewardListEnable, currentTab, inbox } = JSON.parse(JSON.stringify(context))
|
|
419
|
-
if (isRewardListEnable && (currentTab === 'REWARD' || currentTab === 'DIAMOND')) {
|
|
420
|
-
const { data } = await request.send(activity.getRewardList({ count: 30, appSecret }))
|
|
427
|
+
if (isRewardListEnable && (currentTab === 'REWARD' || currentTab === 'DIAMOND' || currentTab === 'FREE_GAME')) {
|
|
428
|
+
const { data } = await request.send(activity.getRewardList({ count: 30, appSecret, lang }))
|
|
421
429
|
inbox[currentTab] = { data, page: 0, totalPage: 1 }
|
|
422
430
|
} else {
|
|
423
431
|
const { page = -1 } = inbox[currentTab] || {}
|
|
@@ -430,6 +438,9 @@ export default function (request) {
|
|
|
430
438
|
},
|
|
431
439
|
reFetchMessages: async (context, event) => {
|
|
432
440
|
const { currentTab, inbox } = JSON.parse(JSON.stringify(context))
|
|
441
|
+
|
|
442
|
+
if (currentTab === 'FREE_GAME') return inbox
|
|
443
|
+
|
|
433
444
|
const { data, ...rest } = await request.send(mailbox.getMessageList({ type: currentTab, page: 0 }))
|
|
434
445
|
let formattedData = []
|
|
435
446
|
formattedData = data?.map((item) => ({ ...item, isSelected: false }))
|
package/src/machine/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import game_search_v2 from './game_search_v2.js'
|
|
|
10
10
|
import game_hot_new from './game_hot_new.js'
|
|
11
11
|
import game_info from './game_info.js'
|
|
12
12
|
import game_replay from './game_replay.js'
|
|
13
|
+
import game_betslip from './game_betslip.js'
|
|
13
14
|
import inbox from './inbox.js'
|
|
14
15
|
import merge from './merge.js'
|
|
15
16
|
import payment_data from './payment_data.js'
|
|
@@ -53,6 +54,7 @@ export default {
|
|
|
53
54
|
game_hot_new,
|
|
54
55
|
game_info,
|
|
55
56
|
game_replay,
|
|
57
|
+
game_betslip,
|
|
56
58
|
inbox,
|
|
57
59
|
merge,
|
|
58
60
|
payment_data,
|
package/src/machine/reward.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createMachine, assign, send } from 'xstate'
|
|
|
2
2
|
import activity from '../api/activity.js'
|
|
3
3
|
import payment from '../api/payment.js'
|
|
4
4
|
|
|
5
|
-
export default function (request) {
|
|
5
|
+
export default function (request, context) {
|
|
6
6
|
const { appSecret } = request.config
|
|
7
7
|
return createMachine(
|
|
8
8
|
{
|
|
@@ -19,6 +19,7 @@ export default function (request) {
|
|
|
19
19
|
isPlaying: false,
|
|
20
20
|
callback: () => {},
|
|
21
21
|
orderColumn: 'createTime',
|
|
22
|
+
lang: context?.locale,
|
|
22
23
|
},
|
|
23
24
|
states: {
|
|
24
25
|
timer: {
|
|
@@ -72,6 +73,9 @@ export default function (request) {
|
|
|
72
73
|
SET_IS_PLAYING: {
|
|
73
74
|
actions: 'setIsPlaying',
|
|
74
75
|
},
|
|
76
|
+
SET_LANG: {
|
|
77
|
+
actions: 'setLang',
|
|
78
|
+
},
|
|
75
79
|
},
|
|
76
80
|
},
|
|
77
81
|
fetching: {
|
|
@@ -193,6 +197,10 @@ export default function (request) {
|
|
|
193
197
|
isPlaying: event.data,
|
|
194
198
|
}
|
|
195
199
|
}),
|
|
200
|
+
setLang: assign((context, event) => {
|
|
201
|
+
const lang = event.data.locale || context.lang || 'en-US'
|
|
202
|
+
return { lang }
|
|
203
|
+
}),
|
|
196
204
|
},
|
|
197
205
|
guards: {
|
|
198
206
|
isPrize: (context, event) => {
|
|
@@ -205,22 +213,24 @@ export default function (request) {
|
|
|
205
213
|
},
|
|
206
214
|
services: {
|
|
207
215
|
fetchRewardList: async (context, event) => {
|
|
216
|
+
const lang = context.lang
|
|
208
217
|
const orderColumn = context.orderColumn
|
|
209
|
-
const getRewardAPI = request.send(activity.getRewardList({ count: 30, appSecret }))
|
|
210
|
-
const getPointsRewardAPI = request.send(activity.getRewardList({ rewardType: 'POINTS', count: 30, appSecret }))
|
|
211
|
-
const getOtherRewardAPI = request.send(activity.getRewardList({ rewardType: 'CASH,FREE,PRIZE', count: 30, appSecret, orderColumn }))
|
|
218
|
+
const getRewardAPI = request.send(activity.getRewardList({ count: 30, appSecret, lang }))
|
|
219
|
+
const getPointsRewardAPI = request.send(activity.getRewardList({ rewardType: 'POINTS', count: 30, appSecret, lang }))
|
|
220
|
+
const getOtherRewardAPI = request.send(activity.getRewardList({ rewardType: 'CASH,FREE,PRIZE', count: 30, appSecret, orderColumn, lang }))
|
|
212
221
|
const [otherRewardList, pointsRewardList, rewardList] = await Promise.all([getOtherRewardAPI, getPointsRewardAPI, getRewardAPI])
|
|
213
222
|
return [otherRewardList, pointsRewardList, rewardList]
|
|
214
223
|
},
|
|
215
224
|
fetchOtherRewardList: async (context, event) => {
|
|
216
225
|
const orderColumn = context.orderColumn
|
|
217
|
-
|
|
226
|
+
const lang = context.lang
|
|
218
227
|
const getOtherRewardAPI = request.send(
|
|
219
228
|
activity.getRewardList({
|
|
220
229
|
rewardType: 'CASH,FREE,PRIZE',
|
|
221
230
|
count: 30,
|
|
222
231
|
appSecret,
|
|
223
232
|
orderColumn,
|
|
233
|
+
lang,
|
|
224
234
|
})
|
|
225
235
|
)
|
|
226
236
|
const [otherRewardList] = await Promise.all([getOtherRewardAPI])
|
|
@@ -2,7 +2,7 @@ import { createMachine, assign, send } from 'xstate'
|
|
|
2
2
|
import activity from '../api/activity.js'
|
|
3
3
|
import payment from '../api/payment.js'
|
|
4
4
|
|
|
5
|
-
export default function (request) {
|
|
5
|
+
export default function (request, context) {
|
|
6
6
|
const { appSecret } = request.config
|
|
7
7
|
return createMachine(
|
|
8
8
|
{
|
|
@@ -18,6 +18,7 @@ export default function (request) {
|
|
|
18
18
|
withdrawRule: {},
|
|
19
19
|
callback: () => {},
|
|
20
20
|
orderColumn: 'createTime',
|
|
21
|
+
lang: context?.locale,
|
|
21
22
|
},
|
|
22
23
|
states: {
|
|
23
24
|
timer: {
|
|
@@ -78,6 +79,9 @@ export default function (request) {
|
|
|
78
79
|
target: 'allPointsReceiving',
|
|
79
80
|
actions: 'setCallback',
|
|
80
81
|
},
|
|
82
|
+
SET_LANG: {
|
|
83
|
+
actions: 'setLang',
|
|
84
|
+
},
|
|
81
85
|
},
|
|
82
86
|
},
|
|
83
87
|
fetching: {
|
|
@@ -201,16 +205,22 @@ export default function (request) {
|
|
|
201
205
|
withdrawRule: event.data,
|
|
202
206
|
}
|
|
203
207
|
}),
|
|
208
|
+
setLang: assign((context, event) => {
|
|
209
|
+
const lang = event.data.locale || context.lang || 'en-US'
|
|
210
|
+
return { lang }
|
|
211
|
+
}),
|
|
204
212
|
},
|
|
205
213
|
services: {
|
|
206
214
|
fetchRewardList: async (context, event) => {
|
|
207
|
-
const
|
|
215
|
+
const lang = context.lang
|
|
216
|
+
const getRewardAPI = request.send(activity.getRewardList({ count: 30, appSecret, lang }))
|
|
208
217
|
const orderColumn = context.orderColumn
|
|
209
218
|
const getPointsRewardAPI = request.send(
|
|
210
219
|
activity.getRewardList({
|
|
211
220
|
rewardType: 'POINTS',
|
|
212
221
|
count: 30,
|
|
213
222
|
appSecret,
|
|
223
|
+
lang,
|
|
214
224
|
})
|
|
215
225
|
)
|
|
216
226
|
const getOtherRewardAPI = request.send(
|
|
@@ -219,6 +229,7 @@ export default function (request) {
|
|
|
219
229
|
count: 30,
|
|
220
230
|
appSecret,
|
|
221
231
|
orderColumn,
|
|
232
|
+
lang,
|
|
222
233
|
})
|
|
223
234
|
)
|
|
224
235
|
const [otherRewardList, pointsRewardList, rewardList] = await Promise.all([getOtherRewardAPI, getPointsRewardAPI, getRewardAPI])
|
|
@@ -226,13 +237,14 @@ export default function (request) {
|
|
|
226
237
|
},
|
|
227
238
|
fetchOtherRewardList: async (context, event) => {
|
|
228
239
|
const orderColumn = context.orderColumn
|
|
229
|
-
|
|
240
|
+
const lang = context.lang
|
|
230
241
|
const getOtherRewardAPI = request.send(
|
|
231
242
|
activity.getRewardList({
|
|
232
243
|
rewardType: 'CASH,FREE,PRIZE',
|
|
233
244
|
count: 30,
|
|
234
245
|
appSecret,
|
|
235
246
|
orderColumn,
|
|
247
|
+
lang,
|
|
236
248
|
})
|
|
237
249
|
)
|
|
238
250
|
const [otherRewardList] = await Promise.all([getOtherRewardAPI])
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import auth from '../api/auth.js'
|
|
3
|
-
import {
|
|
3
|
+
import { getDeviceTokenWithRetry } from '../util/deviceToken.js'
|
|
4
4
|
import storage from '../util/storage.js'
|
|
5
5
|
|
|
6
6
|
export default function (request) {
|
|
@@ -200,7 +200,7 @@ export default function (request) {
|
|
|
200
200
|
services: {
|
|
201
201
|
authenticate: async (context, event) => {
|
|
202
202
|
const { channel, subchannel, signUpData, deviceTokenEnable } = context
|
|
203
|
-
const dt = await
|
|
203
|
+
const dt = await getDeviceTokenWithRetry({ fpToken, sentry, hosts: request.hosts, enable: deviceTokenEnable })
|
|
204
204
|
|
|
205
205
|
const affiliateCode = storage.get('ac') || signUpData?.affiliateCode
|
|
206
206
|
const messages = {
|
package/src/util/deviceToken.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import uniqBy from 'lodash/uniqBy'
|
|
2
|
-
import { load, defaultEndpoint } from '../lib/
|
|
2
|
+
import { load, defaultEndpoint } from '../lib/fingerprint_v3_11_12.js'
|
|
3
3
|
|
|
4
4
|
const reg = /fnapi\d*/
|
|
5
5
|
|
|
@@ -32,4 +32,28 @@ const getDeviceToken = async ({ fpToken, sentry, hosts, enable = true }) => {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
// 重試機制,最多嘗試 maxRetries 次,每次間隔 intervalMs 毫秒
|
|
36
|
+
const getDeviceTokenWithRetry = async ({ fpToken, sentry, hosts, enable = true, maxRetries = 3, intervalMs = 1000 }) => {
|
|
37
|
+
if (!enable) {
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
// 設置幾秒後重試
|
|
41
|
+
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
|
|
42
|
+
// 設定重試次數
|
|
43
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
44
|
+
try {
|
|
45
|
+
const deviceToken = await getDeviceToken({ fpToken, sentry, hosts, enable })
|
|
46
|
+
if (deviceToken) return deviceToken
|
|
47
|
+
throw new Error('No device token received')
|
|
48
|
+
} catch (error) {
|
|
49
|
+
// 若失敗則等待intervalMs後重試,最多重試maxRetries次
|
|
50
|
+
if (attempt < maxRetries) {
|
|
51
|
+
await delay(intervalMs)
|
|
52
|
+
} else {
|
|
53
|
+
throw error
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { getDeviceToken, getDeviceTokenWithRetry }
|
package/src/util/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getDeviceToken } from './deviceToken.js'
|
|
1
|
+
import { getDeviceToken, getDeviceTokenWithRetry } from './deviceToken.js'
|
|
2
2
|
import storage from './storage.js'
|
|
3
3
|
import * as constant from './constant.js'
|
|
4
4
|
import { max } from './math.js'
|
|
5
5
|
|
|
6
|
-
export default { getDeviceToken }
|
|
6
|
+
export default { getDeviceToken, getDeviceTokenWithRetry }
|
|
7
7
|
export { constant, storage, max }
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
get(name, options) {
|
|
3
|
+
const itemStr = sessionStorage.getItem(name)
|
|
4
|
+
|
|
5
|
+
if (!itemStr) {
|
|
6
|
+
return null
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const item = JSON.parse(itemStr)
|
|
10
|
+
if (item.expiry && new Date().getTime() > item.expiry) {
|
|
11
|
+
sessionStorage.removeItem(name)
|
|
12
|
+
return null
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return item.value
|
|
16
|
+
},
|
|
17
|
+
set(name, value, options) {
|
|
18
|
+
const item = { value }
|
|
19
|
+
|
|
20
|
+
if (options?.maxAge) {
|
|
21
|
+
item.expiry = new Date().getTime() + options.maxAge * 1000
|
|
22
|
+
}
|
|
23
|
+
sessionStorage.setItem(name, JSON.stringify(item))
|
|
24
|
+
},
|
|
25
|
+
remove(name, options) {
|
|
26
|
+
sessionStorage.removeItem(name)
|
|
27
|
+
},
|
|
28
|
+
}
|