@jetthai/cuora 1.1.439-dev.6 → 1.1.439
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/.claude/commands/auto-git-flow.md +12 -5
- package/.claude/commands/commit-push.md +4 -15
- package/.claude/commands/sync-ai-prompts.md +1 -88
- package/.claude/settings.local.json +1 -3
- package/.github/copilot-instructions.md +399 -551
- package/.prettierignore +1 -2
- package/AGENTS.md +399 -551
- package/AI_PROMPT_SOURCE.md +130 -662
- package/CHANGELOG.md +13 -228
- package/CLAUDE.md +399 -551
- package/GEMINI.md +399 -551
- package/README.md +107 -35
- package/package.json +1 -1
- package/scripts/auto-version.js +0 -1
- package/src/api/activity.js +0 -10
- package/src/api/auth.js +2 -2
- package/src/lib/fingerprint_v3_11_12.js +11433 -0
- package/src/machine/activity/activity_cash.js +3 -18
- package/src/machine/auth.js +10 -5
- package/src/machine/common.js +15 -1
- package/src/machine/deposit/crypto_bank_cash.js +1 -2
- package/src/machine/deposit/crypto_way_cash.js +1 -2
- package/src/machine/ranking.js +25 -43
- package/src/machine/user_sign_up.js +3 -2
- package/src/machine/withdraw/withdraw_manual_cash.js +4 -33
- package/src/request/config.js +0 -2
- package/src/util/deviceToken.js +59 -0
- package/src/util/index.js +2 -1
- package/prepare-for-pr/JT-1776243420.md +0 -85
|
@@ -11,7 +11,6 @@ export default function (request) {
|
|
|
11
11
|
context: {
|
|
12
12
|
tick: 2000,
|
|
13
13
|
activityList: [],
|
|
14
|
-
progressSummary: {},
|
|
15
14
|
tournamentList: [],
|
|
16
15
|
promotionList: [],
|
|
17
16
|
uidSite: '',
|
|
@@ -25,7 +24,7 @@ export default function (request) {
|
|
|
25
24
|
src: 'fetchList',
|
|
26
25
|
onDone: {
|
|
27
26
|
target: 'checking',
|
|
28
|
-
actions: ['setActivityList', 'setTournamentList', 'setPromotionList'
|
|
27
|
+
actions: ['setActivityList', 'setTournamentList', 'setPromotionList'],
|
|
29
28
|
},
|
|
30
29
|
onError: {
|
|
31
30
|
target: 'pending',
|
|
@@ -97,12 +96,6 @@ export default function (request) {
|
|
|
97
96
|
activityList: list,
|
|
98
97
|
}
|
|
99
98
|
}),
|
|
100
|
-
setProgressSummary: assign((context, event) => {
|
|
101
|
-
const { progressSummary } = event.data
|
|
102
|
-
return {
|
|
103
|
-
progressSummary: progressSummary || null,
|
|
104
|
-
}
|
|
105
|
-
}),
|
|
106
99
|
setPromotionList: assign((context, event) => {
|
|
107
100
|
const { promotionList } = event.data
|
|
108
101
|
return {
|
|
@@ -161,20 +154,12 @@ export default function (request) {
|
|
|
161
154
|
services: {
|
|
162
155
|
fetchList: async (context, event) => {
|
|
163
156
|
const hasToken = request.getToken()
|
|
164
|
-
const
|
|
165
|
-
const isProgressEnable = siteConfig?.frontendActivityProgressEnable
|
|
166
|
-
|
|
167
|
-
const [{ data }, promotionList, progressSummaryRes] = await Promise.all([
|
|
157
|
+
const [{ data }, promotionList] = await Promise.all([
|
|
168
158
|
hasToken ? request.send(activity.getActivityList({ appSecret })) : request.send(activity.getAllActivityList({ appSecret })),
|
|
169
159
|
hasToken ? request.send(payment.getPromotionsList()) : [],
|
|
170
|
-
hasToken && isProgressEnable ? request.send(activity.getProgressSummary({ appSecret })).catch(() => null) : null,
|
|
171
160
|
])
|
|
172
161
|
|
|
173
|
-
return {
|
|
174
|
-
activityList: data,
|
|
175
|
-
promotionList,
|
|
176
|
-
progressSummary: progressSummaryRes?.data || null,
|
|
177
|
-
}
|
|
162
|
+
return { activityList: data, promotionList }
|
|
178
163
|
},
|
|
179
164
|
fetchActivityDetailList: async (context, event) => {
|
|
180
165
|
await new Promise((resolve) => setTimeout(resolve, 1000)) // delay 1 second
|
package/src/machine/auth.js
CHANGED
|
@@ -3,11 +3,12 @@ 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 { getDeviceTokenWithRetry } from '../util/deviceToken.js'
|
|
6
7
|
import common from '../api/common.js'
|
|
7
8
|
import pickBy from 'lodash/pickBy.js'
|
|
8
9
|
|
|
9
10
|
export default function (request) {
|
|
10
|
-
const { appSecret, clientId, sentry, defaultChannel, defaultSubchannel } = request.config
|
|
11
|
+
const { appSecret, clientId, fpToken, sentry, defaultChannel, defaultSubchannel } = request.config
|
|
11
12
|
const tokenKey = `cuora_${clientId}`
|
|
12
13
|
const userKey = `cuora_tempuser`
|
|
13
14
|
const phoneCountryCode = 'phone_countrycode'
|
|
@@ -393,14 +394,13 @@ export default function (request) {
|
|
|
393
394
|
}
|
|
394
395
|
}),
|
|
395
396
|
setLoginTelegram: assign((context, event) => {
|
|
396
|
-
const { loginType, additionalUserInfo, isSignature
|
|
397
|
+
const { loginType, additionalUserInfo, isSignature } = event.data
|
|
397
398
|
return {
|
|
398
399
|
loginData: {
|
|
399
400
|
provider: 'telegram',
|
|
400
401
|
loginType,
|
|
401
402
|
additionalUserInfo,
|
|
402
403
|
isSignature,
|
|
403
|
-
idToken,
|
|
404
404
|
},
|
|
405
405
|
}
|
|
406
406
|
}),
|
|
@@ -467,7 +467,12 @@ export default function (request) {
|
|
|
467
467
|
const { provider, channel, subchannel, fc } = event.data
|
|
468
468
|
const deviceTokenEnable = context.siteConfig?.dtVerify
|
|
469
469
|
|
|
470
|
-
const dt =
|
|
470
|
+
const dt = await getDeviceTokenWithRetry({
|
|
471
|
+
fpToken,
|
|
472
|
+
sentry,
|
|
473
|
+
hosts: request.hosts,
|
|
474
|
+
enable: deviceTokenEnable,
|
|
475
|
+
})
|
|
471
476
|
|
|
472
477
|
const affiliateCode = storage.get('ac')
|
|
473
478
|
const nickname = storage.get('nk')
|
|
@@ -569,7 +574,7 @@ export default function (request) {
|
|
|
569
574
|
if (deviceTokenEnable) {
|
|
570
575
|
const { exist } = await request.send(user.checkDt())
|
|
571
576
|
if (!exist) {
|
|
572
|
-
const dt = await request.
|
|
577
|
+
const dt = await getDeviceTokenWithRetry({ fpToken, sentry, hosts: request.hosts, enable: deviceTokenEnable })
|
|
573
578
|
// 確定有dt再取得updateDt
|
|
574
579
|
if (dt) {
|
|
575
580
|
await request.send(user.updateDt({ dt }))
|
package/src/machine/common.js
CHANGED
|
@@ -5,7 +5,7 @@ import api from '../api/common.js'
|
|
|
5
5
|
import storage from '../util/storage.js'
|
|
6
6
|
|
|
7
7
|
export default function (request) {
|
|
8
|
-
const { appSecret } = request.config
|
|
8
|
+
const { appSecret, defaultChannel, defaultSubchannel } = request.config
|
|
9
9
|
return createMachine(
|
|
10
10
|
{
|
|
11
11
|
id: 'common',
|
|
@@ -35,6 +35,8 @@ export default function (request) {
|
|
|
35
35
|
promotions: [],
|
|
36
36
|
normalBroadcast: null,
|
|
37
37
|
sentNormalBroadcastList: [],
|
|
38
|
+
channel: null,
|
|
39
|
+
subchannel: null,
|
|
38
40
|
affiliateCode: null,
|
|
39
41
|
defaultAffiliateCode: null,
|
|
40
42
|
friendCode: null,
|
|
@@ -282,9 +284,19 @@ export default function (request) {
|
|
|
282
284
|
return
|
|
283
285
|
} else {
|
|
284
286
|
let urlParams = new URLSearchParams(window.location.search)
|
|
287
|
+
const channel = urlParams.get('channel') || storage.get('channel') || defaultChannel || 'official'
|
|
288
|
+
const subchannel = urlParams.get('subchannel') || storage.get('subchannel') || defaultSubchannel || 'pwa'
|
|
285
289
|
const affiliateCode = urlParams.get('ac') || urlParams.get('referralCode') || storage.get('ac') || storage.get('referralCode')
|
|
286
290
|
const friendCode = urlParams.get('fc') || urlParams.get('affiliate') || storage.get('fc') || storage.get('affiliate')
|
|
287
291
|
|
|
292
|
+
storage.set('channel', channel, {
|
|
293
|
+
path: '/',
|
|
294
|
+
maxAge: 60 * 60 * 24 * 7,
|
|
295
|
+
})
|
|
296
|
+
storage.set('subchannel', subchannel, {
|
|
297
|
+
path: '/',
|
|
298
|
+
maxAge: 60 * 60 * 24 * 7,
|
|
299
|
+
})
|
|
288
300
|
storage.set('ac', affiliateCode, {
|
|
289
301
|
path: '/',
|
|
290
302
|
maxAge: 60 * 60 * 24 * 7,
|
|
@@ -295,6 +307,8 @@ export default function (request) {
|
|
|
295
307
|
})
|
|
296
308
|
|
|
297
309
|
return {
|
|
310
|
+
channel,
|
|
311
|
+
subchannel,
|
|
298
312
|
affiliateCode,
|
|
299
313
|
friendCode,
|
|
300
314
|
}
|
|
@@ -164,7 +164,6 @@ export default function (request, context) {
|
|
|
164
164
|
selectedCrypto: defaultCrypto[0],
|
|
165
165
|
selectedAddress: defaultAddresses[0],
|
|
166
166
|
options: cryptoBank.optional,
|
|
167
|
-
selectedAmount: max(context.promotion?.minimumAmount, defaultCrypto[0]?.minimum, context.selectedAmount, 0),
|
|
168
167
|
}
|
|
169
168
|
}),
|
|
170
169
|
setCrypto: assign((context, event) => {
|
|
@@ -183,7 +182,7 @@ export default function (request, context) {
|
|
|
183
182
|
addresses,
|
|
184
183
|
selectedCrypto: selectedCrypto,
|
|
185
184
|
selectedAddress: addresses[0],
|
|
186
|
-
selectedAmount:
|
|
185
|
+
selectedAmount: null,
|
|
187
186
|
calculation: null,
|
|
188
187
|
options: cryptoBank.optional,
|
|
189
188
|
}
|
|
@@ -153,7 +153,6 @@ export default function (request, context) {
|
|
|
153
153
|
cryptos,
|
|
154
154
|
selectedCrypto: defaultCrypto,
|
|
155
155
|
options: defaultCrypto?.optional || [],
|
|
156
|
-
selectedAmount: max(context.promotion?.minimumAmount, defaultCrypto?.minimum, context.selectedAmount, 0),
|
|
157
156
|
}
|
|
158
157
|
}),
|
|
159
158
|
setCrypto: assign((context, event) => {
|
|
@@ -161,7 +160,7 @@ export default function (request, context) {
|
|
|
161
160
|
const selectedCrypto = cryptos.find((crypto) => crypto.label === event.data.label)
|
|
162
161
|
return {
|
|
163
162
|
selectedCrypto: selectedCrypto,
|
|
164
|
-
selectedAmount:
|
|
163
|
+
selectedAmount: null,
|
|
165
164
|
calculation: null,
|
|
166
165
|
options: selectedCrypto?.optional || [],
|
|
167
166
|
}
|
package/src/machine/ranking.js
CHANGED
|
@@ -1,28 +1,19 @@
|
|
|
1
1
|
import { createMachine, assign } from 'xstate'
|
|
2
2
|
import ranking from '../api/ranking.js'
|
|
3
3
|
|
|
4
|
-
const ROUND_LIMIT = { DAILY: 56, WEEKLY: 8, MONTHLY: 2, ALL: 2 }
|
|
5
|
-
const ONE_DAY_MS = 24 * 60 * 60 * 1000
|
|
6
|
-
|
|
7
|
-
// 後端每個 cycle 只回傳「當前回合」一筆,前台依當前回合往前回填歷史回合
|
|
8
|
-
// 回合長度 = 當期長度(endDate - beginDate)+ 1 天,回合之間連續無間隔
|
|
9
|
-
function expandPeriodOption(option, cycle) {
|
|
10
|
-
if (!option) return []
|
|
11
|
-
const { round, beginDate, endDate } = option
|
|
12
|
-
// 回合長度取整到整數天,避免後端 endDate 帶當日 23:59:59 等時間造成歷史回合逐期偏移
|
|
13
|
-
const step = Math.floor((endDate - beginDate) / ONE_DAY_MS + 1) * ONE_DAY_MS
|
|
14
|
-
const count = Math.min(ROUND_LIMIT[cycle] || round, round)
|
|
15
|
-
// 降冪排列,當前回合在最前
|
|
16
|
-
return Array.from({ length: count }, (_, i) => ({
|
|
17
|
-
round: round - i,
|
|
18
|
-
beginDate: beginDate - i * step,
|
|
19
|
-
endDate: endDate - i * step,
|
|
20
|
-
}))
|
|
21
|
-
}
|
|
22
|
-
|
|
23
4
|
export default function (request) {
|
|
24
5
|
const { appSecret } = request.config
|
|
25
6
|
const cycleMapping = ['DAILY', 'WEEKLY', 'MONTHLY']
|
|
7
|
+
const limit = { DAILY: 56, WEEKLY: 8, MONTHLY: 2, ALL: 2 }
|
|
8
|
+
|
|
9
|
+
function roundProcess(rounds, cycles) {
|
|
10
|
+
const roundArrays = rounds.map((round) => Array.from({ length: round }, (_, i) => i + 1))
|
|
11
|
+
return roundArrays.reduce((acc, roundArray, index) => {
|
|
12
|
+
const max = limit[cycles[index]] || rounds[index] // 若沒限制則取全部
|
|
13
|
+
acc[cycles[index]] = roundArray.reverse().slice(0, max)
|
|
14
|
+
return acc
|
|
15
|
+
}, {})
|
|
16
|
+
}
|
|
26
17
|
|
|
27
18
|
function transGameData(item) {
|
|
28
19
|
if (!item) return {}
|
|
@@ -39,6 +30,7 @@ export default function (request) {
|
|
|
39
30
|
site: '',
|
|
40
31
|
activityNo: '',
|
|
41
32
|
// api options 回傳的資料
|
|
33
|
+
currentRound: [],
|
|
42
34
|
cycle: '',
|
|
43
35
|
round: 0,
|
|
44
36
|
rule: '',
|
|
@@ -50,7 +42,7 @@ export default function (request) {
|
|
|
50
42
|
gameRanking: [],
|
|
51
43
|
topRanking: [],
|
|
52
44
|
settleStatus: false,
|
|
53
|
-
// 前端這邊用的選單資料 { cycle
|
|
45
|
+
// 前端這邊用的選單資料 { cycle, round }
|
|
54
46
|
options: {},
|
|
55
47
|
},
|
|
56
48
|
states: {
|
|
@@ -164,41 +156,31 @@ export default function (request) {
|
|
|
164
156
|
setRankingOptions: assign((context, event) => {
|
|
165
157
|
const isChampion = event.data?.rule === 'CHAMPION'
|
|
166
158
|
const cycle = event.data?.cycle
|
|
167
|
-
const
|
|
168
|
-
//
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
return acc
|
|
172
|
-
}, {})
|
|
173
|
-
// 依照 cycleMapping 順序取出有資料的 cycle
|
|
174
|
-
const cycleOptions = isChampion ? cycleMapping.filter((c) => optionByCycle[c]) : [cycle]
|
|
175
|
-
// 將每個 cycle 的當前回合往前回填為完整回合列表 { [cycle]: [{ round, beginDate, endDate }] }
|
|
176
|
-
const roundOptions = cycleOptions.reduce((acc, c) => {
|
|
177
|
-
acc[c] = expandPeriodOption(optionByCycle[c], c)
|
|
178
|
-
return acc
|
|
179
|
-
}, {})
|
|
159
|
+
const currentRound = event.data?.currentRound || []
|
|
160
|
+
// 取得結算週期選單列表
|
|
161
|
+
const cycleOptions = isChampion ? cycleMapping.slice(0, currentRound.length) : [cycle]
|
|
162
|
+
const roundOptions = roundProcess(currentRound, cycleOptions)
|
|
180
163
|
// 如果是冠軍龍虎月結算,則加入全部選項
|
|
181
164
|
if (cycle === 'MONTHLY' && isChampion) {
|
|
182
165
|
cycleOptions.push('ALL')
|
|
183
|
-
roundOptions.ALL =
|
|
166
|
+
roundOptions.ALL = roundOptions.MONTHLY
|
|
184
167
|
}
|
|
185
|
-
// 初始 cycle 與 round
|
|
186
|
-
const initialCycle = isChampion ? 'DAILY' : cycle
|
|
187
|
-
const initialRound = roundOptions[initialCycle]?.[0]?.round
|
|
188
168
|
return {
|
|
189
169
|
...event.data,
|
|
190
170
|
options: { cycle: cycleOptions, round: roundOptions },
|
|
191
|
-
|
|
192
|
-
|
|
171
|
+
// 初始固定顯示 DAILY
|
|
172
|
+
cycle: isChampion ? 'DAILY' : cycle,
|
|
173
|
+
round: currentRound[0],
|
|
193
174
|
}
|
|
194
175
|
}),
|
|
195
176
|
setOptions: assign((context, event) => {
|
|
196
|
-
const { cycle, round
|
|
177
|
+
const { cycle, round } = context
|
|
197
178
|
// 處理變更 cycle,如果沒有輸入或沒有變更就不更新
|
|
198
179
|
if (event.data?.cycle && cycle !== event.data?.cycle) {
|
|
199
|
-
const
|
|
200
|
-
const
|
|
201
|
-
|
|
180
|
+
const { currentRound } = context
|
|
181
|
+
const cycleForRound = event.data?.cycle === 'ALL' ? 'MONTHLY' : event.data?.cycle
|
|
182
|
+
const cycleIndex = cycleMapping.indexOf(cycleForRound)
|
|
183
|
+
return { cycle: event.data?.cycle, round: currentRound[cycleIndex] }
|
|
202
184
|
}
|
|
203
185
|
if (event.data?.round && round !== event.data?.round) {
|
|
204
186
|
return { round: event.data?.round }
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import auth from '../api/auth.js'
|
|
3
|
+
import { getDeviceTokenWithRetry } from '../util/deviceToken.js'
|
|
3
4
|
import storage from '../util/storage.js'
|
|
4
5
|
|
|
5
6
|
export default function (request) {
|
|
6
|
-
const { sentry, defaultChannel, defaultSubchannel } = request.config
|
|
7
|
+
const { fpToken, sentry, defaultChannel, defaultSubchannel } = request.config
|
|
7
8
|
return createMachine(
|
|
8
9
|
{
|
|
9
10
|
id: 'user_sign_up',
|
|
@@ -203,7 +204,7 @@ export default function (request) {
|
|
|
203
204
|
services: {
|
|
204
205
|
authenticate: async (context, event) => {
|
|
205
206
|
const { channel, subchannel, signUpData, deviceTokenEnable } = context
|
|
206
|
-
const dt =
|
|
207
|
+
const dt = await getDeviceTokenWithRetry({ fpToken, sentry, hosts: request.hosts, enable: deviceTokenEnable })
|
|
207
208
|
|
|
208
209
|
const affiliateCode = storage.get('ac') || signUpData?.affiliateCode
|
|
209
210
|
const messages = {
|
|
@@ -3,14 +3,13 @@ import payment from '../../api/payment.js'
|
|
|
3
3
|
import user from '../../api/user.js'
|
|
4
4
|
|
|
5
5
|
export default function (request, context) {
|
|
6
|
-
const { paymentDetail = []
|
|
6
|
+
const { paymentDetail = [] } = context || {}
|
|
7
7
|
return createMachine(
|
|
8
8
|
{
|
|
9
9
|
id: 'withdraw_manual_cash',
|
|
10
10
|
initial: 'loading',
|
|
11
11
|
context: {
|
|
12
12
|
paymentDetail,
|
|
13
|
-
doubleWalletWithdrawLimitCheck,
|
|
14
13
|
currentPayment: null,
|
|
15
14
|
banks: [],
|
|
16
15
|
paymentInfo: null,
|
|
@@ -235,39 +234,11 @@ export default function (request, context) {
|
|
|
235
234
|
},
|
|
236
235
|
},
|
|
237
236
|
services: {
|
|
238
|
-
// 雙錢包出款規則閘門(對齊 client-pwa-ssr useWithdrawManual.initialize 流程):
|
|
239
|
-
// - '0':只抓 CASH withdrawRule
|
|
240
|
-
// - '1':只抓 ACTIVITY withdrawRule(不論達標與否,CASH 規則不參與閘門,省一次 API)
|
|
241
|
-
// - '2' + ACTIVITY 不可提:略過 CASH withdrawRule(少一次 API)
|
|
242
|
-
// - '2' + ACTIVITY 達標:續抓 CASH withdrawRule 作為最終出款依據
|
|
243
237
|
fetchInitData: async (context, event) => {
|
|
244
|
-
const { paymentDetail = []
|
|
238
|
+
const { paymentDetail = [] } = context
|
|
245
239
|
const currentPayment = paymentDetail.find((element) => element.category === 'manual' && element.transferType === 'withdraw')
|
|
246
240
|
|
|
247
|
-
|
|
248
|
-
if (doubleWalletWithdrawLimitCheck === '2' || doubleWalletWithdrawLimitCheck === '1') {
|
|
249
|
-
const activityRule = await request.send(payment.getDoubleWalletWithdrawRule({ walletType: 'ACTIVITY' }))
|
|
250
|
-
// '1' 模式僅看 ACTIVITY,'2' 模式 ACTIVITY 不可提則 CASH 不參與閘門 — 兩種情況都用 activityRule 為依據。
|
|
251
|
-
// enableWithdraw 用 truthy 比較對齊 client-pwa-ssr useWithdrawManual(!enableWithdraw.value),避免 backend 回傳非 boolean truthy 值(如 1)時誤判。
|
|
252
|
-
if (doubleWalletWithdrawLimitCheck === '1' || !activityRule?.enableWithdraw) {
|
|
253
|
-
prefetchedRule = activityRule
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
if (prefetchedRule) {
|
|
258
|
-
const [paymentInfo, orders] = await Promise.all([
|
|
259
|
-
request.send(payment.getBindingPaymentInfo()),
|
|
260
|
-
request.send(payment.getPendingOrder({ transferType: 'WITHDRAW' })),
|
|
261
|
-
])
|
|
262
|
-
return {
|
|
263
|
-
currentPayment,
|
|
264
|
-
paymentInfo,
|
|
265
|
-
withdrawRule: prefetchedRule,
|
|
266
|
-
processing: orders[0],
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
const [paymentInfo, cashRule, orders] = await Promise.all([
|
|
241
|
+
const [paymentInfo, withdrawRule, orders] = await Promise.all([
|
|
271
242
|
request.send(payment.getBindingPaymentInfo()),
|
|
272
243
|
request.send(payment.getDoubleWalletWithdrawRule({ walletType: 'CASH' })),
|
|
273
244
|
request.send(payment.getPendingOrder({ transferType: 'WITHDRAW' })),
|
|
@@ -276,7 +247,7 @@ export default function (request, context) {
|
|
|
276
247
|
return {
|
|
277
248
|
currentPayment,
|
|
278
249
|
paymentInfo,
|
|
279
|
-
withdrawRule
|
|
250
|
+
withdrawRule,
|
|
280
251
|
processing: orders[0],
|
|
281
252
|
}
|
|
282
253
|
},
|
package/src/request/config.js
CHANGED
|
@@ -16,7 +16,6 @@ export default class Config {
|
|
|
16
16
|
defaultSubchannel,
|
|
17
17
|
socketURL,
|
|
18
18
|
bucketName,
|
|
19
|
-
getDt,
|
|
20
19
|
}) {
|
|
21
20
|
this.apiURL = apiURL
|
|
22
21
|
this.apiVersion = apiVersion
|
|
@@ -31,7 +30,6 @@ export default class Config {
|
|
|
31
30
|
this.defaultSubchannel = defaultSubchannel
|
|
32
31
|
this.socketURL = socketURL
|
|
33
32
|
this.bucketName = bucketName
|
|
34
|
-
this.getDt = getDt
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
setApiURL(url) {
|
|
@@ -0,0 +1,59 @@
|
|
|
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 }
|
package/src/util/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { getDeviceToken, getDeviceTokenWithRetry } from './deviceToken.js'
|
|
1
2
|
import storage from './storage.js'
|
|
2
3
|
import * as constant from './constant.js'
|
|
3
4
|
import { max } from './math.js'
|
|
4
5
|
|
|
5
|
-
export default {}
|
|
6
|
+
export default { getDeviceToken, getDeviceTokenWithRetry }
|
|
6
7
|
export { constant, storage, max }
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
# JT-1776243420: Third-Party Register Carry Phone / Email Payload
|
|
2
|
-
|
|
3
|
-
## Key Changes
|
|
4
|
-
|
|
5
|
-
1. Extended third-party redirect payload assembly to read `tp_phone`, `tp_countryCode`, and `tp_email` from storage.
|
|
6
|
-
2. Preserved existing affiliate code / nickname behavior and appended new fields only when values are valid.
|
|
7
|
-
3. Cleans the temporary third-party storage keys after composing the redirect query.
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Key Findings
|
|
12
|
-
|
|
13
|
-
### Strengths
|
|
14
|
-
|
|
15
|
-
1. The change is tightly scoped to the third-party auth redirect builder in `src/machine/auth.js:477-520`.
|
|
16
|
-
2. Existing affiliate code and nickname logic remains unchanged while phone / email are additive only.
|
|
17
|
-
3. Temporary keys are removed after payload composition, reducing leakage into later unrelated auth flows.
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
### Behavior Observed
|
|
22
|
-
|
|
23
|
-
1. Static review confirms `phone`, `countryCode`, and `email` are appended only when storage values are not `undefined` / `null`.
|
|
24
|
-
2. Channel and subchannel fallback logic stays intact after the new fields are added.
|
|
25
|
-
3. No unrelated file changes were present in this repo for the review scope.
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
|
-
## 🔧 Change Type
|
|
30
|
-
|
|
31
|
-
- [ ] 🐛 Bug fix
|
|
32
|
-
- [x] ✨ New feature
|
|
33
|
-
- [ ] 💄 Style
|
|
34
|
-
- [ ] ♻️ Refactor
|
|
35
|
-
- [ ] ⚡ Performance
|
|
36
|
-
- [ ] 🔧 Chore
|
|
37
|
-
|
|
38
|
-
---
|
|
39
|
-
|
|
40
|
-
## 📱 Impact Scope
|
|
41
|
-
|
|
42
|
-
- Third-party register / login redirect query assembly in cuora shared auth machine.
|
|
43
|
-
- Downstream PWA clients that store `tp_phone`, `tp_countryCode`, and `tp_email` before `LOGIN_3PARTY`.
|
|
44
|
-
|
|
45
|
-
---
|
|
46
|
-
|
|
47
|
-
## Test Completion Status
|
|
48
|
-
|
|
49
|
-
| Item | Validation Tested | Status |
|
|
50
|
-
| -------------------------- | --------------------------------------------------------------------- | ------- |
|
|
51
|
-
| Diff hygiene | `git diff --check` in `cuora-module` | PASS |
|
|
52
|
-
| Shared auth payload review | Reviewed `src/machine/auth.js:477-520` against ticket intent | PASS |
|
|
53
|
-
| Runtime redirect execution | Not run in this repo directly; validated through client repos instead | NOT RUN |
|
|
54
|
-
|
|
55
|
-
---
|
|
56
|
-
|
|
57
|
-
## 📋 Spec Validation (Aligned with review-playbook)
|
|
58
|
-
|
|
59
|
-
| Spec Item | Evidence (File/Line/Result) | Status |
|
|
60
|
-
| ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | ------ |
|
|
61
|
-
| Third-party flow can carry phone when client stored it | `src/machine/auth.js:479-520` reads `tp_phone` / `tp_countryCode` and appends them to `referralObj` | PASS |
|
|
62
|
-
| Third-party flow can carry email when client stored it | `src/machine/auth.js:481-520` reads `tp_email` and appends it to `referralObj` | PASS |
|
|
63
|
-
| Affiliate code and nickname keep original logic | `src/machine/auth.js:477-500` keeps `ac` / `nick_name` handling unchanged | PASS |
|
|
64
|
-
| Temporary third-party data does not leak into later unrelated flows | `src/machine/auth.js:518-520` removes the temporary storage keys after composing the redirect URL | PASS |
|
|
65
|
-
|
|
66
|
-
---
|
|
67
|
-
|
|
68
|
-
## 📋 Standards Checklist (Summary)
|
|
69
|
-
|
|
70
|
-
| Category | Result | Notes |
|
|
71
|
-
| ---------------------- | ------- | --------------------------------------------------------------------------- |
|
|
72
|
-
| Memory Safety | PASS | Simple storage reads and object assembly only. |
|
|
73
|
-
| Rendering Performance | PASS | No rendering code touched. |
|
|
74
|
-
| Network Requests | PASS | Existing redirect flow only; no extra requests added. |
|
|
75
|
-
| Bundle Optimization | PASS | No new imports or heavy logic added. |
|
|
76
|
-
| Code Quality | PASS | Scope is narrow and branch contains only the required file change. |
|
|
77
|
-
| Vue / Nuxt Standards | NOT RUN | Shared module; not a Vue / Nuxt surface. |
|
|
78
|
-
| SSR Security Standards | PASS | Query parameters are assembled from existing client-side storage path only. |
|
|
79
|
-
| Project Conventions | PASS | Matches existing storage-guard pattern used for affiliate / nickname. |
|
|
80
|
-
|
|
81
|
-
## Conclusion
|
|
82
|
-
|
|
83
|
-
This repo’s shared auth-machine change matches the ticket intent and is internally consistent. Runtime behavior was not executed in `cuora-module` directly, but both client repos now pass the new storage keys into this shared payload path.
|
|
84
|
-
|
|
85
|
-
**Overall Result:** PASS (PARTIAL)
|