@jetthai/cuora 2.0.0-beta.0 → 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.
Files changed (201) hide show
  1. package/.claude/commands/sync-ai-prompts.md +93 -0
  2. package/.claude/settings.local.json +23 -0
  3. package/.github/copilot-instructions.md +405 -0
  4. package/.husky/post-checkout +32 -0
  5. package/.husky/pre-commit +1 -3
  6. package/.husky/pre-push +36 -0
  7. package/AGENTS.md +405 -0
  8. package/AI_PROMPT_SOURCE.md +403 -0
  9. package/CHANGELOG.md +274 -3
  10. package/CLAUDE.md +405 -0
  11. package/GEMINI.md +405 -0
  12. package/README.md +299 -15
  13. package/docs/kibana/crypto-way-deposit-amount-bug-analysis.md +1003 -0
  14. package/docs/kibana/play-providerId-error.md +202 -0
  15. package/docs/kibana/play-selectedWalletType.md +1 -0
  16. package/docs/kibana/play-selectedWalletType_2.md +1 -0
  17. package/docs/kibana/play-selectedWalletType_analysis.md +565 -0
  18. package/package.json +3 -3
  19. package/scripts/auto-version.js +68 -0
  20. package/scripts/auto-version.sh +33 -0
  21. package/scripts/branch-auto-npm-publish.js +29 -0
  22. package/scripts/check-version.sh +36 -0
  23. package/scripts/clean-tags.sh +84 -0
  24. package/src/api/account.js +0 -1
  25. package/src/api/activity.js +22 -37
  26. package/src/api/auth.js +5 -36
  27. package/src/api/common.js +5 -3
  28. package/src/api/game.js +0 -10
  29. package/src/api/payment.js +17 -55
  30. package/src/api/user.js +10 -16
  31. package/src/index.js +2 -2
  32. package/src/machine/activity/activity_cash.js +84 -36
  33. package/src/machine/activity/cash_rain_activity.js +0 -1
  34. package/src/machine/activity/continue_deposit_activity.js +0 -1
  35. package/src/machine/activity/deposit_activity.js +0 -1
  36. package/src/machine/activity/diamond_shop_activity_cash.js +0 -8
  37. package/src/machine/activity/fafafa_activity.js +0 -11
  38. package/src/machine/activity/friend_invite_friends_activity.js +8 -7
  39. package/src/machine/activity/index.js +0 -12
  40. package/src/machine/activity/instant_rebate_activity.js +0 -1
  41. package/src/machine/activity/jackpot.js +0 -1
  42. package/src/machine/activity/otp_verified_activity.js +0 -1
  43. package/src/machine/activity/ranking_activity.js +0 -1
  44. package/src/machine/activity/roulette_activity_v2.js +0 -1
  45. package/src/machine/activity/sign_in_activity.js +0 -1
  46. package/src/machine/activity/sign_in_monthly_activity.js +1 -2
  47. package/src/machine/activity/specify_bets_activity.js +0 -1
  48. package/src/machine/activity/specify_turnover_activity.js +0 -1
  49. package/src/machine/activity/time_bomb_activity.js +0 -1
  50. package/src/machine/activity/vip_card_activity.js +0 -1
  51. package/src/machine/auth.js +112 -112
  52. package/src/machine/auth_otp_v3.js +11 -8
  53. package/src/machine/bank_binding.js +2 -3
  54. package/src/machine/common.js +14 -98
  55. package/src/machine/deposit/crypto_bank_cash.js +20 -35
  56. package/src/machine/deposit/crypto_qrcode_cash.js +26 -64
  57. package/src/machine/deposit/crypto_way_cash.js +48 -37
  58. package/src/machine/deposit/direct_cash.js +8 -10
  59. package/src/machine/deposit/index.js +0 -28
  60. package/src/machine/deposit/loadcard_cash.js +14 -32
  61. package/src/machine/deposit/manual_cash.js +8 -11
  62. package/src/machine/deposit/qrcode_cash.js +15 -32
  63. package/src/machine/deposit/usdt_cash.js +1 -15
  64. package/src/machine/deposit/virtual_bank_cash.js +13 -12
  65. package/src/machine/error.js +7 -1
  66. package/src/machine/game_betslip.js +0 -1
  67. package/src/machine/game_favorite_v2.js +0 -1
  68. package/src/machine/game_info.js +1 -13
  69. package/src/machine/game_search_cash.js +0 -1
  70. package/src/machine/game_v2_1.js +39 -126
  71. package/src/machine/honor_board_cash.js +8 -11
  72. package/src/machine/inbox.js +43 -105
  73. package/src/machine/index.js +0 -32
  74. package/src/machine/leaderboard.js +8 -12
  75. package/src/machine/navbar.js +1 -3
  76. package/src/machine/ranking.js +45 -30
  77. package/src/machine/reward_cash.js +0 -40
  78. package/src/machine/roulette_v2.js +14 -11
  79. package/src/machine/setting.js +0 -1
  80. package/src/machine/side_cash.js +3 -3
  81. package/src/machine/user_info.js +0 -1
  82. package/src/machine/user_photo.js +0 -1
  83. package/src/machine/user_reset_password.js +0 -14
  84. package/src/machine/user_sign_up.js +46 -61
  85. package/src/machine/websocket.js +18 -62
  86. package/src/machine/withdraw/index.js +0 -6
  87. package/src/machine/withdraw/withdraw_manual_cash.js +59 -39
  88. package/src/request/config.js +2 -0
  89. package/src/request/request.js +49 -60
  90. package/src/util/amount.js +8 -0
  91. package/src/util/constant.js +0 -1
  92. package/src/util/err998SentryExtra.js +26 -0
  93. package/src/util/index.js +2 -4
  94. package/src/util/paramStore.js +139 -0
  95. package/src/util/storage.js +3 -4
  96. package/BREAKING_CHANGES.md +0 -9
  97. package/resetGitBranch.sh +0 -101
  98. package/src/lib/fingerprint_v3_11_12.js +0 -11433
  99. package/src/machine/activity/activity.js +0 -213
  100. package/src/machine/activity/diamond_shop_activity_fc.js +0 -197
  101. package/src/machine/activity/diamond_shop_activity_vn.js +0 -179
  102. package/src/machine/activity/invite_friends_activity.js +0 -115
  103. package/src/machine/activity/mini_game_activity.js +0 -69
  104. package/src/machine/activity/return_bonus_activity.js +0 -155
  105. package/src/machine/auth_otp_v2.js +0 -178
  106. package/src/machine/bank_binding_amb.js +0 -146
  107. package/src/machine/bonus.js +0 -76
  108. package/src/machine/deposit/amb.js +0 -93
  109. package/src/machine/deposit/crypto_bank.js +0 -340
  110. package/src/machine/deposit/crypto_qrcode.js +0 -158
  111. package/src/machine/deposit/crypto_way.js +0 -253
  112. package/src/machine/deposit/deposit_fc.js +0 -272
  113. package/src/machine/deposit/direct.js +0 -311
  114. package/src/machine/deposit/float.js +0 -375
  115. package/src/machine/deposit/krway.js +0 -152
  116. package/src/machine/deposit/loadcard_vn.js +0 -352
  117. package/src/machine/deposit/manual_vn.js +0 -459
  118. package/src/machine/deposit/qrcode_v2.js +0 -339
  119. package/src/machine/deposit/usdt.js +0 -163
  120. package/src/machine/deposit/virtual_bank_vn.js +0 -270
  121. package/src/machine/deposit/vpay.js +0 -374
  122. package/src/machine/game_hot_new.js +0 -80
  123. package/src/machine/game_replay.js +0 -47
  124. package/src/machine/game_search_v2.js +0 -402
  125. package/src/machine/honor_board.js +0 -133
  126. package/src/machine/merge.js +0 -58
  127. package/src/machine/payment_data.js +0 -87
  128. package/src/machine/promotions.js +0 -163
  129. package/src/machine/reward.js +0 -256
  130. package/src/machine/reward_fc.js +0 -99
  131. package/src/machine/side.js +0 -160
  132. package/src/machine/side_v2.js +0 -223
  133. package/src/machine/vip_table.js +0 -58
  134. package/src/machine/welcome.js +0 -111
  135. package/src/machine/withdraw/withdraw_crypto_cash.js +0 -328
  136. package/src/machine/withdraw/withdraw_krway.js +0 -223
  137. package/src/machine/withdraw/withdraw_manual.js +0 -541
  138. package/src/util/deviceToken.js +0 -60
  139. package/src/util/math.js +0 -4
  140. package/test/api.behavior.test.js +0 -69
  141. package/test/api.contract.test.js +0 -18
  142. package/test/config.test.js +0 -27
  143. package/test/deviceToken.test.js +0 -139
  144. package/test/helpers.coverage.test.js +0 -11
  145. package/test/helpers.js +0 -91
  146. package/test/index.exports.test.js +0 -14
  147. package/test/machine.activity.core.coverage.test.js +0 -337
  148. package/test/machine.activity.gap.coverage.test.js +0 -252
  149. package/test/machine.activity.more.coverage.test.js +0 -180
  150. package/test/machine.activity_plus_and_binding_amb.coverage.test.js +0 -201
  151. package/test/machine.activity_timer_bonus.coverage.test.js +0 -136
  152. package/test/machine.activity_welcome.low.coverage.test.js +0 -211
  153. package/test/machine.amb_rewardfc_websocket.more.coverage.test.js +0 -201
  154. package/test/machine.auth.coverage.test.js +0 -215
  155. package/test/machine.bank_binding.test.js +0 -143
  156. package/test/machine.binding_otp_krway.coverage.test.js +0 -223
  157. package/test/machine.contract.test.js +0 -50
  158. package/test/machine.crypto_bank.coverage.test.js +0 -270
  159. package/test/machine.crypto_way.coverage.test.js +0 -108
  160. package/test/machine.crypto_way_cash.coverage.test.js +0 -114
  161. package/test/machine.definition.test.js +0 -137
  162. package/test/machine.deposit.manual.coverage.test.js +0 -365
  163. package/test/machine.deposit_fc.coverage.test.js +0 -126
  164. package/test/machine.direct.coverage.test.js +0 -96
  165. package/test/machine.direct_cash.coverage.test.js +0 -108
  166. package/test/machine.error.coverage.test.js +0 -37
  167. package/test/machine.events.test.js +0 -126
  168. package/test/machine.favorite_jackpot.coverage.test.js +0 -82
  169. package/test/machine.float.coverage.test.js +0 -136
  170. package/test/machine.flow.test.js +0 -226
  171. package/test/machine.game_hot_new_vip_table.coverage.test.js +0 -105
  172. package/test/machine.game_search_cash.coverage.test.js +0 -155
  173. package/test/machine.game_search_v2.test.js +0 -199
  174. package/test/machine.game_user_profile.coverage.test.js +0 -100
  175. package/test/machine.honor_board.test.js +0 -133
  176. package/test/machine.inbox.common.coverage.test.js +0 -304
  177. package/test/machine.loadcard_cash.coverage.test.js +0 -101
  178. package/test/machine.loadcard_vn.coverage.test.js +0 -122
  179. package/test/machine.misc.coverage.test.js +0 -361
  180. package/test/machine.more2.coverage.test.js +0 -261
  181. package/test/machine.options.execution.test.js +0 -272
  182. package/test/machine.priority.coverage.test.js +0 -603
  183. package/test/machine.qrcode_cash.coverage.test.js +0 -107
  184. package/test/machine.qrcode_v2.coverage.test.js +0 -121
  185. package/test/machine.regression.test.js +0 -82
  186. package/test/machine.roulette_v2.test.js +0 -142
  187. package/test/machine.side_reward_reset.coverage.test.js +0 -220
  188. package/test/machine.targeted.coverage.test.js +0 -313
  189. package/test/machine.usdt.coverage.test.js +0 -95
  190. package/test/machine.usdt_cash.coverage.test.js +0 -73
  191. package/test/machine.vip_card_activity.test.js +0 -114
  192. package/test/machine.virtual_bank_cash.coverage.test.js +0 -105
  193. package/test/machine.virtual_bank_vn.coverage.test.js +0 -105
  194. package/test/machine.vpay.coverage.test.js +0 -142
  195. package/test/machine.withdraw_crypto_cash.coverage.test.js +0 -166
  196. package/test/machine.withdraw_krway.coverage.test.js +0 -123
  197. package/test/machine.withdraw_manual.coverage.test.js +0 -185
  198. package/test/machine.withdraw_manual_cash.coverage.test.js +0 -123
  199. package/test/request.test.js +0 -325
  200. package/test/util.storage.errors.test.js +0 -47
  201. package/test/util.test.js +0 -41
