@jetthai/cuora 1.1.488 → 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/CHANGELOG.md +0 -349
- 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 -17
- 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 +109 -158
- 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 -43
- 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 -46
- 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 +38 -59
- package/src/request/config.js +0 -2
- package/src/request/request.js +62 -130
- package/src/util/constant.js +2 -6
- 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 -93
- package/.claude/settings.local.json +0 -23
- package/.github/copilot-instructions.md +0 -448
- package/.husky/post-checkout +0 -32
- package/.husky/pre-push +0 -36
- package/AGENTS.md +0 -448
- package/AI_PROMPT_SOURCE.md +0 -446
- package/CLAUDE.md +0 -448
- package/GEMINI.md +0 -448
- 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/scripts/auto-version.js +0 -68
- package/scripts/auto-version.sh +0 -33
- package/scripts/branch-auto-npm-publish.js +0 -29
- 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/test/auth_otp_v3.test.js +0 -323
- package/tests/websocket.test.mjs +0 -779
|
@@ -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
|
+
}
|
package/src/machine/common.js
CHANGED
|
@@ -3,10 +3,9 @@ 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'
|
|
7
6
|
|
|
8
7
|
export default function (request) {
|
|
9
|
-
const { appSecret,
|
|
8
|
+
const { appSecret, defaultChannel, defaultSubchannel } = request.config
|
|
10
9
|
return createMachine(
|
|
11
10
|
{
|
|
12
11
|
id: 'common',
|
|
@@ -34,6 +33,10 @@ export default function (request) {
|
|
|
34
33
|
broadcastList: null,
|
|
35
34
|
mailBoxInfo: null,
|
|
36
35
|
promotions: [],
|
|
36
|
+
normalBroadcast: null,
|
|
37
|
+
sentNormalBroadcastList: [],
|
|
38
|
+
channel: null,
|
|
39
|
+
subchannel: null,
|
|
37
40
|
affiliateCode: null,
|
|
38
41
|
defaultAffiliateCode: null,
|
|
39
42
|
friendCode: null,
|
|
@@ -52,7 +55,7 @@ export default function (request) {
|
|
|
52
55
|
},
|
|
53
56
|
},
|
|
54
57
|
fetching: {
|
|
55
|
-
entry: ['setUA', 'setAgent', 'setPixel', 'setKPixel'
|
|
58
|
+
entry: ['setUA', 'setAgent', 'setPixel', 'setKPixel'],
|
|
56
59
|
invoke: {
|
|
57
60
|
src: 'fetchConfig',
|
|
58
61
|
onDone: [
|
|
@@ -119,9 +122,6 @@ export default function (request) {
|
|
|
119
122
|
},
|
|
120
123
|
},
|
|
121
124
|
on: {
|
|
122
|
-
REFRESH_FEEDS: {
|
|
123
|
-
target: '.updating',
|
|
124
|
-
},
|
|
125
125
|
ENTER_GAME_PAUSE: {
|
|
126
126
|
target: '.idle',
|
|
127
127
|
actions: 'resetByEnterGame',
|
|
@@ -157,6 +157,39 @@ export default function (request) {
|
|
|
157
157
|
},
|
|
158
158
|
},
|
|
159
159
|
},
|
|
160
|
+
broadcast: {
|
|
161
|
+
initial: 'idle',
|
|
162
|
+
states: {
|
|
163
|
+
idle: {
|
|
164
|
+
on: {
|
|
165
|
+
START_BROADCAST: {
|
|
166
|
+
target: 'picking',
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
picking: {
|
|
171
|
+
after: {
|
|
172
|
+
5000: {
|
|
173
|
+
target: 'display',
|
|
174
|
+
actions: 'setBroadcast',
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
display: {
|
|
179
|
+
after: {
|
|
180
|
+
5000: {
|
|
181
|
+
target: 'picking',
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
on: {
|
|
187
|
+
RESET_BROADCAST: {
|
|
188
|
+
target: '.idle',
|
|
189
|
+
actions: 'resetBroadcast',
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
},
|
|
160
193
|
},
|
|
161
194
|
},
|
|
162
195
|
{
|
|
@@ -204,18 +237,6 @@ export default function (request) {
|
|
|
204
237
|
isMobile: userAgent?.device?.type,
|
|
205
238
|
}
|
|
206
239
|
}),
|
|
207
|
-
setFbclid: assign(() => {
|
|
208
|
-
const urlParams = new URLSearchParams(window.location.search)
|
|
209
|
-
const fbclid = urlParams.get('fbclid') || ''
|
|
210
|
-
if (fbclid !== '') {
|
|
211
|
-
const timestamp = Date.now()
|
|
212
|
-
const cookieRecord = 'fb.1.' + timestamp + '.' + fbclid
|
|
213
|
-
document.cookie = `_fbc=${cookieRecord}; path=/; max-age=${60 * 60 * 24 * 7}`
|
|
214
|
-
}
|
|
215
|
-
return {
|
|
216
|
-
fbclid,
|
|
217
|
-
}
|
|
218
|
-
}),
|
|
219
240
|
setPixel: assign(() => {
|
|
220
241
|
let urlParams = new URLSearchParams(window.location.search)
|
|
221
242
|
const pix = urlParams.get('pix') || storage.get('pix') || ''
|
|
@@ -242,17 +263,40 @@ export default function (request) {
|
|
|
242
263
|
kpix,
|
|
243
264
|
}
|
|
244
265
|
}),
|
|
245
|
-
setAgent: assign(() => {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
266
|
+
setAgent: assign((context, event) => {
|
|
267
|
+
if (window.CC_JSB === true) {
|
|
268
|
+
// is cocos native app
|
|
269
|
+
return
|
|
270
|
+
} else {
|
|
271
|
+
let urlParams = new URLSearchParams(window.location.search)
|
|
272
|
+
const channel = urlParams.get('channel') || storage.get('channel') || defaultChannel || 'official'
|
|
273
|
+
const subchannel = urlParams.get('subchannel') || storage.get('subchannel') || defaultSubchannel || 'pwa'
|
|
274
|
+
const affiliateCode = urlParams.get('ac') || urlParams.get('referralCode') || storage.get('ac') || storage.get('referralCode')
|
|
275
|
+
const friendCode = urlParams.get('fc') || urlParams.get('affiliate') || storage.get('fc') || storage.get('affiliate')
|
|
249
276
|
|
|
250
|
-
|
|
251
|
-
|
|
277
|
+
storage.set('channel', channel, {
|
|
278
|
+
path: '/',
|
|
279
|
+
maxAge: 60 * 60 * 24 * 7,
|
|
280
|
+
})
|
|
281
|
+
storage.set('subchannel', subchannel, {
|
|
282
|
+
path: '/',
|
|
283
|
+
maxAge: 60 * 60 * 24 * 7,
|
|
284
|
+
})
|
|
285
|
+
storage.set('ac', affiliateCode, {
|
|
286
|
+
path: '/',
|
|
287
|
+
maxAge: 60 * 60 * 24 * 7,
|
|
288
|
+
})
|
|
289
|
+
storage.set('fc', friendCode, {
|
|
290
|
+
path: '/',
|
|
291
|
+
maxAge: 60 * 60 * 24 * 7,
|
|
292
|
+
})
|
|
252
293
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
294
|
+
return {
|
|
295
|
+
channel,
|
|
296
|
+
subchannel,
|
|
297
|
+
affiliateCode,
|
|
298
|
+
friendCode,
|
|
299
|
+
}
|
|
256
300
|
}
|
|
257
301
|
}),
|
|
258
302
|
clearAnnouncements: assign((context, event) => {
|
|
@@ -271,6 +315,26 @@ export default function (request) {
|
|
|
271
315
|
}
|
|
272
316
|
return { broadcastList, mailBoxInfo }
|
|
273
317
|
}),
|
|
318
|
+
setBroadcast: assign((context, event) => {
|
|
319
|
+
const { broadcastList, sentNormalBroadcastList, normalBroadcast } = context
|
|
320
|
+
let sentNormalList = sentNormalBroadcastList
|
|
321
|
+
if (normalBroadcast) {
|
|
322
|
+
sentNormalList = [...sentNormalBroadcastList, normalBroadcast]
|
|
323
|
+
}
|
|
324
|
+
const nextNormalBroadcast = broadcastList?.broadcasts?.find((broadcast) => {
|
|
325
|
+
return broadcast.type === '0' && !sentNormalList.some((item) => item.broadcast_id === broadcast.broadcast_id)
|
|
326
|
+
})
|
|
327
|
+
return {
|
|
328
|
+
normalBroadcast: nextNormalBroadcast,
|
|
329
|
+
sentNormalBroadcastList: sentNormalList,
|
|
330
|
+
}
|
|
331
|
+
}),
|
|
332
|
+
resetBroadcast: assign((context, event) => {
|
|
333
|
+
return {
|
|
334
|
+
normalBroadcast: null,
|
|
335
|
+
sentNormalBroadcastList: [],
|
|
336
|
+
}
|
|
337
|
+
}),
|
|
274
338
|
resetByEnterGame: assign((context, event) => {
|
|
275
339
|
return {
|
|
276
340
|
isPlaying: true,
|