@jetthai/cuora 2.0.0-beta.1 → 2.0.0
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/sync-ai-prompts.md +93 -0
- package/.claude/settings.local.json +23 -0
- package/.github/copilot-instructions.md +405 -0
- package/.husky/post-checkout +32 -0
- package/.husky/pre-commit +1 -3
- package/.husky/pre-push +36 -0
- package/AGENTS.md +405 -0
- package/AI_PROMPT_SOURCE.md +403 -0
- package/CHANGELOG.md +274 -3
- package/CLAUDE.md +405 -0
- package/GEMINI.md +405 -0
- package/README.md +299 -15
- package/docs/kibana/crypto-way-deposit-amount-bug-analysis.md +1003 -0
- package/docs/kibana/play-providerId-error.md +202 -0
- package/docs/kibana/play-selectedWalletType.md +1 -0
- package/docs/kibana/play-selectedWalletType_2.md +1 -0
- package/docs/kibana/play-selectedWalletType_analysis.md +565 -0
- package/package.json +3 -3
- package/scripts/auto-version.js +68 -0
- package/scripts/auto-version.sh +33 -0
- package/scripts/branch-auto-npm-publish.js +29 -0
- package/scripts/check-version.sh +36 -0
- package/scripts/clean-tags.sh +84 -0
- package/src/api/account.js +0 -1
- package/src/api/activity.js +22 -37
- package/src/api/auth.js +5 -36
- package/src/api/common.js +5 -3
- package/src/api/game.js +0 -10
- package/src/api/payment.js +17 -55
- package/src/api/user.js +10 -16
- package/src/index.js +2 -2
- package/src/machine/activity/activity_cash.js +84 -36
- package/src/machine/activity/cash_rain_activity.js +0 -1
- package/src/machine/activity/continue_deposit_activity.js +0 -1
- package/src/machine/activity/deposit_activity.js +0 -1
- package/src/machine/activity/diamond_shop_activity_cash.js +0 -8
- package/src/machine/activity/fafafa_activity.js +0 -11
- package/src/machine/activity/friend_invite_friends_activity.js +8 -7
- package/src/machine/activity/index.js +0 -12
- package/src/machine/activity/instant_rebate_activity.js +0 -1
- package/src/machine/activity/jackpot.js +0 -1
- package/src/machine/activity/otp_verified_activity.js +0 -1
- package/src/machine/activity/ranking_activity.js +0 -1
- package/src/machine/activity/roulette_activity_v2.js +0 -1
- package/src/machine/activity/sign_in_activity.js +0 -1
- package/src/machine/activity/sign_in_monthly_activity.js +1 -2
- package/src/machine/activity/specify_bets_activity.js +0 -1
- package/src/machine/activity/specify_turnover_activity.js +0 -1
- package/src/machine/activity/time_bomb_activity.js +0 -1
- package/src/machine/activity/vip_card_activity.js +0 -1
- package/src/machine/auth.js +112 -113
- package/src/machine/auth_otp_v3.js +11 -8
- package/src/machine/bank_binding.js +2 -3
- package/src/machine/common.js +14 -112
- package/src/machine/deposit/crypto_bank_cash.js +20 -35
- package/src/machine/deposit/crypto_qrcode_cash.js +26 -64
- package/src/machine/deposit/crypto_way_cash.js +48 -37
- package/src/machine/deposit/direct_cash.js +8 -10
- package/src/machine/deposit/index.js +0 -28
- package/src/machine/deposit/loadcard_cash.js +14 -32
- package/src/machine/deposit/manual_cash.js +18 -28
- package/src/machine/deposit/qrcode_cash.js +15 -32
- package/src/machine/deposit/usdt_cash.js +1 -15
- package/src/machine/deposit/virtual_bank_cash.js +13 -12
- package/src/machine/error.js +7 -1
- package/src/machine/game_betslip.js +0 -1
- package/src/machine/game_favorite_v2.js +0 -1
- package/src/machine/game_info.js +1 -13
- package/src/machine/game_search_cash.js +2 -13
- package/src/machine/game_v2_1.js +42 -166
- package/src/machine/honor_board_cash.js +8 -11
- package/src/machine/inbox.js +43 -105
- package/src/machine/index.js +0 -32
- package/src/machine/leaderboard.js +8 -12
- package/src/machine/navbar.js +1 -3
- package/src/machine/ranking.js +45 -30
- package/src/machine/reward_cash.js +0 -40
- package/src/machine/roulette_v2.js +14 -11
- package/src/machine/setting.js +0 -1
- package/src/machine/side_cash.js +3 -3
- package/src/machine/user_info.js +0 -1
- package/src/machine/user_photo.js +0 -1
- package/src/machine/user_reset_password.js +0 -14
- package/src/machine/user_sign_up.js +46 -61
- package/src/machine/websocket.js +18 -62
- package/src/machine/withdraw/index.js +0 -6
- package/src/machine/withdraw/withdraw_manual_cash.js +59 -39
- package/src/request/config.js +2 -0
- package/src/request/request.js +49 -60
- package/src/util/amount.js +8 -0
- package/src/util/constant.js +0 -1
- package/src/util/err998SentryExtra.js +26 -0
- package/src/util/index.js +2 -4
- package/src/util/paramStore.js +139 -0
- package/src/util/storage.js +3 -4
- package/BREAKING_CHANGES.md +0 -9
- package/resetGitBranch.sh +0 -101
- package/src/lib/fingerprint_v3_11_12.js +0 -11433
- package/src/machine/activity/activity.js +0 -213
- package/src/machine/activity/diamond_shop_activity_fc.js +0 -197
- package/src/machine/activity/diamond_shop_activity_vn.js +0 -179
- package/src/machine/activity/invite_friends_activity.js +0 -115
- package/src/machine/activity/mini_game_activity.js +0 -69
- package/src/machine/activity/return_bonus_activity.js +0 -155
- package/src/machine/auth_otp_v2.js +0 -178
- package/src/machine/bank_binding_amb.js +0 -146
- package/src/machine/bonus.js +0 -76
- package/src/machine/deposit/amb.js +0 -93
- package/src/machine/deposit/crypto_bank.js +0 -340
- package/src/machine/deposit/crypto_qrcode.js +0 -158
- package/src/machine/deposit/crypto_way.js +0 -253
- package/src/machine/deposit/deposit_fc.js +0 -272
- package/src/machine/deposit/direct.js +0 -311
- package/src/machine/deposit/float.js +0 -375
- package/src/machine/deposit/krway.js +0 -152
- package/src/machine/deposit/loadcard_vn.js +0 -352
- package/src/machine/deposit/manual_vn.js +0 -463
- package/src/machine/deposit/qrcode_v2.js +0 -339
- package/src/machine/deposit/usdt.js +0 -163
- package/src/machine/deposit/virtual_bank_vn.js +0 -270
- package/src/machine/deposit/vpay.js +0 -374
- package/src/machine/game_hot_new.js +0 -91
- package/src/machine/game_replay.js +0 -47
- package/src/machine/game_search_v2.js +0 -402
- package/src/machine/honor_board.js +0 -144
- package/src/machine/merge.js +0 -58
- package/src/machine/payment_data.js +0 -87
- package/src/machine/promotions.js +0 -163
- package/src/machine/reward.js +0 -256
- package/src/machine/reward_fc.js +0 -99
- package/src/machine/side.js +0 -160
- package/src/machine/side_v2.js +0 -223
- package/src/machine/vip_table.js +0 -58
- package/src/machine/welcome.js +0 -111
- package/src/machine/withdraw/withdraw_crypto_cash.js +0 -328
- package/src/machine/withdraw/withdraw_krway.js +0 -223
- package/src/machine/withdraw/withdraw_manual.js +0 -541
- package/src/util/deviceToken.js +0 -60
- package/src/util/math.js +0 -4
- package/test/api.behavior.test.js +0 -69
- package/test/api.contract.test.js +0 -18
- package/test/config.test.js +0 -27
- package/test/deviceToken.test.js +0 -139
- package/test/helpers.coverage.test.js +0 -11
- package/test/helpers.js +0 -91
- package/test/index.exports.test.js +0 -14
- package/test/machine.activity.core.coverage.test.js +0 -337
- package/test/machine.activity.gap.coverage.test.js +0 -252
- package/test/machine.activity.more.coverage.test.js +0 -180
- package/test/machine.activity_plus_and_binding_amb.coverage.test.js +0 -201
- package/test/machine.activity_timer_bonus.coverage.test.js +0 -136
- package/test/machine.activity_welcome.low.coverage.test.js +0 -211
- package/test/machine.amb_rewardfc_websocket.more.coverage.test.js +0 -201
- package/test/machine.auth.coverage.test.js +0 -215
- package/test/machine.bank_binding.test.js +0 -143
- package/test/machine.binding_otp_krway.coverage.test.js +0 -223
- package/test/machine.contract.test.js +0 -50
- package/test/machine.crypto_bank.coverage.test.js +0 -270
- package/test/machine.crypto_way.coverage.test.js +0 -108
- package/test/machine.crypto_way_cash.coverage.test.js +0 -114
- package/test/machine.definition.test.js +0 -137
- package/test/machine.deposit.manual.coverage.test.js +0 -365
- package/test/machine.deposit_fc.coverage.test.js +0 -126
- package/test/machine.direct.coverage.test.js +0 -96
- package/test/machine.direct_cash.coverage.test.js +0 -108
- package/test/machine.error.coverage.test.js +0 -37
- package/test/machine.events.test.js +0 -126
- package/test/machine.favorite_jackpot.coverage.test.js +0 -82
- package/test/machine.float.coverage.test.js +0 -136
- package/test/machine.flow.test.js +0 -226
- package/test/machine.game_hot_new_vip_table.coverage.test.js +0 -105
- package/test/machine.game_search_cash.coverage.test.js +0 -195
- package/test/machine.game_search_v2.test.js +0 -199
- package/test/machine.game_user_profile.coverage.test.js +0 -100
- package/test/machine.honor_board.test.js +0 -148
- package/test/machine.inbox.common.coverage.test.js +0 -304
- package/test/machine.loadcard_cash.coverage.test.js +0 -101
- package/test/machine.loadcard_vn.coverage.test.js +0 -122
- package/test/machine.misc.coverage.test.js +0 -361
- package/test/machine.more2.coverage.test.js +0 -261
- package/test/machine.options.execution.test.js +0 -272
- package/test/machine.priority.coverage.test.js +0 -629
- package/test/machine.qrcode_cash.coverage.test.js +0 -107
- package/test/machine.qrcode_v2.coverage.test.js +0 -121
- package/test/machine.regression.test.js +0 -82
- package/test/machine.roulette_v2.test.js +0 -142
- package/test/machine.side_reward_reset.coverage.test.js +0 -220
- package/test/machine.targeted.coverage.test.js +0 -313
- package/test/machine.usdt.coverage.test.js +0 -95
- package/test/machine.usdt_cash.coverage.test.js +0 -73
- package/test/machine.vip_card_activity.test.js +0 -114
- package/test/machine.virtual_bank_cash.coverage.test.js +0 -105
- package/test/machine.virtual_bank_vn.coverage.test.js +0 -105
- package/test/machine.vpay.coverage.test.js +0 -142
- package/test/machine.withdraw_crypto_cash.coverage.test.js +0 -166
- package/test/machine.withdraw_krway.coverage.test.js +0 -123
- package/test/machine.withdraw_manual.coverage.test.js +0 -185
- package/test/machine.withdraw_manual_cash.coverage.test.js +0 -123
- package/test/request.test.js +0 -325
- package/test/util.storage.errors.test.js +0 -47
- package/test/util.test.js +0 -41
package/src/machine/auth.js
CHANGED
|
@@ -3,25 +3,28 @@ 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'
|
|
7
6
|
import common from '../api/common.js'
|
|
8
7
|
import pickBy from 'lodash/pickBy.js'
|
|
8
|
+
import { readParamFromLocation, writeParam, normalize, AC_KEYS, FC_KEYS } from '../util/paramStore.js'
|
|
9
9
|
|
|
10
10
|
export default function (request) {
|
|
11
|
-
const { appSecret, clientId,
|
|
12
|
-
const getDtWithRetry = request.config.getDeviceTokenWithRetry || getDeviceTokenWithRetry
|
|
11
|
+
const { appSecret, clientId, sentry } = request.config
|
|
13
12
|
const tokenKey = `cuora_${clientId}`
|
|
14
|
-
const userKey = `cuora_tempuser`
|
|
15
13
|
const phoneCountryCode = 'phone_countrycode'
|
|
16
14
|
const accountPhoneKey = 'account_phone'
|
|
17
15
|
const accountEmailKey = 'account_email'
|
|
18
16
|
const accountUsernameKey = 'account_username'
|
|
19
|
-
|
|
17
|
+
// loginMethods 的鍵 → setAccount 寫入的 storage key。
|
|
18
|
+
// LOGIN_ID 寫的是 accountUsernameKey,在 loginMethods 卻算 'local',此對照無法由 key 名反推。
|
|
19
|
+
const rememberedAccountKeys = [
|
|
20
|
+
['local', accountUsernameKey],
|
|
21
|
+
['phone', accountPhoneKey],
|
|
22
|
+
['email', accountEmailKey],
|
|
23
|
+
]
|
|
20
24
|
|
|
21
25
|
return createMachine(
|
|
22
26
|
{
|
|
23
27
|
id: 'auth',
|
|
24
|
-
predictableActionArguments: true,
|
|
25
28
|
initial: 'fetchingConfig',
|
|
26
29
|
context: {
|
|
27
30
|
base: '',
|
|
@@ -43,6 +46,7 @@ export default function (request) {
|
|
|
43
46
|
redirectURL: null,
|
|
44
47
|
reCaptchaToken: null,
|
|
45
48
|
fc: null,
|
|
49
|
+
dt: null,
|
|
46
50
|
},
|
|
47
51
|
states: {
|
|
48
52
|
fetchingConfig: {
|
|
@@ -50,7 +54,7 @@ export default function (request) {
|
|
|
50
54
|
src: 'fetchSiteConfig',
|
|
51
55
|
onDone: {
|
|
52
56
|
target: 'idle',
|
|
53
|
-
actions: 'setSiteConfig',
|
|
57
|
+
actions: ['setSiteConfig', 'pruneRememberedAccounts'],
|
|
54
58
|
},
|
|
55
59
|
onError: {
|
|
56
60
|
target: 'idle',
|
|
@@ -74,32 +78,6 @@ export default function (request) {
|
|
|
74
78
|
},
|
|
75
79
|
},
|
|
76
80
|
},
|
|
77
|
-
authenticationGuest: {
|
|
78
|
-
invoke: {
|
|
79
|
-
src: 'authenticateGuest',
|
|
80
|
-
onDone: {
|
|
81
|
-
target: 'authenticated',
|
|
82
|
-
actions: 'setToken',
|
|
83
|
-
},
|
|
84
|
-
onError: {
|
|
85
|
-
target: 'idle',
|
|
86
|
-
actions: 'removeToken',
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
authenticationApp: {
|
|
91
|
-
invoke: {
|
|
92
|
-
src: 'authenticateApp',
|
|
93
|
-
onDone: {
|
|
94
|
-
target: 'authenticated',
|
|
95
|
-
actions: ['setToken'],
|
|
96
|
-
},
|
|
97
|
-
onError: {
|
|
98
|
-
target: 'idle',
|
|
99
|
-
actions: 'removeToken',
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
81
|
authenticated: {
|
|
104
82
|
invoke: {
|
|
105
83
|
src: 'fetchUserInfo',
|
|
@@ -113,6 +91,28 @@ export default function (request) {
|
|
|
113
91
|
},
|
|
114
92
|
},
|
|
115
93
|
otpChecking: {
|
|
94
|
+
initial: 'pending',
|
|
95
|
+
states: {
|
|
96
|
+
pending: {
|
|
97
|
+
after: {
|
|
98
|
+
TIMEOUT: {
|
|
99
|
+
target: 'fetching',
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
fetching: {
|
|
104
|
+
invoke: {
|
|
105
|
+
src: 'fetchUserInfo',
|
|
106
|
+
onDone: {
|
|
107
|
+
target: 'pending',
|
|
108
|
+
actions: ['setUserInfo', 'extendToken'],
|
|
109
|
+
},
|
|
110
|
+
onError: {
|
|
111
|
+
target: 'pending',
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
116
|
on: {
|
|
117
117
|
OTP_VERIFIED: {
|
|
118
118
|
target: 'loginSuccess',
|
|
@@ -180,10 +180,12 @@ export default function (request) {
|
|
|
180
180
|
initial: 'deviceTokenChecking',
|
|
181
181
|
states: {
|
|
182
182
|
deviceTokenChecking: {
|
|
183
|
+
entry: 'clearDeviceToken',
|
|
183
184
|
invoke: {
|
|
184
185
|
src: 'checkDeviceToken',
|
|
185
186
|
onDone: {
|
|
186
187
|
target: 'checkDeviceTokenDone',
|
|
188
|
+
actions: 'setDeviceToken',
|
|
187
189
|
},
|
|
188
190
|
onError: {
|
|
189
191
|
target: 'fetching',
|
|
@@ -263,9 +265,6 @@ export default function (request) {
|
|
|
263
265
|
CLEAR: {
|
|
264
266
|
target: '.logout',
|
|
265
267
|
},
|
|
266
|
-
LOGIN_GUEST: {
|
|
267
|
-
target: '.authenticationGuest',
|
|
268
|
-
},
|
|
269
268
|
LOGIN_ID: {
|
|
270
269
|
target: '.authentication',
|
|
271
270
|
actions: ['setReCaptchaToken', 'setLoginId'],
|
|
@@ -278,16 +277,9 @@ export default function (request) {
|
|
|
278
277
|
target: '.authentication',
|
|
279
278
|
actions: ['setReCaptchaToken', 'setLoginEmail'],
|
|
280
279
|
},
|
|
281
|
-
LOGIN_LOCAL: {
|
|
282
|
-
target: '.authentication',
|
|
283
|
-
actions: 'setLoginLocal',
|
|
284
|
-
},
|
|
285
280
|
LOGIN_3PARTY: {
|
|
286
281
|
actions: 'redirectTo3Party',
|
|
287
282
|
},
|
|
288
|
-
LOGIN_APP: {
|
|
289
|
-
target: '.authenticationApp',
|
|
290
|
-
},
|
|
291
283
|
LOGIN_TELEGRAM: {
|
|
292
284
|
target: '.authentication',
|
|
293
285
|
actions: 'setLoginTelegram',
|
|
@@ -322,6 +314,19 @@ export default function (request) {
|
|
|
322
314
|
siteConfig: { ...event.data, loginMethods: pickBy(loginMethods), registerMethods: pickBy(registerMethods) },
|
|
323
315
|
}
|
|
324
316
|
}),
|
|
317
|
+
// setAccount 寫入的帳號 TTL 是 31 天,且只互斥清除另外兩支 key,
|
|
318
|
+
// 後台關掉某種登入方式後殘值仍在,下游會把它回填進已改型別的輸入框(例如把 email 填進 phone-only 站台)。
|
|
319
|
+
// 非 assign action,故取得的是 setSiteConfig 套用後的 context。
|
|
320
|
+
pruneRememberedAccounts: (context) => {
|
|
321
|
+
// fetchSiteConfig 失敗會走 onError 不進到這裡;此處防的是回傳成功但 loginMethods 整包缺失,避免誤清全部記住的帳號。
|
|
322
|
+
const enabledMethods = context.siteConfig?.loginMethods
|
|
323
|
+
if (!enabledMethods || !Object.keys(enabledMethods).length) return
|
|
324
|
+
rememberedAccountKeys.forEach(([method, key]) => {
|
|
325
|
+
if (enabledMethods[method]) return
|
|
326
|
+
storage.remove(key)
|
|
327
|
+
if (method === 'phone') storage.remove(phoneCountryCode)
|
|
328
|
+
})
|
|
329
|
+
},
|
|
325
330
|
setReCaptchaToken: assign((context, event) => {
|
|
326
331
|
const { reCaptchaToken } = event.data
|
|
327
332
|
return {
|
|
@@ -360,28 +365,15 @@ export default function (request) {
|
|
|
360
365
|
},
|
|
361
366
|
}
|
|
362
367
|
}),
|
|
363
|
-
setLoginLocal: assign((context, event) => {
|
|
364
|
-
const { username, password } = event.data
|
|
365
|
-
storage.set(userKey, username, {
|
|
366
|
-
path: '/',
|
|
367
|
-
maxAge: 60 * 60 * 24,
|
|
368
|
-
})
|
|
369
|
-
return {
|
|
370
|
-
loginData: {
|
|
371
|
-
provider: 'local',
|
|
372
|
-
username,
|
|
373
|
-
password,
|
|
374
|
-
},
|
|
375
|
-
}
|
|
376
|
-
}),
|
|
377
368
|
setLoginTelegram: assign((context, event) => {
|
|
378
|
-
const { loginType, additionalUserInfo, isSignature } = event.data
|
|
369
|
+
const { loginType, additionalUserInfo, isSignature, idToken } = event.data
|
|
379
370
|
return {
|
|
380
371
|
loginData: {
|
|
381
372
|
provider: 'telegram',
|
|
382
373
|
loginType,
|
|
383
374
|
additionalUserInfo,
|
|
384
375
|
isSignature,
|
|
376
|
+
idToken,
|
|
385
377
|
},
|
|
386
378
|
}
|
|
387
379
|
}),
|
|
@@ -400,6 +392,13 @@ export default function (request) {
|
|
|
400
392
|
token: event.data,
|
|
401
393
|
}
|
|
402
394
|
}),
|
|
395
|
+
setDeviceToken: assign((context, event) => {
|
|
396
|
+
return {
|
|
397
|
+
dt: event.data?.dt ?? null,
|
|
398
|
+
}
|
|
399
|
+
}),
|
|
400
|
+
// checkDeviceToken 失敗走 onError 不會執行 setDeviceToken,先清空避免下游讀到前一個帳號的 dt
|
|
401
|
+
clearDeviceToken: assign({ dt: null }),
|
|
403
402
|
setAccount: assign((context, event) => {
|
|
404
403
|
if (context.loginData.username) {
|
|
405
404
|
storage.remove(accountEmailKey)
|
|
@@ -434,7 +433,7 @@ export default function (request) {
|
|
|
434
433
|
path: '/',
|
|
435
434
|
maxAge: 300,
|
|
436
435
|
})
|
|
437
|
-
return { token: null }
|
|
436
|
+
return { token: null, dt: null }
|
|
438
437
|
}),
|
|
439
438
|
extendToken: assign((context, event) => {
|
|
440
439
|
const token = storage.get(tokenKey)
|
|
@@ -445,61 +444,69 @@ export default function (request) {
|
|
|
445
444
|
return { token }
|
|
446
445
|
}),
|
|
447
446
|
redirectTo3Party: async (context, event) => {
|
|
448
|
-
const { provider,
|
|
447
|
+
const { provider, fc } = event.data
|
|
449
448
|
const deviceTokenEnable = context.siteConfig?.dtVerify
|
|
450
449
|
|
|
451
|
-
const dt = await
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
450
|
+
const dt = deviceTokenEnable ? await request.config.getDt?.() : undefined
|
|
451
|
+
|
|
452
|
+
// 宿主若明確帶了 ac(使用者在補資料頁/代理碼彈窗按下確認,含刻意留白)以它為準:
|
|
453
|
+
// 網址層仍留著進站時的 ?ac=,不讓步的話使用者剛清掉的值會被網址撿回來又寫回兩個媒介
|
|
454
|
+
const hasExplicitAc = !!event.data && Object.prototype.hasOwnProperty.call(event.data, 'ac')
|
|
455
|
+
const acRead = readParamFromLocation(AC_KEYS)
|
|
456
|
+
const affiliateCode = hasExplicitAc ? normalize(event.data.ac) : acRead.value
|
|
457
|
+
// 宿主可能傳進字面 'undefined',先 normalize 才不會蓋掉網址/儲存層的真值
|
|
458
|
+
const friendCode = normalize(fc) || readParamFromLocation(FC_KEYS).value
|
|
459
|
+
|
|
460
|
+
// 本段結尾以 window.location.href 離站,離站後 SPA 記憶體全丟;導頁前先落地雙寫
|
|
461
|
+
writeParam('ac', affiliateCode, { sentry })
|
|
462
|
+
writeParam('fc', friendCode, { sentry })
|
|
457
463
|
|
|
458
|
-
const affiliateCode = storage.get('ac')
|
|
459
464
|
const nickname = storage.get('nk')
|
|
465
|
+
const phone = storage.get('tp_phone')
|
|
466
|
+
const countryCode = storage.get('tp_countryCode')
|
|
467
|
+
const email = storage.get('tp_email')
|
|
468
|
+
const birthday = storage.get('tp_birthday')
|
|
460
469
|
const messages = {
|
|
461
470
|
url: window.location.href,
|
|
462
|
-
channelOrders: [
|
|
463
|
-
{ channel: storage.get('channel'), subchannel: storage.get('subchannel') },
|
|
464
|
-
{ channel: defaultChannel, subchannel: defaultSubchannel },
|
|
465
|
-
{ channel: channel, subchannel: subchannel },
|
|
466
|
-
],
|
|
467
471
|
affiliateCode,
|
|
472
|
+
acSource: hasExplicitAc ? 'event' : acRead.from,
|
|
468
473
|
nickname,
|
|
469
474
|
}
|
|
470
|
-
sentry?.captureMessage(JSON.stringify(messages))
|
|
471
475
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
476
|
+
// 空值一律不進 query。dt 與 fc 原本裸展開進 URLSearchParams,兩者為 undefined 時會被
|
|
477
|
+
// 序列化成字面字串 dt=undefined / fc=undefined,後端收到的是 "undefined" 而非缺省
|
|
478
|
+
const query = pickBy(
|
|
479
|
+
{
|
|
480
|
+
provider,
|
|
481
|
+
redirectURI: `${window.location.protocol}//${window.location.host}${context.base}`,
|
|
482
|
+
ac: affiliateCode,
|
|
483
|
+
nick_name: nickname,
|
|
484
|
+
phone,
|
|
485
|
+
countryCode,
|
|
486
|
+
email,
|
|
487
|
+
birthday,
|
|
488
|
+
dt,
|
|
489
|
+
platform: 'pwa',
|
|
490
|
+
fc: friendCode,
|
|
491
|
+
},
|
|
492
|
+
(value) => normalize(value) !== null
|
|
493
|
+
)
|
|
480
494
|
|
|
481
|
-
|
|
482
|
-
|
|
495
|
+
storage.remove('tp_phone')
|
|
496
|
+
storage.remove('tp_countryCode')
|
|
497
|
+
storage.remove('tp_email')
|
|
498
|
+
// tp_birthday 不在此移除:client 於回站登入完成後以 /self 補交作為備援,由 client 消費後移除
|
|
483
499
|
|
|
484
500
|
const fullURL = request.config.fullURL
|
|
485
501
|
|
|
486
|
-
const redirectURL = urljoin(
|
|
487
|
-
fullURL,
|
|
488
|
-
'login?' +
|
|
489
|
-
new URLSearchParams({
|
|
490
|
-
provider,
|
|
491
|
-
redirectURI: `${window.location.protocol}//${window.location.host}${context.base}`,
|
|
492
|
-
...referralObj,
|
|
493
|
-
dt,
|
|
494
|
-
platform: 'pwa',
|
|
495
|
-
fc,
|
|
496
|
-
}).toString()
|
|
497
|
-
)
|
|
502
|
+
const redirectURL = urljoin(fullURL, 'login?' + new URLSearchParams(query).toString())
|
|
498
503
|
|
|
499
504
|
window.location.href = redirectURL
|
|
500
505
|
},
|
|
501
506
|
setUserInfo: assign((context, event) => {
|
|
502
|
-
|
|
507
|
+
if (event.data?.uid_site) {
|
|
508
|
+
sentry?.setUser({ id: event.data.uid_site })
|
|
509
|
+
}
|
|
503
510
|
return {
|
|
504
511
|
userInfo: event.data,
|
|
505
512
|
}
|
|
@@ -511,19 +518,11 @@ export default function (request) {
|
|
|
511
518
|
}),
|
|
512
519
|
},
|
|
513
520
|
services: {
|
|
514
|
-
authenticateApp: async (context, event) => {
|
|
515
|
-
const { token } = await request.send(auth.loginApp(event.data))
|
|
516
|
-
return token
|
|
517
|
-
},
|
|
518
521
|
authenticate: async (context, event) => {
|
|
519
522
|
const data = { ...context.loginData, reCaptchaToken: context.reCaptchaToken }
|
|
520
523
|
const { token } = await request.send(auth.login(data))
|
|
521
524
|
return token
|
|
522
525
|
},
|
|
523
|
-
authenticateGuest: async (context, event) => {
|
|
524
|
-
const { token } = await request.send(auth.guestLogin())
|
|
525
|
-
return token
|
|
526
|
-
},
|
|
527
526
|
logout: async (context, event) => {
|
|
528
527
|
return await request.send(auth.logout())
|
|
529
528
|
},
|
|
@@ -532,16 +531,16 @@ export default function (request) {
|
|
|
532
531
|
},
|
|
533
532
|
checkDeviceToken: async (context, event) => {
|
|
534
533
|
const deviceTokenEnable = context.siteConfig?.dtVerify
|
|
535
|
-
if (deviceTokenEnable) {
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
}
|
|
534
|
+
if (!deviceTokenEnable) return { dt: null }
|
|
535
|
+
const { exist, dt: boundDt } = await request.send(user.checkDt())
|
|
536
|
+
if (exist) return { dt: boundDt }
|
|
537
|
+
const dt = await request.config.getDt?.()
|
|
538
|
+
// 確定有dt再取得updateDt
|
|
539
|
+
if (dt) {
|
|
540
|
+
await request.send(user.updateDt({ dt }))
|
|
541
|
+
return { dt }
|
|
544
542
|
}
|
|
543
|
+
return { dt: null }
|
|
545
544
|
},
|
|
546
545
|
fetchSiteConfig: async (context, event) => {
|
|
547
546
|
const { config } = await request.send(common.getConfig({ appSecret }))
|
|
@@ -6,7 +6,6 @@ export default function (request) {
|
|
|
6
6
|
return createMachine(
|
|
7
7
|
{
|
|
8
8
|
id: 'auth_otp',
|
|
9
|
-
predictableActionArguments: true,
|
|
10
9
|
initial: 'idle',
|
|
11
10
|
context: {
|
|
12
11
|
strategy: null,
|
|
@@ -130,9 +129,6 @@ export default function (request) {
|
|
|
130
129
|
RESET_OTP: {
|
|
131
130
|
target: 'reset',
|
|
132
131
|
},
|
|
133
|
-
RESEND_PHONE: {
|
|
134
|
-
target: '#auth_otp.notVerified.phone',
|
|
135
|
-
},
|
|
136
132
|
},
|
|
137
133
|
},
|
|
138
134
|
acknowledging: {
|
|
@@ -218,18 +214,25 @@ export default function (request) {
|
|
|
218
214
|
},
|
|
219
215
|
guards: {
|
|
220
216
|
isVerified: (context, event) => {
|
|
221
|
-
|
|
217
|
+
const { strategy, userInfo } = context
|
|
218
|
+
if (strategy === 'phone') return !!userInfo?.phone_verification_status
|
|
219
|
+
if (strategy === 'email') return !!userInfo?.email_verification_status
|
|
220
|
+
return false
|
|
222
221
|
},
|
|
223
222
|
isNotVerified: (context, event) => {
|
|
224
|
-
|
|
223
|
+
const { strategy, userInfo } = context
|
|
224
|
+
if (!userInfo) return false
|
|
225
|
+
if (strategy === 'phone') return !userInfo.phone_verification_status
|
|
226
|
+
if (strategy === 'email') return !userInfo.email_verification_status
|
|
227
|
+
return false
|
|
225
228
|
},
|
|
226
229
|
isPhoneNotVerified: (context, event) => {
|
|
227
230
|
const { strategy, userInfo } = context
|
|
228
|
-
return strategy === 'phone' && userInfo && userInfo.
|
|
231
|
+
return strategy === 'phone' && !!userInfo && !userInfo.phone_verification_status && !userInfo.phone
|
|
229
232
|
},
|
|
230
233
|
isEmailNotVerified: (context, event) => {
|
|
231
234
|
const { strategy, userInfo } = context
|
|
232
|
-
return strategy === 'email' && userInfo && userInfo.
|
|
235
|
+
return strategy === 'email' && !!userInfo && !userInfo.email_verification_status && !userInfo.email
|
|
233
236
|
},
|
|
234
237
|
hasNoPhone: (context, event) => {
|
|
235
238
|
const { error } = context
|
|
@@ -7,7 +7,6 @@ export default function (request) {
|
|
|
7
7
|
return createMachine(
|
|
8
8
|
{
|
|
9
9
|
id: 'bank_binding',
|
|
10
|
-
predictableActionArguments: true,
|
|
11
10
|
initial: 'fetching',
|
|
12
11
|
context: {
|
|
13
12
|
hasAnyAccount: false,
|
|
@@ -232,7 +231,7 @@ export default function (request) {
|
|
|
232
231
|
fetchInitData: async (context, event) => {
|
|
233
232
|
const [paymentList, paymentInfo] = await Promise.all([
|
|
234
233
|
request.send(payment.getBindingPaymentList({ appSecret })),
|
|
235
|
-
request.send(payment.getPaymentInfo()),
|
|
234
|
+
// request.send(payment.getPaymentInfo()),
|
|
236
235
|
])
|
|
237
236
|
return { paymentList, paymentInfo }
|
|
238
237
|
},
|
|
@@ -259,7 +258,7 @@ export default function (request) {
|
|
|
259
258
|
ifscCode,
|
|
260
259
|
bankCode: bank?.bankCode || '',
|
|
261
260
|
cryptoCurrency: crypto?.symbol || '',
|
|
262
|
-
cryptoNetwork: network?.
|
|
261
|
+
cryptoNetwork: network?.networkCode,
|
|
263
262
|
cryptoAddress: cryptoAddress,
|
|
264
263
|
walletCode: walletCode?.bankCode || '',
|
|
265
264
|
branch: branch === 'BLANK' ? '' : branch, // 'BLANK'會置換成空值
|
package/src/machine/common.js
CHANGED
|
@@ -3,13 +3,13 @@ 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 { readParam, writeParam, AC_KEYS, FC_KEYS } from '../util/paramStore.js'
|
|
6
7
|
|
|
7
8
|
export default function (request) {
|
|
8
|
-
const { appSecret,
|
|
9
|
+
const { appSecret, sentry } = request.config
|
|
9
10
|
return createMachine(
|
|
10
11
|
{
|
|
11
12
|
id: 'common',
|
|
12
|
-
predictableActionArguments: true,
|
|
13
13
|
type: 'parallel',
|
|
14
14
|
context: {
|
|
15
15
|
tick: 2000,
|
|
@@ -34,10 +34,6 @@ export default function (request) {
|
|
|
34
34
|
broadcastList: null,
|
|
35
35
|
mailBoxInfo: null,
|
|
36
36
|
promotions: [],
|
|
37
|
-
normalBroadcast: null,
|
|
38
|
-
sentNormalBroadcastList: [],
|
|
39
|
-
channel: null,
|
|
40
|
-
subchannel: null,
|
|
41
37
|
affiliateCode: null,
|
|
42
38
|
defaultAffiliateCode: null,
|
|
43
39
|
friendCode: null,
|
|
@@ -123,6 +119,9 @@ export default function (request) {
|
|
|
123
119
|
},
|
|
124
120
|
},
|
|
125
121
|
on: {
|
|
122
|
+
REFRESH_FEEDS: {
|
|
123
|
+
target: '.updating',
|
|
124
|
+
},
|
|
126
125
|
ENTER_GAME_PAUSE: {
|
|
127
126
|
target: '.idle',
|
|
128
127
|
actions: 'resetByEnterGame',
|
|
@@ -158,39 +157,6 @@ export default function (request) {
|
|
|
158
157
|
},
|
|
159
158
|
},
|
|
160
159
|
},
|
|
161
|
-
broadcast: {
|
|
162
|
-
initial: 'idle',
|
|
163
|
-
states: {
|
|
164
|
-
idle: {
|
|
165
|
-
on: {
|
|
166
|
-
START_BROADCAST: {
|
|
167
|
-
target: 'picking',
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
picking: {
|
|
172
|
-
after: {
|
|
173
|
-
5000: {
|
|
174
|
-
target: 'display',
|
|
175
|
-
actions: 'setBroadcast',
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
display: {
|
|
180
|
-
after: {
|
|
181
|
-
5000: {
|
|
182
|
-
target: 'picking',
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
},
|
|
187
|
-
on: {
|
|
188
|
-
RESET_BROADCAST: {
|
|
189
|
-
target: '.idle',
|
|
190
|
-
actions: 'resetBroadcast',
|
|
191
|
-
},
|
|
192
|
-
},
|
|
193
|
-
},
|
|
194
160
|
},
|
|
195
161
|
},
|
|
196
162
|
{
|
|
@@ -276,40 +242,17 @@ export default function (request) {
|
|
|
276
242
|
kpix,
|
|
277
243
|
}
|
|
278
244
|
}),
|
|
279
|
-
setAgent: assign((
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
} else {
|
|
284
|
-
let urlParams = new URLSearchParams(window.location.search)
|
|
285
|
-
const channel = urlParams.get('channel') || storage.get('channel') || defaultChannel || 'official'
|
|
286
|
-
const subchannel = urlParams.get('subchannel') || storage.get('subchannel') || defaultSubchannel || 'pwa'
|
|
287
|
-
const affiliateCode = urlParams.get('ac') || urlParams.get('referralCode') || storage.get('ac') || storage.get('referralCode')
|
|
288
|
-
const friendCode = urlParams.get('fc') || urlParams.get('affiliate') || storage.get('fc') || storage.get('affiliate')
|
|
245
|
+
setAgent: assign(() => {
|
|
246
|
+
const urlParams = new URLSearchParams(window.location.search)
|
|
247
|
+
const ac = readParam(urlParams, AC_KEYS)
|
|
248
|
+
const fc = readParam(urlParams, FC_KEYS)
|
|
289
249
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
maxAge: 60 * 60 * 24 * 7,
|
|
293
|
-
})
|
|
294
|
-
storage.set('subchannel', subchannel, {
|
|
295
|
-
path: '/',
|
|
296
|
-
maxAge: 60 * 60 * 24 * 7,
|
|
297
|
-
})
|
|
298
|
-
storage.set('ac', affiliateCode, {
|
|
299
|
-
path: '/',
|
|
300
|
-
maxAge: 60 * 60 * 24 * 7,
|
|
301
|
-
})
|
|
302
|
-
storage.set('fc', friendCode, {
|
|
303
|
-
path: '/',
|
|
304
|
-
maxAge: 60 * 60 * 24 * 7,
|
|
305
|
-
})
|
|
250
|
+
writeParam('ac', ac.value, { sentry })
|
|
251
|
+
writeParam('fc', fc.value, { sentry })
|
|
306
252
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
affiliateCode,
|
|
311
|
-
friendCode,
|
|
312
|
-
}
|
|
253
|
+
return {
|
|
254
|
+
affiliateCode: ac.value,
|
|
255
|
+
friendCode: fc.value,
|
|
313
256
|
}
|
|
314
257
|
}),
|
|
315
258
|
clearAnnouncements: assign((context, event) => {
|
|
@@ -328,47 +271,6 @@ export default function (request) {
|
|
|
328
271
|
}
|
|
329
272
|
return { broadcastList, mailBoxInfo }
|
|
330
273
|
}),
|
|
331
|
-
setBroadcast: assign((context, event) => {
|
|
332
|
-
const { broadcastList, sentNormalBroadcastList, normalBroadcast } = context
|
|
333
|
-
const broadcastQueue = broadcastList?.broadcasts || []
|
|
334
|
-
const normalQueue = broadcastQueue.filter((broadcast) => broadcast.type === '0')
|
|
335
|
-
const normalQueueIdSet = new Set(normalQueue.map((broadcast) => broadcast.broadcast_id))
|
|
336
|
-
const sentNormalList = []
|
|
337
|
-
const seenSentIds = new Set()
|
|
338
|
-
for (let i = 0; i < sentNormalBroadcastList.length; i++) {
|
|
339
|
-
const item = sentNormalBroadcastList[i]
|
|
340
|
-
const broadcastId = item?.broadcast_id
|
|
341
|
-
if (!normalQueueIdSet.has(broadcastId) || seenSentIds.has(broadcastId)) {
|
|
342
|
-
continue
|
|
343
|
-
}
|
|
344
|
-
seenSentIds.add(broadcastId)
|
|
345
|
-
sentNormalList.push(item)
|
|
346
|
-
}
|
|
347
|
-
const currentBroadcastId = normalBroadcast?.broadcast_id
|
|
348
|
-
if (currentBroadcastId != null && normalQueueIdSet.has(currentBroadcastId) && !seenSentIds.has(currentBroadcastId)) {
|
|
349
|
-
seenSentIds.add(currentBroadcastId)
|
|
350
|
-
sentNormalList.push(normalBroadcast)
|
|
351
|
-
}
|
|
352
|
-
const sentIds = seenSentIds
|
|
353
|
-
let nextNormalBroadcast
|
|
354
|
-
for (let i = 0; i < normalQueue.length; i++) {
|
|
355
|
-
const broadcast = normalQueue[i]
|
|
356
|
-
if (!sentIds.has(broadcast.broadcast_id)) {
|
|
357
|
-
nextNormalBroadcast = broadcast
|
|
358
|
-
break
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
return {
|
|
362
|
-
normalBroadcast: nextNormalBroadcast,
|
|
363
|
-
sentNormalBroadcastList: sentNormalList,
|
|
364
|
-
}
|
|
365
|
-
}),
|
|
366
|
-
resetBroadcast: assign((context, event) => {
|
|
367
|
-
return {
|
|
368
|
-
normalBroadcast: null,
|
|
369
|
-
sentNormalBroadcastList: [],
|
|
370
|
-
}
|
|
371
|
-
}),
|
|
372
274
|
resetByEnterGame: assign((context, event) => {
|
|
373
275
|
return {
|
|
374
276
|
isPlaying: true,
|