@jetthai/cuora 1.1.439 → 1.1.440
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/.husky/post-checkout +3 -3
- package/.husky/pre-push +1 -1
- package/CHANGELOG.md +22 -0
- package/README.md +30 -5
- package/package.json +1 -1
- package/src/api/auth.js +2 -2
- package/src/machine/auth.js +5 -10
- package/src/machine/deposit/crypto_bank_cash.js +2 -1
- package/src/machine/deposit/crypto_way_cash.js +2 -1
- package/src/machine/user_sign_up.js +5 -4
- package/src/machine/withdraw/withdraw_manual_cash.js +33 -4
- package/src/request/config.js +2 -0
- package/src/util/index.js +1 -2
- package/src/lib/fingerprint_v3_11_12.js +0 -11433
- package/src/util/deviceToken.js +0 -59
package/src/util/deviceToken.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import uniqBy from 'lodash/uniqBy'
|
|
2
|
-
import { load, defaultEndpoint } from '../lib/fingerprint_v3_11_12.js'
|
|
3
|
-
|
|
4
|
-
const reg = /fnapi\d*/
|
|
5
|
-
|
|
6
|
-
const getDeviceToken = async ({ fpToken, sentry, hosts, enable = true }) => {
|
|
7
|
-
if (!enable) {
|
|
8
|
-
return
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
let dt, endpoints
|
|
12
|
-
try {
|
|
13
|
-
endpoints = uniqBy(
|
|
14
|
-
hosts.map((host) => host.replace(reg, 'fp')),
|
|
15
|
-
(url) => url
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
const fp = await load({ endpoint: [...endpoints, defaultEndpoint] })
|
|
19
|
-
const result = await fp.get({ timeout: 30000 })
|
|
20
|
-
dt = result.visitorId
|
|
21
|
-
|
|
22
|
-
if (!dt) {
|
|
23
|
-
throw new Error('[Device Token] No token from FingerprintJS.')
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
sentry?.setTag('dt', dt)
|
|
27
|
-
} catch (error) {
|
|
28
|
-
console.error('[Device Token]', `${dt} from ${endpoints}`, error)
|
|
29
|
-
sentry?.captureException(error)
|
|
30
|
-
} finally {
|
|
31
|
-
return dt
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
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 }
|