@@ -3,24 +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, fpToken, sentry, defaultChannel, defaultSubchannel } = request.config
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'
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
+ ]
19
24
 
20
25
  return createMachine(
21
26
  {
22
27
  id: 'auth',
23
- predictableActionArguments: true,
24
28
  initial: 'fetchingConfig',
25
29
  context: {
26
30
  base: '',
@@ -42,6 +46,7 @@ export default function (request) {
42
46
  redirectURL: null,
43
47
  reCaptchaToken: null,
44
48
  fc: null,
49
+ dt: null,
45
50
  },
46
51
  states: {
47
52
  fetchingConfig: {
@@ -49,7 +54,7 @@ export default function (request) {
49
54
  src: 'fetchSiteConfig',
50
55
  onDone: {
51
56
  target: 'idle',
52
- actions: 'setSiteConfig',
57
+ actions: ['setSiteConfig', 'pruneRememberedAccounts'],
53
58
  },
54
59
  onError: {
55
60
  target: 'idle',
@@ -73,32 +78,6 @@ export default function (request) {
73
78
  },
74
79
  },
75
80
  },
76
- authenticationGuest: {
77
- invoke: {
78
- src: 'authenticateGuest',
79
- onDone: {
80
- target: 'authenticated',
81
- actions: 'setToken',
82
- },
83
- onError: {
84
- target: 'idle',
85
- actions: 'removeToken',
86
- },
87
- },
88
- },
89
- authenticationApp: {
90
- invoke: {
91
- src: 'authenticateApp',
92
- onDone: {
93
- target: 'authenticated',
94
- actions: ['setToken'],
95
- },
96
- onError: {
97
- target: 'idle',
98
- actions: 'removeToken',
99
- },
100
- },
101
- },
102
81
  authenticated: {
103
82
  invoke: {
104
83
  src: 'fetchUserInfo',
@@ -112,6 +91,28 @@ export default function (request) {
112
91
  },
113
92
  },
114
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
+ },
115
116
  on: {
116
117
  OTP_VERIFIED: {
117
118
  target: 'loginSuccess',
@@ -179,10 +180,12 @@ export default function (request) {
179
180
  initial: 'deviceTokenChecking',
180
181
  states: {
181
182
  deviceTokenChecking: {
183
+ entry: 'clearDeviceToken',
182
184
  invoke: {
183
185
  src: 'checkDeviceToken',
184
186
  onDone: {
185
187
  target: 'checkDeviceTokenDone',
188
+ actions: 'setDeviceToken',
186
189
  },
187
190
  onError: {
188
191
  target: 'fetching',
@@ -262,9 +265,6 @@ export default function (request) {
262
265
  CLEAR: {
263
266
  target: '.logout',
264
267
  },
265
- LOGIN_GUEST: {
266
- target: '.authenticationGuest',
267
- },
268
268
  LOGIN_ID: {
269
269
  target: '.authentication',
270
270
  actions: ['setReCaptchaToken', 'setLoginId'],
@@ -277,16 +277,9 @@ export default function (request) {
277
277
  target: '.authentication',
278
278
  actions: ['setReCaptchaToken', 'setLoginEmail'],
279
279
  },
280
- LOGIN_LOCAL: {
281
- target: '.authentication',
282
- actions: 'setLoginLocal',
283
- },
284
280
  LOGIN_3PARTY: {
285
281
  actions: 'redirectTo3Party',
286
282
  },
287
- LOGIN_APP: {
288
- target: '.authenticationApp',
289
- },
290
283
  LOGIN_TELEGRAM: {
291
284
  target: '.authentication',
292
285
  actions: 'setLoginTelegram',
@@ -321,6 +314,19 @@ export default function (request) {
321
314
  siteConfig: { ...event.data, loginMethods: pickBy(loginMethods), registerMethods: pickBy(registerMethods) },
322
315
  }
323
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
+ },
324
330
  setReCaptchaToken: assign((context, event) => {
325
331
  const { reCaptchaToken } = event.data
326
332
  return {
@@ -359,28 +365,15 @@ export default function (request) {
359
365
  },
360
366
  }
361
367
  }),
362
- setLoginLocal: assign((context, event) => {
363
- const { username, password } = event.data
364
- storage.set(userKey, username, {
365
- path: '/',
366
- maxAge: 60 * 60 * 24,
367
- })
368
- return {
369
- loginData: {
370
- provider: 'local',
371
- username,
372
- password,
373
- },
374
- }
375
- }),
376
368
  setLoginTelegram: assign((context, event) => {
377
- const { loginType, additionalUserInfo, isSignature } = event.data
369
+ const { loginType, additionalUserInfo, isSignature, idToken } = event.data
378
370
  return {
379
371
  loginData: {
380
372
  provider: 'telegram',
381
373
  loginType,
382
374
  additionalUserInfo,
383
375
  isSignature,
376
+ idToken,
384
377
  },
385
378
  }
386
379
  }),
@@ -399,6 +392,13 @@ export default function (request) {
399
392
  token: event.data,
400
393
  }
401
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 }),
402
402
  setAccount: assign((context, event) => {
403
403
  if (context.loginData.username) {
404
404
  storage.remove(accountEmailKey)
@@ -433,7 +433,7 @@ export default function (request) {
433
433
  path: '/',
434
434
  maxAge: 300,
435
435
  })
436
- return { token: null }
436
+ return { token: null, dt: null }
437
437
  }),
438
438
  extendToken: assign((context, event) => {
439
439
  const token = storage.get(tokenKey)
@@ -444,61 +444,69 @@ export default function (request) {
444
444
  return { token }
445
445
  }),
446
446
  redirectTo3Party: async (context, event) => {
447
- const { provider, channel, subchannel, fc } = event.data
447
+ const { provider, fc } = event.data
448
448
  const deviceTokenEnable = context.siteConfig?.dtVerify
449
449
 
450
- const dt = await getDeviceTokenWithRetry({
451
- fpToken,
452
- sentry,
453
- hosts: request.hosts,
454
- enable: deviceTokenEnable,
455
- })
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 })
456
463
 
457
- const affiliateCode = storage.get('ac')
458
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')
459
469
  const messages = {
460
470
  url: window.location.href,
461
- channelOrders: [
462
- { channel: storage.get('channel'), subchannel: storage.get('subchannel') },
463
- { channel: defaultChannel, subchannel: defaultSubchannel },
464
- { channel: channel, subchannel: subchannel },
465
- ],
466
471
  affiliateCode,
472
+ acSource: hasExplicitAc ? 'event' : acRead.from,
467
473
  nickname,
468
474
  }
469
- sentry?.captureMessage(JSON.stringify(messages))
470
475
 
471
- const referralObj = {}
472
- if (![undefined, 'undefined', null, 'null'].includes(affiliateCode)) {
473
- referralObj.ac = affiliateCode
474
- }
475
-
476
- if (![undefined, 'undefined', null, 'null'].includes(nickname)) {
477
- referralObj.nick_name = nickname
478
- }
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
+ )
479
494
 
480
- referralObj.channel = storage.get('channel') || defaultChannel || channel
481
- referralObj.subchannel = storage.get('subchannel') || defaultSubchannel || subchannel
495
+ storage.remove('tp_phone')
496
+ storage.remove('tp_countryCode')
497
+ storage.remove('tp_email')
498
+ // tp_birthday 不在此移除:client 於回站登入完成後以 /self 補交作為備援,由 client 消費後移除
482
499
 
483
500
  const fullURL = request.config.fullURL
484
501
 
485
- const redirectURL = urljoin(
486
- fullURL,
487
- 'login?' +
488
- new URLSearchParams({
489
- provider,
490
- redirectURI: `${window.location.protocol}//${window.location.host}${context.base}`,
491
- ...referralObj,
492
- dt,
493
- platform: 'pwa',
494
- fc,
495
- }).toString()
496
- )
502
+ const redirectURL = urljoin(fullURL, 'login?' + new URLSearchParams(query).toString())
497
503
 
498
504
  window.location.href = redirectURL
499
505
  },
500
506
  setUserInfo: assign((context, event) => {
501
- sentry?.setUser({ id: event.data.uid_site })
507
+ if (event.data?.uid_site) {
508
+ sentry?.setUser({ id: event.data.uid_site })
509
+ }
502
510
  return {
503
511
  userInfo: event.data,
504
512
  }
@@ -510,19 +518,11 @@ export default function (request) {
510
518
  }),
511
519
  },
512
520
  services: {
513
- authenticateApp: async (context, event) => {
514
- const { token } = await request.send(auth.loginApp(event.data))
515
- return token
516
- },
517
521
  authenticate: async (context, event) => {
518
522
  const data = { ...context.loginData, reCaptchaToken: context.reCaptchaToken }
519
523
  const { token } = await request.send(auth.login(data))
520
524
  return token
521
525
  },
522
- authenticateGuest: async (context, event) => {
523
- const { token } = await request.send(auth.guestLogin())
524
- return token
525
- },
526
526
  logout: async (context, event) => {
527
527
  return await request.send(auth.logout())
528
528
  },
@@ -531,16 +531,16 @@ export default function (request) {
531
531
  },
532
532
  checkDeviceToken: async (context, event) => {
533
533
  const deviceTokenEnable = context.siteConfig?.dtVerify
534
- if (deviceTokenEnable) {
535
- const { exist } = await request.send(user.checkDt())
536
- if (!exist) {
537
- const dt = await getDtWithRetry({ fpToken, sentry, hosts: request.hosts, enable: deviceTokenEnable })
538
- // 確定有dt再取得updateDt
539
- if (dt) {
540
- await request.send(user.updateDt({ dt }))
541
- }
542
- }
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 }
543
542
  }
543
+ return { dt: null }
544
544
  },
545
545
  fetchSiteConfig: async (context, event) => {
546
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
- return context.userInfo?.verification_status === 1
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
- return context.userInfo && context.userInfo.verification_status !== 1
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.verification_status !== 1 && !userInfo.phone
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.verification_status !== 1 && !userInfo.email
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?.label || '',
261
+ cryptoNetwork: network?.networkCode,
263
262
  cryptoAddress: cryptoAddress,
264
263
  walletCode: walletCode?.bankCode || '',
265
264
  branch: branch === 'BLANK' ? '' : branch, // 'BLANK'會置換成空值
@@ -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, defaultChannel, defaultSubchannel } = request.config
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((context, event) => {
280
- if (window.CC_JSB === true) {
281
- // is cocos native app
282
- return
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
- storage.set('channel', channel, {
291
- path: '/',
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
- return {
308
- channel,
309
- subchannel,
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,33 +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
- let sentNormalList = sentNormalBroadcastList
334
- if (normalBroadcast) {
335
- sentNormalList = [...sentNormalBroadcastList, normalBroadcast]
336
- }
337
- const sentIds = new Set(sentNormalList.map((item) => item.broadcast_id))
338
- const broadcastQueue = broadcastList?.broadcasts || []
339
- let nextNormalBroadcast
340
- for (let i = 0; i < broadcastQueue.length; i++) {
341
- const broadcast = broadcastQueue[i]
342
- if (broadcast.type === '0' && !sentIds.has(broadcast.broadcast_id)) {
343
- nextNormalBroadcast = broadcast
344
- break
345
- }
346
- }
347
- return {
348
- normalBroadcast: nextNormalBroadcast,
349
- sentNormalBroadcastList: sentNormalList,
350
- }
351
- }),
352
- resetBroadcast: assign((context, event) => {
353
- return {
354
- normalBroadcast: null,
355
- sentNormalBroadcastList: [],
356
- }
357
- }),
358
274
  resetByEnterGame: assign((context, event) => {
359
275
  return {
360
276
  isPlaying: true,