@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
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import user from '../api/user.js'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
return createMachine(
|
|
6
|
+
{
|
|
7
|
+
id: 'auth_otp_v2',
|
|
8
|
+
initial: 'idle',
|
|
9
|
+
context: {
|
|
10
|
+
strategy: null,
|
|
11
|
+
requestId: null,
|
|
12
|
+
ttl: null,
|
|
13
|
+
target: {},
|
|
14
|
+
acknowledgeTtl: null,
|
|
15
|
+
newPassword: null,
|
|
16
|
+
},
|
|
17
|
+
states: {
|
|
18
|
+
idle: {
|
|
19
|
+
on: {
|
|
20
|
+
SET_OTP_INITIALIZATION: {
|
|
21
|
+
target: 'otp',
|
|
22
|
+
actions: 'setOtpResult',
|
|
23
|
+
},
|
|
24
|
+
SEND_OTP_EMAIL: {
|
|
25
|
+
target: 'otpFetching',
|
|
26
|
+
actions: 'setStrategyEmail',
|
|
27
|
+
},
|
|
28
|
+
SEND_OTP_PHONE: {
|
|
29
|
+
target: 'otpFetching',
|
|
30
|
+
actions: 'setStrategyPhone',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
otpFetching: {
|
|
35
|
+
invoke: {
|
|
36
|
+
src: 'sendOtp',
|
|
37
|
+
onDone: [
|
|
38
|
+
{
|
|
39
|
+
target: 'acknowledged',
|
|
40
|
+
cond: (context, event) => event.data.status === 'success-verified',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
target: 'otp',
|
|
44
|
+
actions: 'setOtpResult',
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
onError: {
|
|
48
|
+
target: 'idle',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
otp: {
|
|
53
|
+
after: {
|
|
54
|
+
1000: [
|
|
55
|
+
{
|
|
56
|
+
target: 'otp',
|
|
57
|
+
actions: 'decreaseTtl',
|
|
58
|
+
cond: (context) => context.ttl > 0,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
target: 'idle',
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
on: {
|
|
66
|
+
ACKNOWLEDGE: {
|
|
67
|
+
target: 'acknowledging',
|
|
68
|
+
},
|
|
69
|
+
BACK: {
|
|
70
|
+
target: 'idle',
|
|
71
|
+
},
|
|
72
|
+
RESET_OTP: {
|
|
73
|
+
target: 'otpResetting',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
otpResetting: {
|
|
78
|
+
invoke: {
|
|
79
|
+
src: 'resetOtp',
|
|
80
|
+
onDone: {
|
|
81
|
+
target: 'otp',
|
|
82
|
+
actions: 'setOtpResult',
|
|
83
|
+
},
|
|
84
|
+
onError: {
|
|
85
|
+
target: 'otp',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
acknowledging: {
|
|
90
|
+
invoke: {
|
|
91
|
+
src: 'acknowledge',
|
|
92
|
+
onDone: {
|
|
93
|
+
target: 'acknowledged',
|
|
94
|
+
actions: 'setAcknowledgeResult',
|
|
95
|
+
},
|
|
96
|
+
onError: [
|
|
97
|
+
{
|
|
98
|
+
target: 'idle',
|
|
99
|
+
cond: (context, event) => event.data.code === 'ERR_A108',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
target: 'otp',
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
acknowledged: {
|
|
108
|
+
// after: {
|
|
109
|
+
// 1000: [
|
|
110
|
+
// {
|
|
111
|
+
// target: 'acknowledged',
|
|
112
|
+
// actions: 'decreaseAcknowledgeTtl',
|
|
113
|
+
// cond: (context) => context.acknowledgeTtl > 0,
|
|
114
|
+
// },
|
|
115
|
+
// {
|
|
116
|
+
// target: 'idle',
|
|
117
|
+
// },
|
|
118
|
+
// ],
|
|
119
|
+
// },
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
actions: {
|
|
125
|
+
setStrategyPhone: assign((context, event) => {
|
|
126
|
+
return {
|
|
127
|
+
strategy: 'phone',
|
|
128
|
+
}
|
|
129
|
+
}),
|
|
130
|
+
setStrategyEmail: assign((context, event) => {
|
|
131
|
+
return {
|
|
132
|
+
strategy: 'email',
|
|
133
|
+
}
|
|
134
|
+
}),
|
|
135
|
+
setOtpResult: assign((context, event) => {
|
|
136
|
+
const { requestId, ttl, target } = event.data
|
|
137
|
+
return {
|
|
138
|
+
requestId,
|
|
139
|
+
ttl,
|
|
140
|
+
target,
|
|
141
|
+
}
|
|
142
|
+
}),
|
|
143
|
+
decreaseTtl: assign((context, event) => {
|
|
144
|
+
return {
|
|
145
|
+
ttl: Math.max(context.ttl - 1, 0),
|
|
146
|
+
}
|
|
147
|
+
}),
|
|
148
|
+
setAcknowledgeResult: assign((context, event) => {
|
|
149
|
+
const { requestId, ttl, target } = event.data
|
|
150
|
+
return {
|
|
151
|
+
acknowledgeTtl: ttl,
|
|
152
|
+
}
|
|
153
|
+
}),
|
|
154
|
+
decreaseAcknowledgeTtl: assign((context, event) => {
|
|
155
|
+
return {
|
|
156
|
+
acknowledgeTtl: Math.max(context.acknowledgeTtl - 1, 0),
|
|
157
|
+
}
|
|
158
|
+
}),
|
|
159
|
+
},
|
|
160
|
+
services: {
|
|
161
|
+
sendOtp: async (context, event) => {
|
|
162
|
+
const { strategy } = context
|
|
163
|
+
return await request.send(user.verifyV2Initiate({ strategy }))
|
|
164
|
+
},
|
|
165
|
+
resetOtp: async (context, event) => {
|
|
166
|
+
const { requestId, target } = context
|
|
167
|
+
return await request.send(user.otpReset({ requestId, target }))
|
|
168
|
+
},
|
|
169
|
+
acknowledge: async (context, event) => {
|
|
170
|
+
const { requestId, target } = context
|
|
171
|
+
const code = event.data
|
|
172
|
+
return await request.send(user.otpAcknowledge({ requestId, target, code }))
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
}
|
|
176
|
+
)
|
|
177
|
+
}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import user from '../api/user.js'
|
|
3
|
-
import
|
|
4
|
-
import { AUTO_VERIFY_MAX_USER_INFO_UPDATES, AUTO_VERIFY_WAIT_MS } from '../util/constant.js'
|
|
5
|
-
|
|
6
|
-
function isStrategyVerified(strategy, userInfo) {
|
|
7
|
-
if (strategy === 'phone') return !!(userInfo?.phone || userInfo?.tel) && !!userInfo?.phone_verification_status
|
|
8
|
-
if (strategy === 'email') return !!userInfo?.email && !!userInfo?.email_verification_status
|
|
9
|
-
return false
|
|
10
|
-
}
|
|
3
|
+
import auth from '../api/auth.js'
|
|
11
4
|
|
|
12
5
|
export default function (request) {
|
|
13
6
|
return createMachine(
|
|
@@ -25,7 +18,6 @@ export default function (request) {
|
|
|
25
18
|
requestId: null,
|
|
26
19
|
status: null,
|
|
27
20
|
ttl: 0,
|
|
28
|
-
autoVerifyUpdates: 0,
|
|
29
21
|
},
|
|
30
22
|
states: {
|
|
31
23
|
idle: {
|
|
@@ -56,44 +48,16 @@ export default function (request) {
|
|
|
56
48
|
{ target: 'notVerified', cond: 'isNotVerified' },
|
|
57
49
|
],
|
|
58
50
|
},
|
|
59
|
-
autoVerifying: {
|
|
60
|
-
invoke: {
|
|
61
|
-
src: 'fetchUserInfo',
|
|
62
|
-
onDone: {
|
|
63
|
-
target: 'checkingAutoVerification',
|
|
64
|
-
actions: 'setUserInfo',
|
|
65
|
-
},
|
|
66
|
-
onError: { target: 'fail' },
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
checkingAutoVerification: {
|
|
70
|
-
always: [{ target: 'verified', cond: 'isVerified' }, { target: 'autoVerifyWaiting' }],
|
|
71
|
-
},
|
|
72
|
-
// 後端寫入驗證狀態到 /self 反映之間有延遲(主動打的那次可能還是舊值),
|
|
73
|
-
// 改等下游轉送 auth 例行輪詢的 /self 結果,不另開輪詢以免重複打 /self
|
|
74
|
-
autoVerifyWaiting: {
|
|
75
|
-
entry: 'resetAutoVerifyUpdates',
|
|
76
|
-
after: {
|
|
77
|
-
AUTO_VERIFY_TIMEOUT: { target: 'fail' },
|
|
78
|
-
},
|
|
79
|
-
on: {
|
|
80
|
-
USER_INFO_UPDATED: [
|
|
81
|
-
{ target: 'verified', cond: 'isUpdatedUserInfoVerified', actions: 'setUserInfo' },
|
|
82
|
-
{ target: 'fail', cond: 'isLastAutoVerifyUpdate', actions: 'setUserInfo' },
|
|
83
|
-
{ actions: ['setUserInfo', 'countAutoVerifyUpdate'] },
|
|
84
|
-
],
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
51
|
notVerified: {
|
|
88
52
|
initial: 'checkingStatus',
|
|
89
53
|
states: {
|
|
90
54
|
checkingStatus: {
|
|
91
55
|
invoke: {
|
|
92
56
|
src: 'verify',
|
|
93
|
-
onDone:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
57
|
+
onDone: {
|
|
58
|
+
target: 'otp',
|
|
59
|
+
actions: 'setVerificationData',
|
|
60
|
+
},
|
|
97
61
|
onError: {
|
|
98
62
|
target: 'errorChecking',
|
|
99
63
|
actions: 'setError',
|
|
@@ -122,20 +86,20 @@ export default function (request) {
|
|
|
122
86
|
sendingPhone: {
|
|
123
87
|
invoke: {
|
|
124
88
|
src: 'sendPhone',
|
|
125
|
-
onDone:
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
89
|
+
onDone: {
|
|
90
|
+
target: 'otp',
|
|
91
|
+
actions: 'setVerificationData',
|
|
92
|
+
},
|
|
129
93
|
onError: { target: 'phone' },
|
|
130
94
|
},
|
|
131
95
|
},
|
|
132
96
|
sendingEmail: {
|
|
133
97
|
invoke: {
|
|
134
98
|
src: 'sendEmail',
|
|
135
|
-
onDone:
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
99
|
+
onDone: {
|
|
100
|
+
target: 'otp',
|
|
101
|
+
actions: 'setVerificationData',
|
|
102
|
+
},
|
|
139
103
|
onError: { target: 'email' },
|
|
140
104
|
},
|
|
141
105
|
},
|
|
@@ -165,6 +129,9 @@ export default function (request) {
|
|
|
165
129
|
RESET_OTP: {
|
|
166
130
|
target: 'reset',
|
|
167
131
|
},
|
|
132
|
+
RESEND_PHONE: {
|
|
133
|
+
target: '#auth_otp.notVerified.phone',
|
|
134
|
+
},
|
|
168
135
|
},
|
|
169
136
|
},
|
|
170
137
|
acknowledging: {
|
|
@@ -199,9 +166,6 @@ export default function (request) {
|
|
|
199
166
|
},
|
|
200
167
|
},
|
|
201
168
|
{
|
|
202
|
-
delays: {
|
|
203
|
-
AUTO_VERIFY_TIMEOUT: AUTO_VERIFY_WAIT_MS,
|
|
204
|
-
},
|
|
205
169
|
actions: {
|
|
206
170
|
setStrategy: assign((context, event) => {
|
|
207
171
|
return {
|
|
@@ -214,16 +178,12 @@ export default function (request) {
|
|
|
214
178
|
}
|
|
215
179
|
}),
|
|
216
180
|
setVerificationData: assign((context, event) => {
|
|
217
|
-
const {
|
|
181
|
+
const { requestId, ttl, target, status } = event.data
|
|
218
182
|
return {
|
|
219
|
-
requestId
|
|
220
|
-
ttl: ttl
|
|
221
|
-
target
|
|
222
|
-
|
|
223
|
-
email: email,
|
|
224
|
-
countryCode: countryCode,
|
|
225
|
-
phone: phone,
|
|
226
|
-
},
|
|
183
|
+
requestId,
|
|
184
|
+
ttl: ttl * 1000,
|
|
185
|
+
target,
|
|
186
|
+
status,
|
|
227
187
|
}
|
|
228
188
|
}),
|
|
229
189
|
decreaseTtl: assign((context, evnet) => {
|
|
@@ -232,8 +192,6 @@ export default function (request) {
|
|
|
232
192
|
ttl: Math.max(ms - 1000, 0),
|
|
233
193
|
}
|
|
234
194
|
}),
|
|
235
|
-
resetAutoVerifyUpdates: assign(() => ({ autoVerifyUpdates: 0 })),
|
|
236
|
-
countAutoVerifyUpdate: assign((context) => ({ autoVerifyUpdates: context.autoVerifyUpdates + 1 })),
|
|
237
195
|
setError: assign((context, event) => {
|
|
238
196
|
return {
|
|
239
197
|
error: event.data,
|
|
@@ -254,24 +212,19 @@ export default function (request) {
|
|
|
254
212
|
}),
|
|
255
213
|
},
|
|
256
214
|
guards: {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
isLastAutoVerifyUpdate: (context, event) => context.autoVerifyUpdates + 1 >= AUTO_VERIFY_MAX_USER_INFO_UPDATES,
|
|
215
|
+
isVerified: (context, event) => {
|
|
216
|
+
return context.userInfo?.verification_status === 1
|
|
217
|
+
},
|
|
261
218
|
isNotVerified: (context, event) => {
|
|
262
|
-
|
|
263
|
-
if (!userInfo) return false
|
|
264
|
-
if (strategy === 'phone') return !userInfo.phone_verification_status
|
|
265
|
-
if (strategy === 'email') return !userInfo.email_verification_status
|
|
266
|
-
return false
|
|
219
|
+
return context.userInfo && context.userInfo.verification_status !== 1
|
|
267
220
|
},
|
|
268
221
|
isPhoneNotVerified: (context, event) => {
|
|
269
222
|
const { strategy, userInfo } = context
|
|
270
|
-
return strategy === 'phone' &&
|
|
223
|
+
return strategy === 'phone' && userInfo && userInfo.verification_status !== 1 && !userInfo.phone
|
|
271
224
|
},
|
|
272
225
|
isEmailNotVerified: (context, event) => {
|
|
273
226
|
const { strategy, userInfo } = context
|
|
274
|
-
return strategy === 'email' &&
|
|
227
|
+
return strategy === 'email' && userInfo && userInfo.verification_status !== 1 && !userInfo.email
|
|
275
228
|
},
|
|
276
229
|
hasNoPhone: (context, event) => {
|
|
277
230
|
const { error } = context
|
|
@@ -286,56 +239,24 @@ export default function (request) {
|
|
|
286
239
|
return await request.send(user.getUserInfo())
|
|
287
240
|
},
|
|
288
241
|
verify: async (context, event) => {
|
|
289
|
-
|
|
290
|
-
// [防呆] 資料不完整直接跳出
|
|
291
|
-
if (!provider) {
|
|
292
|
-
return
|
|
293
|
-
}
|
|
294
|
-
return await request.send(
|
|
295
|
-
otp.verification({
|
|
296
|
-
strategy: provider,
|
|
297
|
-
email: provider === 'email' ? event.data?.email : undefined,
|
|
298
|
-
countryCode: provider === 'phone' ? event.data?.country_code : undefined,
|
|
299
|
-
phone: provider === 'phone' ? event.data?.tel : undefined,
|
|
300
|
-
})
|
|
301
|
-
)
|
|
242
|
+
return await request.send(user.verifyV2Initiate({ strategy: context.strategy }))
|
|
302
243
|
},
|
|
303
244
|
sendPhone: async (context, event) => {
|
|
304
245
|
const { countryCode, phone } = context
|
|
305
|
-
return await request.send(
|
|
306
|
-
otp.verification({
|
|
307
|
-
strategy: 'phone',
|
|
308
|
-
countryCode,
|
|
309
|
-
phone,
|
|
310
|
-
})
|
|
311
|
-
)
|
|
246
|
+
return await request.send(auth.bindPost({ provider: 'phone', countryCode, phone }))
|
|
312
247
|
},
|
|
313
248
|
sendEmail: async (context, event) => {
|
|
314
249
|
const { email } = context
|
|
315
|
-
return await request.send(
|
|
316
|
-
otp.verification({
|
|
317
|
-
strategy: 'email',
|
|
318
|
-
email,
|
|
319
|
-
})
|
|
320
|
-
)
|
|
250
|
+
return await request.send(auth.bindPost({ provider: 'email', email }))
|
|
321
251
|
},
|
|
322
252
|
resetOtp: async (context, event) => {
|
|
323
253
|
const { requestId, target } = context
|
|
324
|
-
return await request.send(
|
|
325
|
-
otp.reset({
|
|
326
|
-
request_id: requestId,
|
|
327
|
-
})
|
|
328
|
-
)
|
|
254
|
+
return await request.send(user.otpReset({ requestId, target }))
|
|
329
255
|
},
|
|
330
256
|
acknowledge: async (context, event) => {
|
|
331
257
|
const { requestId, target } = context
|
|
332
258
|
const code = event.data
|
|
333
|
-
return await request.send(
|
|
334
|
-
otp.acknowledge({
|
|
335
|
-
request_id: requestId,
|
|
336
|
-
code,
|
|
337
|
-
})
|
|
338
|
-
)
|
|
259
|
+
return await request.send(user.otpAcknowledge({ requestId, target, code }))
|
|
339
260
|
},
|
|
340
261
|
},
|
|
341
262
|
}
|
|
@@ -231,7 +231,7 @@ export default function (request) {
|
|
|
231
231
|
fetchInitData: async (context, event) => {
|
|
232
232
|
const [paymentList, paymentInfo] = await Promise.all([
|
|
233
233
|
request.send(payment.getBindingPaymentList({ appSecret })),
|
|
234
|
-
|
|
234
|
+
request.send(payment.getPaymentInfo()),
|
|
235
235
|
])
|
|
236
236
|
return { paymentList, paymentInfo }
|
|
237
237
|
},
|
|
@@ -258,7 +258,7 @@ export default function (request) {
|
|
|
258
258
|
ifscCode,
|
|
259
259
|
bankCode: bank?.bankCode || '',
|
|
260
260
|
cryptoCurrency: crypto?.symbol || '',
|
|
261
|
-
cryptoNetwork: network?.
|
|
261
|
+
cryptoNetwork: network?.label || '',
|
|
262
262
|
cryptoAddress: cryptoAddress,
|
|
263
263
|
walletCode: walletCode?.bankCode || '',
|
|
264
264
|
branch: branch === 'BLANK' ? '' : branch, // 'BLANK'會置換成空值
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import payment from '../api/payment.js'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
const { appSecret } = request.config
|
|
6
|
+
|
|
7
|
+
return createMachine(
|
|
8
|
+
{
|
|
9
|
+
id: 'bank_binding_amb',
|
|
10
|
+
initial: 'fetching',
|
|
11
|
+
context: {
|
|
12
|
+
hasAnyAccount: false,
|
|
13
|
+
bankList: [],
|
|
14
|
+
bank: null,
|
|
15
|
+
// bonus: 0,
|
|
16
|
+
bankAccount: null,
|
|
17
|
+
firstNameTh: null,
|
|
18
|
+
lastNameTh: null,
|
|
19
|
+
firstNameEn: null,
|
|
20
|
+
lastNameEn: null,
|
|
21
|
+
},
|
|
22
|
+
states: {
|
|
23
|
+
fetching: {
|
|
24
|
+
invoke: {
|
|
25
|
+
src: 'fetchInitData',
|
|
26
|
+
onDone: {
|
|
27
|
+
target: 'idle',
|
|
28
|
+
actions: 'setBanks',
|
|
29
|
+
},
|
|
30
|
+
onError: {
|
|
31
|
+
target: 'idle',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
idle: {
|
|
36
|
+
on: {
|
|
37
|
+
SET_BANK_CODE: {
|
|
38
|
+
actions: assign((context, event) => {
|
|
39
|
+
return {
|
|
40
|
+
bank: event.data,
|
|
41
|
+
}
|
|
42
|
+
}),
|
|
43
|
+
},
|
|
44
|
+
SET_BANK_ACCOUNT: {
|
|
45
|
+
actions: assign((context, event) => {
|
|
46
|
+
return {
|
|
47
|
+
bankAccount: event.data,
|
|
48
|
+
}
|
|
49
|
+
}),
|
|
50
|
+
},
|
|
51
|
+
SET_FIRST_NAME_TH: {
|
|
52
|
+
actions: assign((context, event) => {
|
|
53
|
+
return {
|
|
54
|
+
firstNameTh: event.data,
|
|
55
|
+
}
|
|
56
|
+
}),
|
|
57
|
+
},
|
|
58
|
+
SET_LAST_NAME_TH: {
|
|
59
|
+
actions: assign((context, event) => {
|
|
60
|
+
return {
|
|
61
|
+
lastNameTh: event.data,
|
|
62
|
+
}
|
|
63
|
+
}),
|
|
64
|
+
},
|
|
65
|
+
SET_FIRST_NAME_EN: {
|
|
66
|
+
actions: assign((context, event) => {
|
|
67
|
+
return {
|
|
68
|
+
firstNameEn: event.data,
|
|
69
|
+
}
|
|
70
|
+
}),
|
|
71
|
+
},
|
|
72
|
+
SET_LAST_NAME_EN: {
|
|
73
|
+
actions: assign((context, event) => {
|
|
74
|
+
return {
|
|
75
|
+
lastNameEn: event.data,
|
|
76
|
+
}
|
|
77
|
+
}),
|
|
78
|
+
},
|
|
79
|
+
BIND_BANK: {
|
|
80
|
+
target: 'binding',
|
|
81
|
+
cond: 'isBindable',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
binding: {
|
|
86
|
+
invoke: {
|
|
87
|
+
src: 'updatePaymentInfo',
|
|
88
|
+
onDone: {
|
|
89
|
+
target: 'bound',
|
|
90
|
+
},
|
|
91
|
+
onError: {
|
|
92
|
+
target: 'idle',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
bound: {},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
actions: {
|
|
101
|
+
setBanks: assign((context, event) => {
|
|
102
|
+
const { bankList = [], paymentInfo = {} } = event.data
|
|
103
|
+
const { bankInfo = [] } = paymentInfo
|
|
104
|
+
return {
|
|
105
|
+
hasAnyAccount: bankInfo.length > 0,
|
|
106
|
+
holderName: bankInfo[0]?.holderName,
|
|
107
|
+
bankList,
|
|
108
|
+
bank: bankList[0],
|
|
109
|
+
}
|
|
110
|
+
}),
|
|
111
|
+
},
|
|
112
|
+
guards: {
|
|
113
|
+
isBindable: (context, event) => {
|
|
114
|
+
const { bank, bankAccount, firstNameTh, lastNameTh, firstNameEn, lastNameEn } = context
|
|
115
|
+
|
|
116
|
+
return bank.bankCode && bankAccount && firstNameTh && lastNameTh && firstNameEn && lastNameEn
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
services: {
|
|
120
|
+
fetchInitData: async (context, event) => {
|
|
121
|
+
const [bankList, paymentInfo] = await Promise.all([
|
|
122
|
+
request.send(payment.getBindingBankList({ appSecret })),
|
|
123
|
+
request.send(payment.getPaymentInfo()),
|
|
124
|
+
])
|
|
125
|
+
return { bankList, paymentInfo }
|
|
126
|
+
},
|
|
127
|
+
updatePaymentInfo: async (context, event) => {
|
|
128
|
+
const { bonus, bank, bankAccount, firstNameTh, lastNameTh, firstNameEn, lastNameEn } = context
|
|
129
|
+
return await request.send(
|
|
130
|
+
payment.updatePaymentInfo({
|
|
131
|
+
paymentProvider: 'amb',
|
|
132
|
+
// bonus,
|
|
133
|
+
bankCode: bank.bankCode,
|
|
134
|
+
bankAccount,
|
|
135
|
+
firstNameTh,
|
|
136
|
+
lastNameTh,
|
|
137
|
+
firstNameEn,
|
|
138
|
+
lastNameEn,
|
|
139
|
+
})
|
|
140
|
+
)
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
}
|
|
144
|
+
)
|
|
145
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { assign, createMachine, send } from 'xstate'
|
|
2
|
+
import payment from '../api/payment.js'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
return createMachine(
|
|
6
|
+
{
|
|
7
|
+
id: 'bonus',
|
|
8
|
+
initial: 'loading',
|
|
9
|
+
context: {
|
|
10
|
+
bonus: null,
|
|
11
|
+
},
|
|
12
|
+
states: {
|
|
13
|
+
loading: {
|
|
14
|
+
invoke: {
|
|
15
|
+
src: 'fetchInitData',
|
|
16
|
+
onDone: {
|
|
17
|
+
target: 'idle',
|
|
18
|
+
actions: 'setBonus',
|
|
19
|
+
},
|
|
20
|
+
onError: {
|
|
21
|
+
target: 'idle',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
idle: {
|
|
26
|
+
on: {
|
|
27
|
+
TOGGLE: {
|
|
28
|
+
target: 'updating',
|
|
29
|
+
},
|
|
30
|
+
SWITCH_ON: {
|
|
31
|
+
actions: send((context, event) => ({ type: 'TOGGLE', data: 1 })),
|
|
32
|
+
cond: (context, event) => context.bonus !== 1,
|
|
33
|
+
},
|
|
34
|
+
SWITCH_OFF: {
|
|
35
|
+
actions: send((context, event) => ({ type: 'TOGGLE', data: 0 })),
|
|
36
|
+
cond: (context, event) => context.bonus !== 0,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
updating: {
|
|
41
|
+
invoke: {
|
|
42
|
+
src: 'toggleBonus',
|
|
43
|
+
onDone: {
|
|
44
|
+
target: 'idle',
|
|
45
|
+
actions: 'setBonus',
|
|
46
|
+
},
|
|
47
|
+
onError: {
|
|
48
|
+
target: 'idle',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
actions: {
|
|
56
|
+
setBonus: assign((context, event) => {
|
|
57
|
+
return {
|
|
58
|
+
bonus: event.data,
|
|
59
|
+
}
|
|
60
|
+
}),
|
|
61
|
+
},
|
|
62
|
+
services: {
|
|
63
|
+
fetchInitData: async (context, event) => {
|
|
64
|
+
const { bonus } = await request.send(payment.getPaymentInfo())
|
|
65
|
+
return bonus
|
|
66
|
+
},
|
|
67
|
+
toggleBonus: async (context, event) => {
|
|
68
|
+
const bonus = context.bonus ? 0 : 1
|
|
69
|
+
await request.send(payment.setBonusSetting({ bonus }))
|
|
70
|
+
return bonus
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
}
|