@jetthai/cuora 1.1.366-v2api-2 → 1.1.367
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 +1 -19
- package/package.json +1 -1
- package/src/api/activity.js +1 -1
- package/src/api/common.js +1 -1
- package/src/api/game.js +12 -0
- package/src/api/payment.js +5 -5
- package/src/api/ranking.js +2 -2
- 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/game_betslip.js +46 -0
- package/src/machine/honor_board_cash.js +1 -1
- package/src/machine/index.js +2 -0
- package/src/machine/ranking.js +1 -2
- package/src/machine/user_sign_up.js +2 -2
- package/src/machine/vip_table.js +4 -11
- package/src/request/request.js +5 -194
- package/src/util/deviceToken.js +26 -2
- package/src/util/index.js +2 -2
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
|
},
|
|
@@ -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
|
+
}
|
|
@@ -80,7 +80,7 @@ export default function (request) {
|
|
|
80
80
|
},
|
|
81
81
|
services: {
|
|
82
82
|
fetchHonorBoardList: async (context, event) => {
|
|
83
|
-
const { data } = await request.send(activity.getHonorBroadcast(
|
|
83
|
+
const { data } = await request.send(activity.getHonorBroadcast(appSecret))
|
|
84
84
|
return data
|
|
85
85
|
},
|
|
86
86
|
},
|
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/ranking.js
CHANGED
|
@@ -2,7 +2,6 @@ import { createMachine, assign } from 'xstate'
|
|
|
2
2
|
import ranking from '../api/ranking.js'
|
|
3
3
|
|
|
4
4
|
export default function (request) {
|
|
5
|
-
const { appSecret } = request.config
|
|
6
5
|
const cycleMapping = ['DAILY', 'WEEKLY', 'MONTHLY']
|
|
7
6
|
const limit = { DAILY: 56, WEEKLY: 8, MONTHLY: 2, ALL: 2 }
|
|
8
7
|
|
|
@@ -200,7 +199,7 @@ export default function (request) {
|
|
|
200
199
|
},
|
|
201
200
|
fetchRankingOptions: async (context) => {
|
|
202
201
|
const { activityNo } = context
|
|
203
|
-
const { data } = await request.send(ranking.getRankingOptions({ activityNo
|
|
202
|
+
const { data } = await request.send(ranking.getRankingOptions({ activityNo }))
|
|
204
203
|
return data
|
|
205
204
|
},
|
|
206
205
|
fetchRankingDetail: async (context, event) => {
|
|
@@ -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/machine/vip_table.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import activity from '../api/activity.js'
|
|
3
3
|
export default function (request) {
|
|
4
|
-
const { appSecret } = request.config
|
|
5
4
|
return createMachine(
|
|
6
5
|
{
|
|
7
6
|
id: 'vip_table',
|
|
@@ -36,20 +35,14 @@ export default function (request) {
|
|
|
36
35
|
},
|
|
37
36
|
services: {
|
|
38
37
|
fetchVipTable: async (context, event) => {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (!result?.viptable) {
|
|
43
|
-
dataList = result.data
|
|
44
|
-
} else {
|
|
45
|
-
dataList = result.viptable?.data
|
|
46
|
-
}
|
|
47
|
-
dataList.map((item) => {
|
|
38
|
+
const { viptable = {} } = await request.send(activity.getVipTable())
|
|
39
|
+
const { data = [] } = viptable
|
|
40
|
+
data.map((item) => {
|
|
48
41
|
item.title = item.title.toLowerCase()
|
|
49
42
|
return item
|
|
50
43
|
})
|
|
51
44
|
|
|
52
|
-
return
|
|
45
|
+
return data
|
|
53
46
|
},
|
|
54
47
|
},
|
|
55
48
|
}
|
package/src/request/request.js
CHANGED
|
@@ -2,139 +2,6 @@ import pickBy from 'lodash/pickBy.js'
|
|
|
2
2
|
import storage from '../util/storage.js'
|
|
3
3
|
|
|
4
4
|
// const pickBy = require('lodash/pickBy')
|
|
5
|
-
const supportVersion2List = [
|
|
6
|
-
// 04-09 Update
|
|
7
|
-
'game/play',
|
|
8
|
-
'game/gameReplay',
|
|
9
|
-
'game/logout',
|
|
10
|
-
'game/list/v3/root',
|
|
11
|
-
'game/list/v3/category',
|
|
12
|
-
'game/list/v3/addition',
|
|
13
|
-
'game/list/v3/categoryByRange',
|
|
14
|
-
'game/list/v3/additionByRange',
|
|
15
|
-
'game/list/v3/myFavorite',
|
|
16
|
-
'game/list/v3/addMyFavorite',
|
|
17
|
-
'game/list/v3/removeMyFavorite',
|
|
18
|
-
'login',
|
|
19
|
-
'callback/:strategy',
|
|
20
|
-
'guestLogin',
|
|
21
|
-
'appLogin',
|
|
22
|
-
'logout',
|
|
23
|
-
'self',
|
|
24
|
-
'register',
|
|
25
|
-
'settings/password',
|
|
26
|
-
'verify',
|
|
27
|
-
'reset',
|
|
28
|
-
'acknowledge',
|
|
29
|
-
'recovery',
|
|
30
|
-
'recovery/abandon',
|
|
31
|
-
'recovery/acknowledge',
|
|
32
|
-
'checkDt',
|
|
33
|
-
'updateDt',
|
|
34
|
-
'checkAC',
|
|
35
|
-
'checkAccount',
|
|
36
|
-
'getAllAvatar',
|
|
37
|
-
'updateUserAvatar',
|
|
38
|
-
'getConfig',
|
|
39
|
-
'getQuickLayout',
|
|
40
|
-
'getNavbarSetting',
|
|
41
|
-
'getAffiliateCode',
|
|
42
|
-
'get-site-config',
|
|
43
|
-
'mailbox/sendMessage',
|
|
44
|
-
'mailbox/getMessageList',
|
|
45
|
-
'mailbox/getMessage',
|
|
46
|
-
'mailbox/updateMessage',
|
|
47
|
-
'mailbox/getMessageTypes',
|
|
48
|
-
// 05-23 Update
|
|
49
|
-
'game/info',
|
|
50
|
-
'recovery/v2/initiate',
|
|
51
|
-
'recovery/v2/acknowledge',
|
|
52
|
-
'recovery/v2/abandon',
|
|
53
|
-
'recovery/v2/reset',
|
|
54
|
-
'recovery/v2/changePassword',
|
|
55
|
-
'account-binding/status',
|
|
56
|
-
'account-binding/bind',
|
|
57
|
-
'account-binding/acknowledge',
|
|
58
|
-
'account-binding/bind-third-party',
|
|
59
|
-
'feeds',
|
|
60
|
-
'broadcast',
|
|
61
|
-
'upload',
|
|
62
|
-
'game/search',
|
|
63
|
-
'game/search/home',
|
|
64
|
-
'game/search/list',
|
|
65
|
-
'game/search/trace',
|
|
66
|
-
'game/history',
|
|
67
|
-
'game/history/detail',
|
|
68
|
-
'payment/v2/bankWallet/promotion/apply',
|
|
69
|
-
'payment/v2/bankWallet/promotion/giveUp',
|
|
70
|
-
'payment/v2/bankWallet/promotion/preview',
|
|
71
|
-
'payment/v2/bankWallet/promotions',
|
|
72
|
-
'payment/v2/bankWallet/restore',
|
|
73
|
-
'payment/v2/callback',
|
|
74
|
-
'payment/v2/convertFreeCredit',
|
|
75
|
-
'payment/v2/getBindingBankList',
|
|
76
|
-
'payment/v2/getBindingPaymentList',
|
|
77
|
-
'payment/v2/getWithdrawBankList',
|
|
78
|
-
'payment/v2/getCurrentWithdrawRule',
|
|
79
|
-
'payment/v2/withdrawCheck',
|
|
80
|
-
'payment/v2/history',
|
|
81
|
-
'payment/v2/mergeWallet',
|
|
82
|
-
'payment/v2/paymentDetail',
|
|
83
|
-
'payment/v2/category/options',
|
|
84
|
-
'payment/v2/paymentInfo',
|
|
85
|
-
'payment/v2/getBindingPaymentInfo',
|
|
86
|
-
'payment/v2/pendingOrder',
|
|
87
|
-
'payment/v2/promotions',
|
|
88
|
-
'payment/v2/spotmarket',
|
|
89
|
-
'payment/v2/transactionHistory',
|
|
90
|
-
'payment/v2/updateUtr',
|
|
91
|
-
'payment/v2/setting',
|
|
92
|
-
'payment/v2/amb/setting',
|
|
93
|
-
'payment/v2/updatePaymentInfo',
|
|
94
|
-
'payment/v2/uploadSlip',
|
|
95
|
-
'payment/v2/withdrawRule',
|
|
96
|
-
'payment/v2/:paymentType/getBankList',
|
|
97
|
-
'payment/v2/:paymentType/transaction',
|
|
98
|
-
'payment/v2/:paymentType/checkTransaction',
|
|
99
|
-
'payment/v2/:paymentType/bonus/preview',
|
|
100
|
-
'payment/v2/:paymentType/expected/result',
|
|
101
|
-
'payment/v2/:paymentType/crypto/expected/result',
|
|
102
|
-
// 05-28 Update
|
|
103
|
-
'all-activities/list',
|
|
104
|
-
'activities/list',
|
|
105
|
-
'activities/rewards',
|
|
106
|
-
'activities/rewardAmount',
|
|
107
|
-
'activities/sentAward',
|
|
108
|
-
'activities/exchange',
|
|
109
|
-
'activities/collect',
|
|
110
|
-
'activities',
|
|
111
|
-
'activities/types',
|
|
112
|
-
'activities/promo',
|
|
113
|
-
'activities/viptable',
|
|
114
|
-
'activities/numbers',
|
|
115
|
-
'activities/honorBroadcast',
|
|
116
|
-
'activities/exchange/diamond/max-amount',
|
|
117
|
-
'activities/exchange/diamond/settle',
|
|
118
|
-
'tournament/detail',
|
|
119
|
-
'ranking/detail',
|
|
120
|
-
'ranking/detail/option',
|
|
121
|
-
'hot-game/ranking',
|
|
122
|
-
'activities/getFreeGameReward',
|
|
123
|
-
'activities/getFreeGameRewardList',
|
|
124
|
-
'activities/rebate/estimate',
|
|
125
|
-
'activities/rebate/collect',
|
|
126
|
-
'activities/rebate/history',
|
|
127
|
-
'activities/lose-rebate/history',
|
|
128
|
-
'friends',
|
|
129
|
-
'friends/home',
|
|
130
|
-
'friends/reward-list',
|
|
131
|
-
'friends/dashboard',
|
|
132
|
-
'friends/dashboard/list',
|
|
133
|
-
'activities/ranking',
|
|
134
|
-
'activities/activity/ranking',
|
|
135
|
-
'activities/cashRain',
|
|
136
|
-
'activities/jackpot/list',
|
|
137
|
-
]
|
|
138
5
|
|
|
139
6
|
function isValid(value) {
|
|
140
7
|
return value !== undefined && value !== null
|
|
@@ -157,8 +24,7 @@ export default class Request {
|
|
|
157
24
|
axiosConfig.headers['X-TH1GAMES-VERSION'] = this.config.version
|
|
158
25
|
axiosConfig.headers['X-TH1GAMES-PLATFORM'] = this.config.platform
|
|
159
26
|
if (this.getToken()) {
|
|
160
|
-
|
|
161
|
-
axiosConfig.headers.Authorization = `Bearer ${this.getToken()}`
|
|
27
|
+
axiosConfig.headers.Authorization = this.getToken()
|
|
162
28
|
}
|
|
163
29
|
return axiosConfig
|
|
164
30
|
})
|
|
@@ -219,34 +85,11 @@ export default class Request {
|
|
|
219
85
|
|
|
220
86
|
_createConfig(req, cancelToken) {
|
|
221
87
|
const { method, url, params, isPublic, isFormData, headers } = req
|
|
222
|
-
let fullURL = this.config.fullURL
|
|
223
|
-
let urlName = url
|
|
224
|
-
// 有些API會將參數(/?)直接帶在URL上,所以要將參數排除
|
|
225
|
-
const cleanUrl = url.split('?')[0]
|
|
226
|
-
|
|
227
|
-
const isV2Supported = supportVersion2List.some((supportedUrl) => {
|
|
228
|
-
// 如果包含動態參數(:parameter),則使用模式匹配
|
|
229
|
-
if (supportedUrl.includes(':')) {
|
|
230
|
-
const pattern = supportedUrl.replace(/:[^/]+/g, '[^/]+')
|
|
231
|
-
const regex = new RegExp(`^${pattern}$`)
|
|
232
|
-
return regex.test(cleanUrl)
|
|
233
|
-
}
|
|
234
|
-
return supportedUrl === cleanUrl
|
|
235
|
-
})
|
|
236
|
-
|
|
237
|
-
if (isV2Supported) {
|
|
238
|
-
fullURL = fullURL.replace('/v1/', '/v2/')
|
|
239
|
-
urlName = this._convertUrlToKebabCase(url)
|
|
240
|
-
console.log(`*[DEV_ONLY]V2`, 'url:', urlName)
|
|
241
|
-
} else {
|
|
242
|
-
console.log(`*[DEV_ONLY]V2-不支援:`, 'url:', urlName)
|
|
243
|
-
}
|
|
244
|
-
|
|
245
88
|
if (isFormData) {
|
|
246
89
|
return {
|
|
247
|
-
baseURL: fullURL,
|
|
90
|
+
baseURL: this.config.fullURL,
|
|
248
91
|
method,
|
|
249
|
-
url
|
|
92
|
+
url,
|
|
250
93
|
cancelToken,
|
|
251
94
|
isPublic,
|
|
252
95
|
headers: { 'Content-Type': 'multipart/form-data' },
|
|
@@ -254,9 +97,9 @@ export default class Request {
|
|
|
254
97
|
}
|
|
255
98
|
} else {
|
|
256
99
|
return {
|
|
257
|
-
baseURL: fullURL,
|
|
100
|
+
baseURL: this.config.fullURL,
|
|
258
101
|
method,
|
|
259
|
-
url
|
|
102
|
+
url,
|
|
260
103
|
cancelToken,
|
|
261
104
|
isPublic,
|
|
262
105
|
headers,
|
|
@@ -265,38 +108,6 @@ export default class Request {
|
|
|
265
108
|
}
|
|
266
109
|
}
|
|
267
110
|
|
|
268
|
-
// 調整API路徑與名稱
|
|
269
|
-
_convertUrlToKebabCase(url) {
|
|
270
|
-
const specifyingPath = {
|
|
271
|
-
'all-activities/list': 'activities/all-activities-list',
|
|
272
|
-
friends: 'activities/friends',
|
|
273
|
-
'friends/home': 'activities/friends/home',
|
|
274
|
-
'friends/reward-list': 'activities/friends/reward-list',
|
|
275
|
-
'friends/dashboard': 'activities/friends/dashboard',
|
|
276
|
-
'friends/dashboard/list': 'activities/friends/dashboard/list',
|
|
277
|
-
'activities/getFreeGameReward': 'activities/free-game/get-free-game-reward',
|
|
278
|
-
'activities/getFreeGameRewardList': 'activities/free-game/get-free-game-reward-list',
|
|
279
|
-
'activities/lose-rebate/history': 'activities/rebate/lose-rebate/history',
|
|
280
|
-
'activities/ranking': 'activities/ranking/promotion-ranking',
|
|
281
|
-
'activities/activity/ranking': 'activities/ranking/basic-ranking',
|
|
282
|
-
'activities/cashRain': 'activities/cash-rain/exchange',
|
|
283
|
-
'tournament/detail': 'activities/tournament/detail',
|
|
284
|
-
'ranking/detail': 'activities/tournament/ranking/detail',
|
|
285
|
-
'ranking/detail/option': 'activities/tournament/ranking/detail/option',
|
|
286
|
-
'hot-game/ranking': 'activities/tournament/ranking/hot-game',
|
|
287
|
-
'activities/rebate/estimate': 'activities/rebate/estimate',
|
|
288
|
-
'activities/exchange/diamond/max-amount': 'activities/diamond/exchange/max-amount',
|
|
289
|
-
'activities/exchange/diamond/settle': 'activities/diamond/exchange/settle',
|
|
290
|
-
}
|
|
291
|
-
if (specifyingPath[url]) {
|
|
292
|
-
// 和原有路徑不同有另外改路徑
|
|
293
|
-
return specifyingPath[url]
|
|
294
|
-
} else {
|
|
295
|
-
// 將API_URL的命名規則由駝峰調整為短橫線(-)
|
|
296
|
-
return url.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
111
|
_checkToken(req) {
|
|
301
112
|
if (!req.isPublic && !this.getToken()) {
|
|
302
113
|
throw { code: 'ERR_A103', url: req.url }
|
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 }
|