@jetthai/cuora 1.1.488-dev.1 → 1.2.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/.husky/pre-commit +3 -1
- package/.prettierignore +1 -2
- package/CHANGELOG.md +0 -746
- package/README.md +15 -299
- package/package.json +3 -6
- package/resetGitBranch.sh +101 -0
- package/src/api/activity.js +39 -24
- package/src/api/auth.js +35 -4
- package/src/api/common.js +1 -8
- package/src/api/game.js +10 -0
- package/src/api/index.js +1 -3
- package/src/api/payment.js +55 -18
- package/src/api/user.js +16 -11
- package/src/index.js +2 -2
- package/src/lib/fingerprint_v3_11_12.js +11433 -0
- package/src/machine/activity/activity.js +209 -0
- package/src/machine/activity/activity_cash.js +18 -71
- package/src/machine/activity/diamond_shop_activity_cash.js +1 -0
- package/src/machine/activity/diamond_shop_activity_fc.js +196 -0
- package/src/machine/activity/diamond_shop_activity_vn.js +178 -0
- package/src/machine/activity/fafafa_activity.js +10 -0
- package/src/machine/activity/index.js +12 -0
- package/src/machine/activity/invite_friends_activity.js +114 -0
- package/src/machine/activity/mini_game_activity.js +68 -0
- package/src/machine/activity/return_bonus_activity.js +153 -0
- package/src/machine/activity/roulette_activity_v2.js +0 -5
- package/src/machine/auth.js +140 -192
- package/src/machine/auth_otp_v2.js +177 -0
- package/src/machine/auth_otp_v3.js +32 -111
- package/src/machine/bank_binding.js +2 -2
- package/src/machine/bank_binding_amb.js +145 -0
- package/src/machine/bonus.js +75 -0
- package/src/machine/common.js +91 -27
- package/src/machine/deposit/amb.js +92 -0
- package/src/machine/deposit/crypto_bank.js +325 -0
- package/src/machine/deposit/crypto_bank_cash.js +8 -19
- package/src/machine/deposit/crypto_qrcode.js +148 -0
- package/src/machine/deposit/crypto_qrcode_cash.js +41 -26
- package/src/machine/deposit/crypto_way.js +247 -0
- package/src/machine/deposit/crypto_way_cash.js +32 -52
- package/src/machine/deposit/deposit_fc.js +271 -0
- package/src/machine/deposit/direct.js +310 -0
- package/src/machine/deposit/direct_cash.js +9 -8
- package/src/machine/deposit/float.js +374 -0
- package/src/machine/deposit/index.js +28 -0
- package/src/machine/deposit/krway.js +151 -0
- package/src/machine/deposit/loadcard_cash.js +31 -14
- package/src/machine/deposit/loadcard_vn.js +351 -0
- package/src/machine/deposit/manual_cash.js +10 -8
- package/src/machine/deposit/manual_vn.js +458 -0
- package/src/machine/deposit/qrcode_cash.js +30 -14
- package/src/machine/deposit/qrcode_v2.js +338 -0
- package/src/machine/deposit/usdt.js +144 -0
- package/src/machine/deposit/virtual_bank_cash.js +2 -5
- package/src/machine/deposit/virtual_bank_vn.js +269 -0
- package/src/machine/deposit/vpay.js +367 -0
- package/src/machine/error.js +0 -7
- package/src/machine/game_hot_new.js +79 -0
- package/src/machine/game_info.js +12 -5
- package/src/machine/game_replay.js +46 -0
- package/src/machine/game_search_v2.js +401 -0
- package/src/machine/game_v2_1.js +88 -58
- package/src/machine/honor_board.js +132 -0
- package/src/machine/honor_board_cash.js +18 -15
- package/src/machine/inbox.js +12 -0
- package/src/machine/index.js +32 -0
- package/src/machine/leaderboard.js +11 -8
- package/src/machine/merge.js +57 -0
- package/src/machine/payment_data.js +86 -0
- package/src/machine/promotions.js +170 -0
- package/src/machine/ranking.js +25 -43
- package/src/machine/reward.js +255 -0
- package/src/machine/reward_cash.js +41 -2
- package/src/machine/reward_fc.js +98 -0
- package/src/machine/roulette_v2.js +25 -20
- package/src/machine/side.js +154 -0
- package/src/machine/side_cash.js +2 -3
- package/src/machine/side_v2.js +209 -0
- package/src/machine/user_reset_password.js +15 -4
- package/src/machine/user_sign_up.js +60 -49
- package/src/machine/vip_table.js +57 -0
- package/src/machine/websocket.js +325 -378
- package/src/machine/welcome.js +110 -0
- package/src/machine/withdraw/index.js +6 -0
- package/src/machine/withdraw/withdraw_crypto_cash.js +327 -0
- package/src/machine/withdraw/withdraw_krway.js +222 -0
- package/src/machine/withdraw/withdraw_manual.js +533 -0
- package/src/machine/withdraw/withdraw_manual_cash.js +43 -74
- package/src/request/config.js +0 -2
- package/src/request/request.js +64 -231
- package/src/util/constant.js +2 -12
- package/src/util/deviceToken.js +59 -0
- package/src/util/index.js +4 -2
- package/src/util/math.js +4 -0
- package/.claude/commands/sync-ai-prompts.md +0 -180
- package/.claude/settings.local.json +0 -25
- package/.github/copilot-instructions.md +0 -459
- package/.husky/post-checkout +0 -32
- package/.husky/pre-push +0 -36
- package/AGENTS.md +0 -459
- package/AI_PROMPT_SOURCE.md +0 -457
- package/CLAUDE.md +0 -459
- package/GEMINI.md +0 -459
- package/docs/kibana/crypto-way-deposit-amount-bug-analysis.md +0 -1003
- package/docs/kibana/play-providerId-error.md +0 -202
- package/docs/kibana/play-selectedWalletType.md +0 -1
- package/docs/kibana/play-selectedWalletType_2.md +0 -1
- package/docs/kibana/play-selectedWalletType_analysis.md +0 -565
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/branch-transfer.md +0 -14
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/cash-module-preparation.json +0 -40
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/cash-module-verification.md +0 -41
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/implementation-ledger.md +0 -87
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/module-report.md +0 -73
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/plan.md +0 -309
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/test-cases.md +0 -245
- package/docs/my-claude/feat-sharon-JT-1791180540-onesignal/transfer.md +0 -9
- package/e2e/feature-map.md +0 -19
- package/prepare-for-pr/JT-1776243420.md +0 -85
- package/prepare-for-pr/TI-16026/STATE.md +0 -18
- package/prepare-for-pr/TI-16026/after-prepare-authorization.md +0 -3
- package/prepare-for-pr/TI-16026/analysis.md +0 -38
- package/prepare-for-pr/TI-16026/answer-analyze-01.md +0 -1
- package/prepare-for-pr/TI-16026/answer-commit-01.md +0 -2
- package/prepare-for-pr/TI-16026/answer-commit-02.md +0 -1
- package/prepare-for-pr/TI-16026/bundle.json +0 -18
- package/prepare-for-pr/TI-16026/checklist.md +0 -196
- package/prepare-for-pr/TI-16026/checklist.unit-test-original.md +0 -39
- package/prepare-for-pr/TI-16026/claude-after-model +0 -1
- package/prepare-for-pr/TI-16026/claude-commit-session +0 -1
- package/prepare-for-pr/TI-16026/claude-harvest-session +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/01-analyze.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/01-analyze.out +0 -2
- package/prepare-for-pr/TI-16026/claude-hops/02-analyze.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/02-analyze.out +0 -4
- package/prepare-for-pr/TI-16026/claude-hops/03-dev.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/03-dev.out +0 -4
- package/prepare-for-pr/TI-16026/claude-hops/04-dev.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/04-dev.out +0 -4
- package/prepare-for-pr/TI-16026/claude-hops/05-dev.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/05-dev.out +0 -3
- package/prepare-for-pr/TI-16026/claude-hops/06-after.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/06-after.out +0 -2
- package/prepare-for-pr/TI-16026/claude-hops/07-commit.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/07-commit.out +0 -2
- package/prepare-for-pr/TI-16026/claude-hops/08-commit.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/08-commit.out +0 -2
- package/prepare-for-pr/TI-16026/claude-hops/09-commit.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/09-commit.out +0 -8
- package/prepare-for-pr/TI-16026/claude-hops/10-harvest.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/10-harvest.out +0 -3
- package/prepare-for-pr/TI-16026/claude-hops/11-harvest.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/11-harvest.out +0 -3
- package/prepare-for-pr/TI-16026/commit-note.md +0 -5
- package/prepare-for-pr/TI-16026/evidence-index.json +0 -215
- package/prepare-for-pr/TI-16026/feature-map.before.md +0 -61
- package/prepare-for-pr/TI-16026/harvest-redaction.json +0 -34
- package/prepare-for-pr/TI-16026/harvest-redaction.out +0 -37
- package/prepare-for-pr/TI-16026/harvest.md +0 -46
- package/prepare-for-pr/TI-16026/lessons.md +0 -5
- package/prepare-for-pr/TI-16026/note-harvest-redaction.md +0 -1
- package/prepare-for-pr/TI-16026/open-questions.md +0 -6
- package/prepare-for-pr/TI-16026/publish.md +0 -32
- package/prepare-for-pr/TI-16026/review-convergence-response.md +0 -3
- package/prepare-for-pr/TI-16026/review-input/scope.md +0 -18
- package/prepare-for-pr/TI-16026/review-log.md +0 -57
- package/prepare-for-pr/TI-16026/review-notes.md +0 -97
- package/prepare-for-pr/TI-16026/review-response-r1.md +0 -7
- package/prepare-for-pr/TI-16026/self-test-report.md +0 -67
- package/prepare-for-pr/TI-16026/spec-proposal.md +0 -34
- package/prepare-for-pr/TI-16026/spec-snapshot.md +0 -291
- package/prepare-for-pr/TI-16026/state-log.md +0 -57
- package/prepare-for-pr/TI-16026/user-messages/01.md +0 -12
- package/prepare-for-pr/TI-16026/user-messages/02.md +0 -20
- package/prepare-for-pr/TI-16026/user-messages/03.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/04.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/05.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/06.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/07.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/08.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/09.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/10.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/11.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/12.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/13.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/14.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/15.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/16.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/17.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/18.md +0 -10
- package/prepare-for-pr/TI-16026/user-messages/19.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/20.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/21.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/22.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/23.md +0 -8
- package/prepare-for-pr/TI-16026/user-messages/24.md +0 -24
- package/prepare-for-pr/TI-16026/user-question.md +0 -24
- package/prepare-for-pr/TI-16026/verify/metrics-check.json +0 -13
- package/prepare-for-pr/TI-16026/verify/redaction.json +0 -38
- package/prepare-for-pr/TI-16026/verify/row-closure.json +0 -45
- package/prepare-for-pr/TI-16026/verify/s04-ws-capture.md +0 -23
- package/prepare-for-pr/TI-16026/verify-after.md +0 -23
- package/prepare-for-pr/TI-16026/verify.json +0 -80
- package/prepare-for-pr/TI-16026.md +0 -408
- package/scripts/auto-version.js +0 -69
- package/scripts/auto-version.sh +0 -33
- package/scripts/branch-auto-npm-publish.js +0 -36
- package/scripts/check-version.sh +0 -36
- package/scripts/clean-tags.sh +0 -84
- package/src/api/account.js +0 -7
- package/src/api/otp.js +0 -5
- package/src/util/amount.js +0 -8
- package/src/util/err998SentryExtra.js +0 -26
- package/src/util/paramStore.js +0 -139
- package/src/util/socketPolicy.js +0 -57
- package/src/util/tokenStore.js +0 -44
- package/test/auth_otp_v3.test.js +0 -323
- package/test/auth_self_timeout.test.js +0 -171
- package/test/request_self.test.js +0 -288
- package/test/withdraw_manual_cash.test.js +0 -149
- package/tests/session.test.mjs +0 -177
- package/tests/websocket.test.mjs +0 -779
package/src/machine/auth.js
CHANGED
|
@@ -3,23 +3,18 @@ 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
|
-
import { readParamFromLocation, writeParam, normalize, AC_KEYS, FC_KEYS } from '../util/paramStore.js'
|
|
9
9
|
|
|
10
10
|
export default function (request) {
|
|
11
|
-
const { appSecret, sentry } = request.config
|
|
11
|
+
const { appSecret, clientId, fpToken, sentry, defaultChannel, defaultSubchannel } = request.config
|
|
12
|
+
const tokenKey = `cuora_${clientId}`
|
|
13
|
+
const userKey = `cuora_tempuser`
|
|
12
14
|
const phoneCountryCode = 'phone_countrycode'
|
|
13
15
|
const accountPhoneKey = 'account_phone'
|
|
14
16
|
const accountEmailKey = 'account_email'
|
|
15
17
|
const accountUsernameKey = 'account_username'
|
|
16
|
-
// loginMethods 的鍵 → setAccount 寫入的 storage key。
|
|
17
|
-
// LOGIN_ID 寫的是 accountUsernameKey,在 loginMethods 卻算 'local',此對照無法由 key 名反推。
|
|
18
|
-
const rememberedAccountKeys = [
|
|
19
|
-
['local', accountUsernameKey],
|
|
20
|
-
['phone', accountPhoneKey],
|
|
21
|
-
['email', accountEmailKey],
|
|
22
|
-
]
|
|
23
18
|
|
|
24
19
|
return createMachine(
|
|
25
20
|
{
|
|
@@ -45,7 +40,6 @@ export default function (request) {
|
|
|
45
40
|
redirectURL: null,
|
|
46
41
|
reCaptchaToken: null,
|
|
47
42
|
fc: null,
|
|
48
|
-
dt: null,
|
|
49
43
|
},
|
|
50
44
|
states: {
|
|
51
45
|
fetchingConfig: {
|
|
@@ -53,7 +47,7 @@ export default function (request) {
|
|
|
53
47
|
src: 'fetchSiteConfig',
|
|
54
48
|
onDone: {
|
|
55
49
|
target: 'idle',
|
|
56
|
-
actions:
|
|
50
|
+
actions: 'setSiteConfig',
|
|
57
51
|
},
|
|
58
52
|
onError: {
|
|
59
53
|
target: 'idle',
|
|
@@ -77,101 +71,40 @@ export default function (request) {
|
|
|
77
71
|
},
|
|
78
72
|
},
|
|
79
73
|
},
|
|
80
|
-
|
|
74
|
+
authenticationGuest: {
|
|
81
75
|
invoke: {
|
|
82
|
-
src: '
|
|
76
|
+
src: 'authenticateGuest',
|
|
83
77
|
onDone: {
|
|
84
|
-
target: '
|
|
85
|
-
actions:
|
|
78
|
+
target: 'authenticated',
|
|
79
|
+
actions: 'setToken',
|
|
80
|
+
},
|
|
81
|
+
onError: {
|
|
82
|
+
target: 'idle',
|
|
83
|
+
actions: 'removeToken',
|
|
86
84
|
},
|
|
87
|
-
onError: [{ target: 'userInfoRetrying', cond: 'isSelfTimeout' }, { target: 'leaving' }],
|
|
88
85
|
},
|
|
89
86
|
},
|
|
90
|
-
|
|
91
|
-
// 下游以 state.matches('authenticated') 觸發一次性副作用(存帳密、註冊轉換追蹤),重進會重複觸發
|
|
92
|
-
userInfoRetrying: {
|
|
87
|
+
authenticationApp: {
|
|
93
88
|
invoke: {
|
|
94
|
-
src: '
|
|
89
|
+
src: 'authenticateApp',
|
|
95
90
|
onDone: {
|
|
96
|
-
target: '
|
|
97
|
-
actions: ['
|
|
98
|
-
},
|
|
99
|
-
onError: [{ target: 'userInfoRetrying', cond: 'isSelfTimeout' }, { target: 'leaving' }],
|
|
100
|
-
},
|
|
101
|
-
on: {
|
|
102
|
-
LOGOUT: {
|
|
103
|
-
target: 'leaving',
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
otpChecking: {
|
|
108
|
-
initial: 'pending',
|
|
109
|
-
states: {
|
|
110
|
-
pending: {
|
|
111
|
-
after: {
|
|
112
|
-
TIMEOUT: {
|
|
113
|
-
target: 'fetching',
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
fetching: {
|
|
118
|
-
invoke: {
|
|
119
|
-
src: 'fetchUserInfo',
|
|
120
|
-
onDone: {
|
|
121
|
-
target: 'pending',
|
|
122
|
-
actions: ['setUserInfo', 'extendToken'],
|
|
123
|
-
},
|
|
124
|
-
onError: {
|
|
125
|
-
target: 'pending',
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
on: {
|
|
131
|
-
OTP_VERIFIED: {
|
|
132
|
-
target: 'bindBankChecking',
|
|
133
|
-
},
|
|
134
|
-
OTP_SKIP: {
|
|
135
|
-
target: 'bindBankChecking',
|
|
91
|
+
target: 'authenticated',
|
|
92
|
+
actions: ['setToken'],
|
|
136
93
|
},
|
|
137
|
-
|
|
138
|
-
target: '
|
|
94
|
+
onError: {
|
|
95
|
+
target: 'idle',
|
|
96
|
+
actions: 'removeToken',
|
|
139
97
|
},
|
|
140
98
|
},
|
|
141
99
|
},
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
states: {
|
|
147
|
-
pending: {
|
|
148
|
-
after: {
|
|
149
|
-
TIMEOUT: {
|
|
150
|
-
target: 'fetching',
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
fetching: {
|
|
155
|
-
invoke: {
|
|
156
|
-
src: 'fetchUserInfo',
|
|
157
|
-
onDone: {
|
|
158
|
-
target: 'pending',
|
|
159
|
-
actions: ['setUserInfo', 'extendToken'],
|
|
160
|
-
},
|
|
161
|
-
onError: {
|
|
162
|
-
target: 'pending',
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
on: {
|
|
168
|
-
BIND_BANK_DONE: {
|
|
169
|
-
target: 'loginSuccess',
|
|
170
|
-
},
|
|
171
|
-
BIND_BANK_SKIP: {
|
|
100
|
+
authenticated: {
|
|
101
|
+
invoke: {
|
|
102
|
+
src: 'fetchUserInfo',
|
|
103
|
+
onDone: {
|
|
172
104
|
target: 'loginSuccess',
|
|
105
|
+
actions: ['setUserInfo', 'extendToken'],
|
|
173
106
|
},
|
|
174
|
-
|
|
107
|
+
onError: {
|
|
175
108
|
target: 'leaving',
|
|
176
109
|
},
|
|
177
110
|
},
|
|
@@ -190,8 +123,9 @@ export default function (request) {
|
|
|
190
123
|
target: 'inline',
|
|
191
124
|
actions: ['setUserInfo', 'extendToken'],
|
|
192
125
|
},
|
|
193
|
-
|
|
194
|
-
|
|
126
|
+
onError: {
|
|
127
|
+
target: 'leaving',
|
|
128
|
+
},
|
|
195
129
|
},
|
|
196
130
|
},
|
|
197
131
|
inline: {
|
|
@@ -207,12 +141,14 @@ export default function (request) {
|
|
|
207
141
|
},
|
|
208
142
|
fetching: {
|
|
209
143
|
invoke: {
|
|
210
|
-
src: '
|
|
144
|
+
src: 'fetchUserInfo',
|
|
211
145
|
onDone: {
|
|
212
146
|
target: 'pending',
|
|
213
147
|
actions: ['setUserInfo', 'extendToken'],
|
|
214
148
|
},
|
|
215
|
-
onError:
|
|
149
|
+
onError: {
|
|
150
|
+
target: '#auth.leaving',
|
|
151
|
+
},
|
|
216
152
|
},
|
|
217
153
|
},
|
|
218
154
|
},
|
|
@@ -228,12 +164,10 @@ export default function (request) {
|
|
|
228
164
|
initial: 'deviceTokenChecking',
|
|
229
165
|
states: {
|
|
230
166
|
deviceTokenChecking: {
|
|
231
|
-
entry: 'clearDeviceToken',
|
|
232
167
|
invoke: {
|
|
233
168
|
src: 'checkDeviceToken',
|
|
234
169
|
onDone: {
|
|
235
170
|
target: 'checkDeviceTokenDone',
|
|
236
|
-
actions: 'setDeviceToken',
|
|
237
171
|
},
|
|
238
172
|
onError: {
|
|
239
173
|
target: 'fetching',
|
|
@@ -247,17 +181,21 @@ export default function (request) {
|
|
|
247
181
|
target: 'pending',
|
|
248
182
|
actions: ['setUserInfo', 'extendToken'],
|
|
249
183
|
},
|
|
250
|
-
onError:
|
|
184
|
+
onError: {
|
|
185
|
+
target: '#auth.leaving',
|
|
186
|
+
},
|
|
251
187
|
},
|
|
252
188
|
},
|
|
253
189
|
fetching: {
|
|
254
190
|
invoke: {
|
|
255
|
-
src: '
|
|
191
|
+
src: 'fetchUserInfo',
|
|
256
192
|
onDone: {
|
|
257
193
|
target: 'pending',
|
|
258
194
|
actions: ['setUserInfo', 'extendToken'],
|
|
259
195
|
},
|
|
260
|
-
onError:
|
|
196
|
+
onError: {
|
|
197
|
+
target: '#auth.leaving',
|
|
198
|
+
},
|
|
261
199
|
},
|
|
262
200
|
},
|
|
263
201
|
pending: {
|
|
@@ -309,6 +247,9 @@ export default function (request) {
|
|
|
309
247
|
CLEAR: {
|
|
310
248
|
target: '.logout',
|
|
311
249
|
},
|
|
250
|
+
LOGIN_GUEST: {
|
|
251
|
+
target: '.authenticationGuest',
|
|
252
|
+
},
|
|
312
253
|
LOGIN_ID: {
|
|
313
254
|
target: '.authentication',
|
|
314
255
|
actions: ['setReCaptchaToken', 'setLoginId'],
|
|
@@ -321,9 +262,16 @@ export default function (request) {
|
|
|
321
262
|
target: '.authentication',
|
|
322
263
|
actions: ['setReCaptchaToken', 'setLoginEmail'],
|
|
323
264
|
},
|
|
265
|
+
LOGIN_LOCAL: {
|
|
266
|
+
target: '.authentication',
|
|
267
|
+
actions: 'setLoginLocal',
|
|
268
|
+
},
|
|
324
269
|
LOGIN_3PARTY: {
|
|
325
270
|
actions: 'redirectTo3Party',
|
|
326
271
|
},
|
|
272
|
+
LOGIN_APP: {
|
|
273
|
+
target: '.authenticationApp',
|
|
274
|
+
},
|
|
327
275
|
LOGIN_TELEGRAM: {
|
|
328
276
|
target: '.authentication',
|
|
329
277
|
actions: 'setLoginTelegram',
|
|
@@ -350,10 +298,6 @@ export default function (request) {
|
|
|
350
298
|
isNotInline: (context, event) => {
|
|
351
299
|
return !(context.userInfo?.rank >= 0)
|
|
352
300
|
},
|
|
353
|
-
// 只認請求層 15 秒逾時(request.js 的 isTimeout);一般 ERR_998 與驗證失敗維持原路由
|
|
354
|
-
isSelfTimeout: (context, event) => {
|
|
355
|
-
return event.data?.isTimeout === true
|
|
356
|
-
},
|
|
357
301
|
},
|
|
358
302
|
actions: {
|
|
359
303
|
setSiteConfig: assign((context, event) => {
|
|
@@ -362,19 +306,6 @@ export default function (request) {
|
|
|
362
306
|
siteConfig: { ...event.data, loginMethods: pickBy(loginMethods), registerMethods: pickBy(registerMethods) },
|
|
363
307
|
}
|
|
364
308
|
}),
|
|
365
|
-
// setAccount 寫入的帳號 TTL 是 31 天,且只互斥清除另外兩支 key,
|
|
366
|
-
// 後台關掉某種登入方式後殘值仍在,下游會把它回填進已改型別的輸入框(例如把 email 填進 phone-only 站台)。
|
|
367
|
-
// 非 assign action,故取得的是 setSiteConfig 套用後的 context。
|
|
368
|
-
pruneRememberedAccounts: (context) => {
|
|
369
|
-
// fetchSiteConfig 失敗會走 onError 不進到這裡;此處防的是回傳成功但 loginMethods 整包缺失,避免誤清全部記住的帳號。
|
|
370
|
-
const enabledMethods = context.siteConfig?.loginMethods
|
|
371
|
-
if (!enabledMethods || !Object.keys(enabledMethods).length) return
|
|
372
|
-
rememberedAccountKeys.forEach(([method, key]) => {
|
|
373
|
-
if (enabledMethods[method]) return
|
|
374
|
-
storage.remove(key)
|
|
375
|
-
if (method === 'phone') storage.remove(phoneCountryCode)
|
|
376
|
-
})
|
|
377
|
-
},
|
|
378
309
|
setReCaptchaToken: assign((context, event) => {
|
|
379
310
|
const { reCaptchaToken } = event.data
|
|
380
311
|
return {
|
|
@@ -413,36 +344,46 @@ export default function (request) {
|
|
|
413
344
|
},
|
|
414
345
|
}
|
|
415
346
|
}),
|
|
347
|
+
setLoginLocal: assign((context, event) => {
|
|
348
|
+
const { username, password } = event.data
|
|
349
|
+
storage.set(userKey, username, {
|
|
350
|
+
path: '/',
|
|
351
|
+
maxAge: 60 * 60 * 24,
|
|
352
|
+
})
|
|
353
|
+
return {
|
|
354
|
+
loginData: {
|
|
355
|
+
provider: 'local',
|
|
356
|
+
username,
|
|
357
|
+
password,
|
|
358
|
+
},
|
|
359
|
+
}
|
|
360
|
+
}),
|
|
416
361
|
setLoginTelegram: assign((context, event) => {
|
|
417
|
-
const { loginType, additionalUserInfo, isSignature
|
|
362
|
+
const { loginType, additionalUserInfo, isSignature } = event.data
|
|
418
363
|
return {
|
|
419
364
|
loginData: {
|
|
420
365
|
provider: 'telegram',
|
|
421
366
|
loginType,
|
|
422
367
|
additionalUserInfo,
|
|
423
368
|
isSignature,
|
|
424
|
-
idToken,
|
|
425
369
|
},
|
|
426
370
|
}
|
|
427
371
|
}),
|
|
428
372
|
fetchToken: assign((context, event) => {
|
|
373
|
+
const token = storage.get(tokenKey)
|
|
429
374
|
return {
|
|
430
|
-
token
|
|
375
|
+
token,
|
|
431
376
|
}
|
|
432
377
|
}),
|
|
433
378
|
setToken: assign((context, event) => {
|
|
434
|
-
|
|
379
|
+
storage.set(tokenKey, event.data, {
|
|
380
|
+
path: '/',
|
|
381
|
+
maxAge: 300,
|
|
382
|
+
})
|
|
435
383
|
return {
|
|
436
384
|
token: event.data,
|
|
437
385
|
}
|
|
438
386
|
}),
|
|
439
|
-
setDeviceToken: assign((context, event) => {
|
|
440
|
-
return {
|
|
441
|
-
dt: event.data?.dt ?? null,
|
|
442
|
-
}
|
|
443
|
-
}),
|
|
444
|
-
// checkDeviceToken 失敗走 onError 不會執行 setDeviceToken,先清空避免下游讀到前一個帳號的 dt
|
|
445
|
-
clearDeviceToken: assign({ dt: null }),
|
|
446
387
|
setAccount: assign((context, event) => {
|
|
447
388
|
if (context.loginData.username) {
|
|
448
389
|
storage.remove(accountEmailKey)
|
|
@@ -473,76 +414,79 @@ export default function (request) {
|
|
|
473
414
|
}
|
|
474
415
|
}),
|
|
475
416
|
removeToken: assign((context, event) => {
|
|
476
|
-
|
|
477
|
-
|
|
417
|
+
storage.remove(tokenKey, {
|
|
418
|
+
path: '/',
|
|
419
|
+
maxAge: 300,
|
|
420
|
+
})
|
|
421
|
+
return { token: null }
|
|
478
422
|
}),
|
|
479
423
|
extendToken: assign((context, event) => {
|
|
480
|
-
|
|
424
|
+
const token = storage.get(tokenKey)
|
|
425
|
+
storage.set(tokenKey, token, {
|
|
426
|
+
path: '/',
|
|
427
|
+
maxAge: 300,
|
|
428
|
+
})
|
|
429
|
+
return { token }
|
|
481
430
|
}),
|
|
482
431
|
redirectTo3Party: async (context, event) => {
|
|
483
|
-
const { provider, fc } = event.data
|
|
432
|
+
const { provider, channel, subchannel, fc } = event.data
|
|
484
433
|
const deviceTokenEnable = context.siteConfig?.dtVerify
|
|
485
434
|
|
|
486
|
-
const dt =
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
const affiliateCode = hasExplicitAc ? normalize(event.data.ac) : acRead.value
|
|
493
|
-
// 宿主可能傳進字面 'undefined',先 normalize 才不會蓋掉網址/儲存層的真值
|
|
494
|
-
const friendCode = normalize(fc) || readParamFromLocation(FC_KEYS).value
|
|
495
|
-
|
|
496
|
-
// 本段結尾以 window.location.href 離站,離站後 SPA 記憶體全丟;導頁前先落地雙寫
|
|
497
|
-
writeParam('ac', affiliateCode, { sentry })
|
|
498
|
-
writeParam('fc', friendCode, { sentry })
|
|
435
|
+
const dt = await getDeviceTokenWithRetry({
|
|
436
|
+
fpToken,
|
|
437
|
+
sentry,
|
|
438
|
+
hosts: request.hosts,
|
|
439
|
+
enable: deviceTokenEnable,
|
|
440
|
+
})
|
|
499
441
|
|
|
442
|
+
const affiliateCode = storage.get('ac')
|
|
500
443
|
const nickname = storage.get('nk')
|
|
501
|
-
const phone = storage.get('tp_phone')
|
|
502
|
-
const countryCode = storage.get('tp_countryCode')
|
|
503
|
-
const email = storage.get('tp_email')
|
|
504
|
-
const birthday = storage.get('tp_birthday')
|
|
505
444
|
const messages = {
|
|
506
445
|
url: window.location.href,
|
|
446
|
+
channelOrders: [
|
|
447
|
+
{ channel: storage.get('channel'), subchannel: storage.get('subchannel') },
|
|
448
|
+
{ channel: defaultChannel, subchannel: defaultSubchannel },
|
|
449
|
+
{ channel: channel, subchannel: subchannel },
|
|
450
|
+
],
|
|
507
451
|
affiliateCode,
|
|
508
|
-
acSource: hasExplicitAc ? 'event' : acRead.from,
|
|
509
452
|
nickname,
|
|
510
453
|
}
|
|
454
|
+
sentry?.captureMessage(JSON.stringify(messages))
|
|
511
455
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
phone,
|
|
521
|
-
countryCode,
|
|
522
|
-
email,
|
|
523
|
-
birthday,
|
|
524
|
-
dt,
|
|
525
|
-
platform: 'pwa',
|
|
526
|
-
fc: friendCode,
|
|
527
|
-
},
|
|
528
|
-
(value) => normalize(value) !== null
|
|
529
|
-
)
|
|
456
|
+
const referralObj = {}
|
|
457
|
+
if (![undefined, 'undefined', null, 'null'].includes(affiliateCode)) {
|
|
458
|
+
referralObj.ac = affiliateCode
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
if (![undefined, 'undefined', null, 'null'].includes(nickname)) {
|
|
462
|
+
referralObj.nick_name = nickname
|
|
463
|
+
}
|
|
530
464
|
|
|
531
|
-
storage.
|
|
532
|
-
storage.
|
|
533
|
-
storage.remove('tp_email')
|
|
534
|
-
// tp_birthday 不在此移除:client 於回站登入完成後以 /self 補交作為備援,由 client 消費後移除
|
|
465
|
+
referralObj.channel = storage.get('channel') || defaultChannel || channel
|
|
466
|
+
referralObj.subchannel = storage.get('subchannel') || defaultSubchannel || subchannel
|
|
535
467
|
|
|
536
|
-
|
|
468
|
+
// OZE、ZAZA 先使用 v2 測試 ,等待確認沒問題後再統一用 v2
|
|
469
|
+
// 但 ZALO 仍維持 v1
|
|
470
|
+
const fullURL =
|
|
471
|
+
['OZE', 'ZAZA'].includes(clientId) && provider !== 'zalo' ? request.config.fullURL.replace('/v1/', '/v2/') : request.config.fullURL
|
|
537
472
|
|
|
538
|
-
const redirectURL = urljoin(
|
|
473
|
+
const redirectURL = urljoin(
|
|
474
|
+
fullURL,
|
|
475
|
+
'login?' +
|
|
476
|
+
new URLSearchParams({
|
|
477
|
+
provider,
|
|
478
|
+
redirectURI: `${window.location.protocol}//${window.location.host}${context.base}`,
|
|
479
|
+
...referralObj,
|
|
480
|
+
dt,
|
|
481
|
+
platform: 'pwa',
|
|
482
|
+
fc,
|
|
483
|
+
}).toString()
|
|
484
|
+
)
|
|
539
485
|
|
|
540
486
|
window.location.href = redirectURL
|
|
541
487
|
},
|
|
542
488
|
setUserInfo: assign((context, event) => {
|
|
543
|
-
|
|
544
|
-
sentry?.setUser({ id: event.data.uid_site })
|
|
545
|
-
}
|
|
489
|
+
sentry?.setUser({ id: event.data.uid_site })
|
|
546
490
|
return {
|
|
547
491
|
userInfo: event.data,
|
|
548
492
|
}
|
|
@@ -554,33 +498,37 @@ export default function (request) {
|
|
|
554
498
|
}),
|
|
555
499
|
},
|
|
556
500
|
services: {
|
|
501
|
+
authenticateApp: async (context, event) => {
|
|
502
|
+
const { token } = await request.send(auth.loginApp(event.data))
|
|
503
|
+
return token
|
|
504
|
+
},
|
|
557
505
|
authenticate: async (context, event) => {
|
|
558
506
|
const data = { ...context.loginData, reCaptchaToken: context.reCaptchaToken }
|
|
559
507
|
const { token } = await request.send(auth.login(data))
|
|
560
508
|
return token
|
|
561
509
|
},
|
|
510
|
+
authenticateGuest: async (context, event) => {
|
|
511
|
+
const { token } = await request.send(auth.guestLogin())
|
|
512
|
+
return token
|
|
513
|
+
},
|
|
562
514
|
logout: async (context, event) => {
|
|
563
515
|
return await request.send(auth.logout())
|
|
564
516
|
},
|
|
565
517
|
fetchUserInfo: async (context, event) => {
|
|
566
518
|
return await request.send(user.getUserInfo())
|
|
567
519
|
},
|
|
568
|
-
// 例行輪詢的 /self 自成一類(channel),與各處單獨發的 /self 互不共用在途、互不影響
|
|
569
|
-
pollUserInfo: async (context, event) => {
|
|
570
|
-
return await request.send({ ...user.getUserInfo(), channel: 'polling' })
|
|
571
|
-
},
|
|
572
520
|
checkDeviceToken: async (context, event) => {
|
|
573
521
|
const deviceTokenEnable = context.siteConfig?.dtVerify
|
|
574
|
-
if (
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
522
|
+
if (deviceTokenEnable) {
|
|
523
|
+
const { exist } = await request.send(user.checkDt())
|
|
524
|
+
if (!exist) {
|
|
525
|
+
const dt = await getDeviceTokenWithRetry({ fpToken, sentry, hosts: request.hosts, enable: deviceTokenEnable })
|
|
526
|
+
// 確定有dt再取得updateDt
|
|
527
|
+
if (dt) {
|
|
528
|
+
await request.send(user.updateDt({ dt }))
|
|
529
|
+
}
|
|
530
|
+
}
|
|
582
531
|
}
|
|
583
|
-
return { dt: null }
|
|
584
532
|
},
|
|
585
533
|
fetchSiteConfig: async (context, event) => {
|
|
586
534
|
const { config } = await request.send(common.getConfig({ appSecret }))
|