@jetthai/cuora 1.1.475 → 1.1.476-dev.1

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 (85) hide show
  1. package/.claude/commands/sync-ai-prompts.md +88 -1
  2. package/.claude/settings.local.json +3 -1
  3. package/.github/copilot-instructions.md +68 -58
  4. package/.husky/post-checkout +3 -3
  5. package/.husky/pre-push +1 -1
  6. package/.prettierignore +2 -1
  7. package/AGENTS.md +69 -59
  8. package/AI_PROMPT_SOURCE.md +69 -59
  9. package/CHANGELOG.md +279 -5
  10. package/CLAUDE.md +69 -59
  11. package/GEMINI.md +69 -59
  12. package/README.md +11 -12
  13. package/package.json +1 -1
  14. package/scripts/auto-version.js +1 -0
  15. package/scripts/branch-auto-npm-publish.js +9 -2
  16. package/src/api/account.js +0 -1
  17. package/src/api/activity.js +0 -37
  18. package/src/api/auth.js +0 -31
  19. package/src/api/game.js +0 -10
  20. package/src/api/payment.js +1 -52
  21. package/src/api/user.js +0 -16
  22. package/src/index.js +2 -2
  23. package/src/machine/activity/activity_cash.js +12 -0
  24. package/src/machine/activity/diamond_shop_activity_cash.js +0 -1
  25. package/src/machine/activity/fafafa_activity.js +0 -10
  26. package/src/machine/activity/index.js +0 -12
  27. package/src/machine/auth.js +37 -59
  28. package/src/machine/auth_otp_v3.js +30 -19
  29. package/src/machine/common.js +0 -55
  30. package/src/machine/deposit/index.js +0 -28
  31. package/src/machine/deposit/manual_cash.js +0 -8
  32. package/src/machine/game_info.js +1 -12
  33. package/src/machine/game_v2_1.js +1 -89
  34. package/src/machine/honor_board_cash.js +15 -18
  35. package/src/machine/inbox.js +0 -12
  36. package/src/machine/index.js +0 -32
  37. package/src/machine/reward_cash.js +0 -39
  38. package/src/machine/user_reset_password.js +0 -13
  39. package/src/machine/user_sign_up.js +3 -0
  40. package/src/machine/websocket.js +0 -4
  41. package/src/machine/withdraw/index.js +0 -6
  42. package/src/request/request.js +0 -28
  43. package/src/util/constant.js +0 -1
  44. package/src/util/index.js +1 -4
  45. package/test/auth_otp_v3.test.js +192 -0
  46. package/src/machine/activity/activity.js +0 -209
  47. package/src/machine/activity/diamond_shop_activity_fc.js +0 -196
  48. package/src/machine/activity/diamond_shop_activity_vn.js +0 -178
  49. package/src/machine/activity/invite_friends_activity.js +0 -114
  50. package/src/machine/activity/mini_game_activity.js +0 -68
  51. package/src/machine/activity/return_bonus_activity.js +0 -153
  52. package/src/machine/auth_otp_v2.js +0 -177
  53. package/src/machine/bank_binding_amb.js +0 -146
  54. package/src/machine/bonus.js +0 -76
  55. package/src/machine/deposit/amb.js +0 -93
  56. package/src/machine/deposit/crypto_bank.js +0 -330
  57. package/src/machine/deposit/crypto_qrcode.js +0 -148
  58. package/src/machine/deposit/crypto_way.js +0 -252
  59. package/src/machine/deposit/deposit_fc.js +0 -272
  60. package/src/machine/deposit/direct.js +0 -310
  61. package/src/machine/deposit/float.js +0 -375
  62. package/src/machine/deposit/krway.js +0 -151
  63. package/src/machine/deposit/loadcard_vn.js +0 -351
  64. package/src/machine/deposit/manual_vn.js +0 -458
  65. package/src/machine/deposit/qrcode_v2.js +0 -338
  66. package/src/machine/deposit/usdt.js +0 -144
  67. package/src/machine/deposit/virtual_bank_vn.js +0 -269
  68. package/src/machine/deposit/vpay.js +0 -368
  69. package/src/machine/game_hot_new.js +0 -79
  70. package/src/machine/game_replay.js +0 -46
  71. package/src/machine/game_search_v2.js +0 -401
  72. package/src/machine/honor_board.js +0 -132
  73. package/src/machine/merge.js +0 -57
  74. package/src/machine/payment_data.js +0 -86
  75. package/src/machine/promotions.js +0 -170
  76. package/src/machine/reward.js +0 -255
  77. package/src/machine/reward_fc.js +0 -98
  78. package/src/machine/side.js +0 -154
  79. package/src/machine/side_v2.js +0 -211
  80. package/src/machine/vip_table.js +0 -57
  81. package/src/machine/welcome.js +0 -110
  82. package/src/machine/withdraw/withdraw_crypto_cash.js +0 -327
  83. package/src/machine/withdraw/withdraw_krway.js +0 -223
  84. package/src/machine/withdraw/withdraw_manual.js +0 -536
  85. package/src/util/math.js +0 -4
@@ -6,9 +6,96 @@
6
6
 
7
7
  ---
8
8
 
9
+ ## Step 0 — 分析專案並更新 AI_PROMPT_SOURCE.md
10
+
11
+ 在同步之前,先掃描專案的實際狀態,確保 `AI_PROMPT_SOURCE.md` 中的數據與程式碼一致。
12
+
13
+ ### Part A — 數據校準
14
+
15
+ 驗證並更新文件中的統計數據,確保與程式碼一致:
16
+
17
+ 1. **版本號**:讀取 `package.json` 的 `version` 欄位,更新文件中的版本號
18
+ 2. **檔案數量統計**:
19
+ - `src/` 下的 `.js` 檔案總數
20
+ - `src/api/` 檔案數
21
+ - `src/machine/` 檔案總數(含子目錄),以及狀態機數量(= 總數 - index 檔案數)
22
+ - `src/machine/activity/`、`src/machine/deposit/`、`src/machine/withdraw/` 各自檔案數
23
+ - `src/util/` 檔案數
24
+ 3. **API 函式數量**:對每個 `src/api/*.js` 模組,計算 `=>` 的出現次數以統計函式數
25
+ 4. **行數驗證**:驗證以下檔案的實際行數:
26
+ - `src/request/request.js`、`src/request/config.js`
27
+ - 所有超過 300 行的狀態機檔案(用於「大型狀態機檔案」表格)
28
+ 5. **supportVersion2List 端點數**:計算 `request.js` 中 `supportVersion2List` 陣列的實際項目數
29
+ 6. **specifyingPath 映射數**:計算 `_convertUrlToKebabCase` 中 `specifyingPath` 的 key 數量
30
+ 7. **關鍵行號參照**:驗證文件中引用的行號(如 `request.js:207`、`request.js:254` 等)是否仍然正確,若偏移則更新
31
+ 8. **依賴套件版本**:讀取 `package.json` 的 `dependencies`,更新版本號
32
+
33
+ ### Part B — Know-How 與架構驗證
34
+
35
+ 檢查 `1.7 核心業務流程與關鍵 Know-How` 章節的內容是否仍然反映程式碼的實際行為:
36
+
37
+ 1. **認證流程**:讀取 `src/machine/auth.js`,驗證:
38
+
39
+ - Token TTL、輪詢間隔、延展機制是否有變
40
+ - inline vs login 狀態判斷邏輯(`rank >= 0`)是否有變
41
+ - 登入方式是否有新增或移除(檢查全域 `on:` 事件列表)
42
+ - OTP 流程是否有調整
43
+
44
+ 2. **存款流程**:抽樣讀取 2-3 個 deposit 狀態機,驗證:
45
+
46
+ - canonical 流程(loading → promotion → loaded → debouncing → calculating → submitting → submitted)是否有變
47
+ - Cash vs Non-Cash 變體的差異描述是否仍然正確
48
+ - 是否有新增的存款類型或支付方式
49
+
50
+ 3. **提款流程**:讀取 `src/machine/withdraw/withdraw_manual.js`,驗證:
51
+
52
+ - 五步驟資格驗證鏈是否有調整
53
+ - OTP 平行狀態是否有變
54
+
55
+ 4. **WebSocket**:讀取 `src/machine/websocket.js`,驗證:
56
+
57
+ - 連線參數、重連策略是否有變
58
+ - 事件轉發映射表是否有新增事件
59
+
60
+ 5. **Error Machine**:讀取 `src/machine/error.js`,驗證:
61
+
62
+ - 錯誤代碼分類是否有新增
63
+ - 路由邏輯是否有調整
64
+
65
+ 6. **Common Machine**:讀取 `src/machine/common.js`,驗證:
66
+
67
+ - 4 個平行子機器的結構是否有變
68
+ - siteConfig 解碼方式是否有變
69
+
70
+ 7. **API 請求生命週期**:讀取 `src/request/request.js`,驗證:
71
+
72
+ - 攔截器邏輯、V2 轉換流程是否有變
73
+ - isBlocked 維護模式機制是否有變
74
+
75
+ 8. **新增狀態機**:比對 `src/machine/` 目錄與文件中的狀態機分類表,若有新增檔案:
76
+ - 判斷歸類(核心/存款/提款/活動/遊戲/使用者/UI)
77
+ - 更新分類表中的數量與代表檔案
78
+
79
+ ### Part C — Clean Code 規範驗證
80
+
81
+ 檢查「二、程式碼品質標準」中列出的問題是否已修正:
82
+
83
+ 1. **已修正的問題**:若問題已被修正(如 HTTP 方法大小寫已統一),將該項標記為已修正或移除
84
+ 2. **新增的問題**:若發現新的程式碼品質問題,添加到對應章節
85
+
86
+ ### 執行方式
87
+
88
+ - 使用 shell 指令(`wc -l`、`grep -c`、`find` 等)取得實際數據
89
+ - 使用 Agent subagent 平行分析多個核心檔案
90
+ - 將每項差異直接修正到 `AI_PROMPT_SOURCE.md` 中
91
+ - 若無差異則跳過,不做無意義修改
92
+ - 完成後簡短回報哪些項目有更新
93
+
94
+ ---
95
+
9
96
  ## Step 1 — 讀取來源檔
10
97
 
11
- 讀取 `AI_PROMPT_SOURCE.md` 完整內容。
98
+ 讀取 `AI_PROMPT_SOURCE.md` 完整內容(此時已是 Step 0 更新後的最新版本)。
12
99
 
13
100
  ---
14
101
 
@@ -17,7 +17,9 @@
17
17
  "mcp__sentry__get_issue_details",
18
18
  "mcp__sentry__search_issues",
19
19
  "Bash(git add:*)",
20
- "Bash(git commit:*)"
20
+ "Bash(git commit:*)",
21
+ "Bash(git branch:*)",
22
+ "Bash(git merge:*)"
21
23
  ]
22
24
  }
23
25
  }
@@ -55,7 +55,7 @@ Before delivering any code change, verify each of the following yourself:
55
55
  - [ ] **Follows existing conventions**: clear four-layer separation, XState v4 factory pattern (`export default function (request) { return createMachine(...) }`), naming conventions, no TypeScript
56
56
  - [ ] **Correct API descriptor object**: returns the `{ url, method, params?, isPublic?, headers?, isFormData?, silent? }` structure; HTTP method consistently lowercase; `isPublic: true` endpoints checked for whether they need `appSecret`; URLs carry no leading slash (unless deliberately bypassing `url-join`'s `baseURL`, in which case comment the reason)
57
57
  - [ ] **V1→V2 path conversion**: new V2 endpoints must be added to `supportVersion2List` **manually**; use the `:param` form for dynamic parameters; put non-standard paths in the `specifyingPath` mapping
58
- - [ ] **State machine conventions**: always modify context via `assign()`, never mutate directly; clone deep objects with `JSON.parse(JSON.stringify())`; choose the initial state name by semantics; don't let `onError` silently fall back to `idle` and lose the error information
58
+ - [ ] **State machine conventions**: always modify context via `assign()`, never mutate directly; clone deep objects with `JSON.parse(JSON.stringify())`; choose the initial state name by semantics; don't let `onError` silently fall back to `idle` and lose the error information; validate response shapes inside the service and reject there — never throw inside `assign()`
59
59
  - [ ] **Memory safety**: `setInterval` / `socket.on()` / `addEventListener` registered inside an XState callback service **must return a cleanup function** (e.g. `() => clientSocket.off(event, handler)`) to avoid accumulating listeners across reconnects; listeners registered inside a Promise must also be cleaned up after resolve / reject
60
60
  - [ ] **Token lifecycle**: token operations go through `getToken()` and the `extendToken` action, never bypass the interceptor to inject manually; prefer the existing TTL constants; when `fetchUserInfo` fails, let the session terminate naturally rather than retrying on your own
61
61
  - [ ] **Error handling**: forward through `request.errorHandler` to the error machine, with correct branches for each special code (see "Error Code System")
@@ -99,7 +99,9 @@ state machine service → request.send(api.xxx(params)) → Request class → AP
99
99
  | Request | `src/request/` | Token injection, V1→V2 path conversion, maintenance-mode detection, custom serialization, request cancellation |
100
100
  | API | `src/api/` | Each function returns a **request descriptor object** (it does not send the request) |
101
101
  | Machine | `src/machine/` | XState v4 state machines, factory pattern receiving `request` |
102
- | Util | `src/util/` | storage (with `maxAge` TTL), deviceToken, constant, math |
102
+ | Util | `src/util/` | storage (with `maxAge` TTL), constant, err998SentryExtra |
103
+
104
+ > **deviceToken does not live in this package**: `auth.js` / `user_sign_up.js` obtain the device token by calling `request.config.getDt?.()` — the implementation is injected by the downstream frontend when it constructs `request`; this package only calls it. Whether it is called is decided by `siteConfig.dtVerify` (login flow) or the `deviceTokenEnable` context (registration flow); when nothing is injected, `?.()` returns `undefined` instead of throwing.
103
105
 
104
106
  **API descriptor object structure**:
105
107
 
@@ -179,16 +181,13 @@ Token 5min TTL → fetchUserInfo success → extendToken resets TTL → poll aga
179
181
 
180
182
  **Polling interval**: base `tick: 2000ms`, **multiplied by 5 while in a game** (becoming 10 seconds) to reduce server load during play.
181
183
 
182
- **Login method routing** (7 kinds):
184
+ **Login method routing** (5 kinds; `LOGIN_TOKEN` additionally follows the token recovery path described above):
183
185
 
184
186
  | Event | Method | Special Handling |
185
187
  | ---------------- | -------------------- | --------------------------------------------------------------- |
186
188
  | `LOGIN_ID` | Account + password | reCAPTCHA header |
187
189
  | `LOGIN_PHONE` | Phone number | reCAPTCHA header + country code |
188
190
  | `LOGIN_EMAIL` | Email | reCAPTCHA header |
189
- | `LOGIN_LOCAL` | Local account | Additionally stores `cuora_tempuser` (24h TTL) |
190
- | `LOGIN_GUEST` | Guest | No auth credentials |
191
- | `LOGIN_APP` | OAuth App | provider + accessToken |
192
191
  | `LOGIN_TELEGRAM` | Telegram | additionalUserInfo |
193
192
  | `LOGIN_3PARTY` | Third-party redirect | **Does not switch state**; uses `window.location.href` directly |
194
193
 
@@ -198,33 +197,33 @@ Token 5min TTL → fetchUserInfo success → extendToken resets TTL → poll aga
198
197
 
199
198
  ### 2.2 Canonical Deposit Pattern
200
199
 
201
- All deposit state machines follow a unified core flow, with variants per payment method:
200
+ Every machine currently under `src/machine/deposit/` is cash-site specific (`*_cash.js`); **the Non-Cash versions no longer live in this package**. All deposit state machines follow a unified core flow, with variants per payment method:
202
201
 
203
202
  ```
204
- loading (fetch siteConfig + bankList in parallel)
205
- → promotion (routing: has a minimum deposit → calculating, none → loaded)
206
- → loaded (user selects bank/amount)
207
- → debouncing (CALCULATE event, 1000ms debounce)
208
- → calculating (calls getDepositExpectedResult)
209
- → loaded/calculated (show the calculation result)
210
- → submitting → submitted
203
+ loading (always + setInitData: takes paymentDetail from the factory context parameter and filters this category's payment methods)
204
+ → checking (invoke to fetch secondary data such as bank/network lists)
205
+ → debouncing (entry clears calculation, after 1000ms debounce)
206
+ → calculating (calls getDepositExpectedResult) → calculated (shows the calculation result)
207
+ → loaded (the resting state when calculation isn't possible, waiting for the user to complete the options)
208
+ → submitting → submitted
211
209
  ```
212
210
 
213
- **Cash vs Non-Cash variants**:
211
+ **Structural traits shared by the Cash machines** (differing from ordinary state machines — easy to trip on):
212
+
213
+ | Aspect | Convention |
214
+ | ------------- | ----------------------------------------------------------------------------------------------------------------- |
215
+ | Constructor | `(request, context) => createMachine()` — initial data is **preloaded by the caller**, not fetched by the machine |
216
+ | loading phase | `always` transitions immediately, with no async request |
217
+ | Global events | `internal: false` (forces external transitions, ensuring entry/exit re-run) |
218
+ | Debounce | `debouncing` uses `after: { 1000 }` + `cond`, not a separate CALCULATE event |
214
219
 
215
- | Aspect | Non-Cash (e.g. `direct.js`) | Cash (e.g. `direct_cash.js`) |
216
- | ------------- | ---------------------------------------- | ----------------------------------------------- |
217
- | Constructor | `(request) => createMachine()` | `(request, context) => createMachine()` |
218
- | Initial data | Fetched asynchronously (init → fetching) | Preloaded via the context parameter |
219
- | loading phase | Two sub-states (init + fetching) | `always` jumps straight to checking |
220
- | Global events | `internal: true` (default) | `internal: false` (forces external transitions) |
221
- | Bank list | Re-fetched every time | `bankMap` cache (keyed by method) |
220
+ **Promotion**: the `SET_PROMOTION` global event sets the promotion context; most machines pair it with an `isPromotionChanged` guard to avoid re-running on an identical value. `direct_cash.js` additionally has `bankMap`, caching bank lists keyed by method.
222
221
 
223
- **Promotion & Bonus preview**: the `SET_PROMOTION` global event sets the promotion context; if `siteConfig.bonusPreviewEnable === true` and `promotion.activityNo !== 'none'`, `getBonusPreview` is additionally called.
222
+ > ⚠️ **`promotionsNo` vs `activityNo` (easy to trip on)**: the **deposit** flow's promotion always uses `promotion?.promotionsNo` (all 7 deposit machines and `api/payment.js` do); the **activity system** uses `activityNo`. They are different fields and are not interchangeable.
224
223
 
225
- > ⚠️ **Naming inconsistency (easy to trip on)**: Non-Cash uses `promotion?.activityNo`, Cash uses `promotion?.promotionsNo`.
224
+ > ℹ️ `getBonusPreview` in `api/payment.js` (whose parameter is `promotionsNo`) currently has **no machine calling it**, and `siteConfig.bonusPreviewEnable` is no longer referenced anywhere in this package. Wiring bonus preview back up has to be done by hand.
226
225
 
227
- **resultMap cache** (`usdt.js`, `usdt_cash.js`): caches keyed by `selectedNetwork.value` to avoid re-fetching the same network address.
226
+ **resultMap cache** (`usdt_cash.js`): caches keyed by `selectedNetwork.value` to avoid re-fetching the same network address.
228
227
 
229
228
  > ⚠️ **V2 API response format is inconsistent**: the same endpoint may return `{ data: {...} }` or just `{...}`, so every machine needs defensive handling:
230
229
  >
@@ -234,27 +233,39 @@ loading (fetch siteConfig + bankList in parallel)
234
233
  > return { calculation: data || event.data }
235
234
  > })
236
235
  > ```
236
+ >
237
+ > This pattern assumes `event.data` is always an object; `send()` may resolve `undefined`, and destructuring it inside an assign throws and stalls the machine (see item 13 of 2.9).
237
238
 
238
- **processing state check**: `crypto_bank.js` and `manual_cash.js` check at initialization whether there is an in-progress deposit order, and if so jump straight to `submitted` to prevent duplicate submission.
239
+ **processing state check**: `manual_cash.js` and `virtual_bank_cash.js` use an `isProcessing` guard to check whether there is an in-progress deposit order, and if so jump straight to `submitted` to prevent duplicate submission.
239
240
 
240
241
  ### 2.3 Withdrawal Flow & OTP
241
242
 
242
- **Five-step eligibility validation chain** (`withdraw_manual.js`); failing any step transitions to the corresponding blocking state:
243
+ `src/machine/withdraw/` contains only one machine, `withdraw_manual_cash.js`. Main flow:
243
244
 
244
245
  ```
245
- 1. haveProcessing → is there a withdrawal in progress? (yes → inProcessing)
246
- 2. isBankNotBound → is a bank account bound? (no → unbound)
247
- 3. isNotWithdrawMinDepositAmount → is the minimum deposit threshold met?
248
- 4. isPassWithdrawCooldownTime → still within the cooldown?
249
- 5. isNotWIthdrawServiceTime → within the service window?
250
- All passed → withdrawable
246
+ loading (fetchInitData: double-wallet rule gate + getBindingPaymentInfo + getPendingOrder)
247
+ → checking (always: isProcessing → submitted, otherwise loaded)
248
+ → loaded ──SET_AMOUNT──▶ debouncing (always: isSubmittable → calculated, otherwise back to loaded)
249
+ → calculated → submitting / submitting_crypto
250
+ → isOtpRequired → otp (parallel state)
251
+ → otherwise → submitted
251
252
  ```
252
253
 
253
- **OTP parallel states**: after a withdrawal is submitted, if the response contains `request_id` plus `number`/`email`, it enters OTP verification. `countdown` (decrementing the TTL each second) and `verification` (`idle → acknowledging → submitted`) run **in parallel**, so the countdown does not block verification actions.
254
+ There are only 4 guards: `hasNoBank` (`REFRESH` only reloads when no account is bound), `isProcessing`, `isSubmittable` (amount > 0 and within `currentPayment.minimum`–`maximum`), and `isOtpRequired`. `userBanks` is `bankList` + `ewalletList` + `cryptoList` flattened together, with the first entry selected by default.
255
+
256
+ **Double-wallet withdrawal rule gate** (`doubleWalletWithdrawLimitCheck` — the least intuitive part; the point is to save API calls):
257
+
258
+ | Value | Behavior |
259
+ | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
260
+ | `'0'` | Fetch only the CASH `withdrawRule` |
261
+ | `'1'` | Fetch only the ACTIVITY `withdrawRule`; regardless of whether it qualifies, the CASH rule takes no part in the gate |
262
+ | `'2'` | Fetch ACTIVITY first; if **not withdrawable**, adopt it directly (skipping CASH); only when it **qualifies** does it go on to fetch CASH as the basis |
263
+
264
+ `enableWithdraw` deliberately uses a truthy comparison (`!activityRule?.enableWithdraw`) to align with client-pwa-ssr, avoiding misjudgment when the backend returns a non-boolean truthy value such as `1`.
254
265
 
255
- **Withdrawal rules system**: the `withdrawRules` array is matched against the balance, using `findLastIndex` to find the **last** matching rule (the highest amount tier), which determines `maxWithdrawAmount`.
266
+ **OTP parallel states**: `isOtpRequired` **only looks at whether the response contains `request_id`** (`number` / `email` are used purely for display). Once entered, the `countdown` and `verification` sub-states run **in parallel**, so the countdown does not block verification actions. Within `verification`, `idle` can branch to `acknowledging` (on success, exits OTP to the top-level `submitted`) or `reset` (resend; on success, returns to `idle` with a new `requestId`/`ttl`); the `BACK` event returns directly to the top-level `calculated`. `ttl` is in **milliseconds**, and `decreaseTtl` applies `Math.max(ttl - 1000, 0)` every second.
256
267
 
257
- **Attachment types**: `withdraw` (normal withdrawal) vs `pool` (bonus / free-credit redemption, which calls the `restore` API).
268
+ > ℹ️ `restore` in `api/payment.js` (bonus / free-credit redemption) currently has **no machine calling it**.
258
269
 
259
270
  ### 2.4 Game Management
260
271
 
@@ -270,11 +281,11 @@ loading (fetch siteConfig + bankList in parallel)
270
281
 
271
282
  **receiveStatus enum**: `0` in progress / not yet eligible (→ `progress_status`), `1` claimed (→ `received`, terminal), `2` claimable (→ `receiveable`).
272
283
 
273
- **Red-dot unread state**:
284
+ **Red-dot unread state** (`activity_cash.js`):
274
285
 
275
- - `noRedActivity = [2, 4, 13, 20, 90, 91, 92]` — these activity types **never show a red dot**
276
- - For other activities the read state is stored in localStorage under the key `unread_${activityNo}_${uidSite}`
286
+ - The read state is stored in localStorage under the key `unread_${activityNo}_${uidSite}`; **when the key is absent, `unread` defaults to `true`** (a new activity always shows a red dot)
277
287
  - Whenever `activityList` is updated, **clone the whole array** to avoid direct mutation
288
+ - The old `noRedActivity` type allowlist **no longer exists**; today every activity type is treated the same
278
289
 
279
290
  **Activity polling**: base interval `tick * 10 = 20 seconds`; **polling pauses while in a game (`isPlaying === true`)**. Fetching promotions additionally requires `hasToken`.
280
291
 
@@ -306,10 +317,9 @@ io(`${socketURL}/frontend`, {
306
317
 
307
318
  ### 2.7 Configuration & Live Info (Common Machine)
308
319
 
309
- **4 parallel sub-machines**: `config` (siteConfig + layoutConfig, event-triggered), `feed` (feeds + mailbox + promotions, 20-second polling), `getAnnouncements` (event-triggered), and `broadcast` (switching every 5 seconds).
320
+ **3 parallel sub-machines**: `config` (siteConfig + layoutConfig, event-triggered), `feed` (feeds + mailbox + promotions, 20-second polling), and `getAnnouncements` (event-triggered).
310
321
 
311
322
  - **siteConfig decoding**: the response is an encoded string; the `setConfig` action base64-decodes it to obtain the actual configuration (`loginMethods`, `paymentMethods`, `csChat`, etc.). **The downstream frontends' stores do not decode it a second time.**
312
- - **Broadcast rotation**: `picking` (5s) → `display` (5s) → `picking`, selecting `type === '0'` entries from `broadcastList`; already-shown items are added to `sentNormalBroadcastList` and not repeated
313
323
  - **Mailbox filtering**: if `customerMessageEnable === false`, the count of CUSTOMER-type messages is deducted from the mailbox total
314
324
 
315
325
  ### 2.8 API Request Lifecycle
@@ -348,6 +358,7 @@ io(`${socketURL}/frontend`, {
348
358
  10. **`isMobile` is a string, not a boolean**: in `common.js`, `isMobile = userAgent?.device?.type` returns `'mobile'`/`'tablet'`/`undefined`, so comparisons must be string-based (e.g. `isMobile === 'mobile' ? 'y' : null`).
349
359
  11. **Requests carry no CancelToken by default**: the cancellation feature of `send(req, customToken)` is **opt-in**. In axios <0.22 the cancel handler is never unsubscribed — a shared long-lived token accumulates one handler per request, causing overnight OOM when left running (TI-15555). **Do not "helpfully" add the CancelToken back onto the shared path.**
350
360
  12. **`silent: true` only skips errorHandler**: the error is still thrown to the caller's `onError`, and `ERR_F108` is still routed as usual; but every other error code — **including logout-class codes such as `ERR_A104`, and `ERR_G106` insufficient balance** — never reaches the error machine. Use it only for background requests whose session invalidation is already covered by `fetchUserInfo` polling; never add it to user-initiated requests.
361
+ 13. **`send()` does not guarantee an object, and `assign()` must never throw**: non-config requests during maintenance (`isBlocked`) and `ERR_800` cancellations make `send()` **resolve `undefined`** (they never reach `onError`); a 200 response with a non-JSON body resolves a string, so destructuring `{ data }` yields `undefined`. When an `assign()` throws, XState v4 clears the event queue and the state is not updated — the machine stays in the current invoke state and `after`-based polling stops until an external event (e.g. `REFRESH`) moves it out. **Validate response shapes inside the service and `throw` there (reject → `onError`)**; every assign in `onDone` must handle every value the service can resolve, including deliberate `return null` early exits.
351
362
 
352
363
  ---
353
364
 
@@ -355,19 +366,19 @@ io(`${socketURL}/frontend`, {
355
366
 
356
367
  > Every item below exists in the code in **two competing forms** — exploring the code cannot tell you which one is the standard, so it must be written down explicitly. New code always follows the "Target" column; existing code is not proactively refactored en masse (scope discipline).
357
368
 
358
- | Item | Current state | Target |
359
- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
360
- | HTTP method casing | `'GET'` and `'get'` coexist (`request.js` calls `toUpperCase()` internally, so behavior is unaffected) | Consistently lowercase `'get'`/`'post'`/`'put'`/`'delete'` |
361
- | Import paths | Some files self-reference via the `@jetthai/cuora` package name | Consistently relative paths (`'../../api/payment.js'`) |
362
- | lodash extension | `'lodash/pickBy.js'` and `'lodash/pickBy'` coexist | Consistently **without** the extension |
363
- | URL leading slash | A few APIs carry a leading slash | Omit it (unless deliberately bypassing `url-join`, in which case comment the reason) |
364
- | Query parameter placement | A few write them straight into the URL (`register?${qs}`, `mail?include=cl`), bypassing serialization | Always use the `params` field |
365
- | Initial state naming | `idle` / `loading` / `fetching` / `init` / `preparing` are used interchangeably | By semantics: `idle` (awaiting action), `loading` (initial load), `fetching` (re-fetch), `submitting` / `submitted` |
366
- | Magic numbers and strings | Activity type IDs, error codes, TTLs, polling ticks, `'DEPOSIT'`/`'WITHDRAW'`, `receiveStatus`, `connectStatus` are scattered around | Centralize in `util/constant.js` (`ERROR_CODES` / `TTL` / `INTERVAL` / `TRANSFER_TYPE` / `RECEIVE_STATUS`) |
367
- | Error handling | Three forms coexist: silent fallback to `idle` (most common, loses error info), transition to `fail`, infinite retry | `onError` with `actions: 'setError'` to preserve the error in context; distinguish recoverable from unrecoverable; retries must have a cap |
368
- | Parameter naming | e.g. `addFavoriteGame(code)` is semantically unclear | Concrete names (`gameCode`) |
369
- | Parameter validation | The API layer has no validation at all (e.g. `makeTransaction({ paymentMethod })` injects straight into the URL) | Validate at the system boundary: path parameters non-undefined and free of path-traversal characters, amounts positive |
370
- | Deprecated APIs | In `api/user.js`, V1 `passwordRecovery` coexists with the V2 `passwordV2*` family, with V1 unmarked | Add `@deprecated` first, then remove once confirmed unreferenced |
369
+ | Item | Current state | Target |
370
+ | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
371
+ | HTTP method casing | `'GET'` and `'get'` coexist (`request.js` calls `toUpperCase()` internally, so behavior is unaffected) | Consistently lowercase `'get'`/`'post'`/`'put'`/`'delete'` |
372
+ | Import paths | Some files self-reference via the `@jetthai/cuora` package name | Consistently relative paths (`'../../api/payment.js'`) |
373
+ | lodash extension | `'lodash/pickBy.js'` and `'lodash/pickBy'` coexist | Consistently **without** the extension |
374
+ | URL leading slash | A few APIs carry a leading slash | Omit it (unless deliberately bypassing `url-join`, in which case comment the reason) |
375
+ | Query parameter placement | A few write them straight into the URL (`register?${qs}`, `mail?include=cl`), bypassing serialization | Always use the `params` field |
376
+ | Initial state naming | `idle`(27) / `loading`(13) / `fetching`(12) / `pending`(6) / `checking` / `init` and others used interchangeably | By semantics: `idle` (awaiting action), `loading` (initial load), `fetching` (re-fetch), `submitting` / `submitted` |
377
+ | Magic numbers and strings | Activity type IDs, error codes, TTLs, polling ticks, `'DEPOSIT'`/`'WITHDRAW'`, `receiveStatus`, `connectStatus` are scattered around; `util/constant.js` currently holds **only** `GAME_SEARCH` / `GAME_TYPE_LIST`, two game-category constants | Centralize in `util/constant.js` (`ERROR_CODES` / `TTL` / `INTERVAL` / `TRANSFER_TYPE` / `RECEIVE_STATUS`) |
378
+ | Error handling | Three forms coexist: silent fallback to `idle` (most common, loses error info), transition to `fail`, infinite retry | `onError` with `actions: 'setError'` to preserve the error in context; distinguish recoverable from unrecoverable; retries must have a cap |
379
+ | Parameter naming | e.g. `getFreeGameReward(code)` is semantically unclear | Concrete names (`gameCode`) |
380
+ | Parameter validation | The API layer has no validation at all (e.g. the dynamic path following `checkDt()` is injected straight into the URL) | Validate at the system boundary: path parameters non-undefined and free of path-traversal characters, amounts positive |
381
+ | Deprecated APIs | `getPaymentInfo` in `api/payment.js` carries a "deprecated" comment but still has callers | Add `@deprecated` first, then remove once confirmed unreferenced |
371
382
 
372
383
  ---
373
384
 
@@ -379,12 +390,11 @@ io(`${socketURL}/frontend`, {
379
390
  - **No request caching** — high-frequency endpoints (`fetchUserInfo` every 2–10 seconds, `getConfig` on every state machine initialization, `getPaymentDetail` on every entry to a deposit/withdrawal page, `getActivityList` every 20 seconds) all hit the server directly. Consider TTL caching or `stale-while-revalidate`.
380
391
  - **No rate limiting or backoff** — polling runs at a fixed interval and does not change on errors. Consider exponential backoff on errors.
381
392
  - **No automatic token refresh** — the response interceptor in `request.js` does not handle 401, so an expired token simply fails.
382
- - **FingerprintJS bundling** — the FingerprintJS embedded in `src/lib/` is loaded at module initialization even when disabled. Consider switching to a dynamic `import()` for lazy loading.
383
393
  - **No code splitting** — `machine/index.js` eagerly imports every state machine + the APIs + Socket.IO + lodash, so importing `machine` loads everything. Consider supporting individual imports to enable tree-shaking.
384
- - **Timer management** — countdowns are largely implemented with self-referencing `after: { 1000 }` transitions, producing one state transition per second (including a context clone + event dispatch). Consider a callback service + `setInterval`, and **compute elapsed time** rather than decrementing step by step to avoid cumulative drift.
385
- - **Large state machine files** — `game_v2_1.js`, `auth.js`, `withdraw_manual.js`, `inbox.js`, `manual_vn.js`, `common.js`, and `game_search_v2.js` all exceed 300 lines and could be split into composable sub-machines.
394
+ - **Timer management** — countdowns are largely implemented with self-referencing `after: { 1000 }` transitions (e.g. the OTP `countdown` in `withdraw_manual_cash.js`), producing one state transition per second (including a context clone + event dispatch). Consider a callback service + `setInterval`, and **compute elapsed time** rather than decrementing step by step to avoid cumulative drift.
395
+ - **Large state machine files** — `game_v2_1.js`(699), `auth.js`(592), `inbox.js`(489), `common.js`(404), `game_search_cash.js`(401), `manual_cash.js`(370), `websocket.js`(357), `withdraw_manual_cash.js`(324), `auth_otp_v3.js`(307), and `crypto_bank_cash.js`(306) all exceed 300 lines and could be split into composable sub-machines.
386
396
  - **Unused context fields** — several state machines declare context fields that are never assigned or read.
387
- - **lodash can be replaced with natives** — only a handful of functions are actually used; `padStart` / `toNumber` can be swapped for natives directly, and `findLastIndex` is supported in modern browsers.
397
+ - **lodash exists for only two functions** — the whole repo has just 5 imports: `pickBy` (`request/request.js`, `api/auth.js`, `machine/auth.js`, `machine/common.js`) and `isEqual` (`activity/fafafa_activity.js`), yet the entire package is listed as a dependency. Both can be replaced with native implementations to drop the dependency; until then, at least unify the extension convention (see "Style Convergence Targets").
388
398
 
389
399
  ---
390
400
 
@@ -19,14 +19,14 @@ if [ "$match" = "1" ]; then
19
19
  # 檢查本地是否有尚未推送的 commit,有的話跳過自動拉取(避免覆蓋本地變更)
20
20
  LOCAL_AHEAD=$(git rev-list --count origin/"$CURRENT_BRANCH"..HEAD 2>/dev/null || echo 0)
21
21
  if [ "$LOCAL_AHEAD" -gt 0 ]; then
22
- echo "分支 '$CURRENT_BRANCH' 有 $LOCAL_AHEAD 個尚未推送的 commit,略過自動拉取。"
22
+ echo "You have $LOCAL_AHEAD unpushed commit(s) on '$CURRENT_BRANCH'. Skipping auto-pull."
23
23
  exit 0
24
24
  fi
25
25
 
26
26
  # 自動從遠端拉取最新程式碼(使用 rebase 保持線性歷史)
27
- echo "正在從遠端自動拉取 '$CURRENT_BRANCH'..."
27
+ echo "Auto pulling '$CURRENT_BRANCH' from remote..."
28
28
  git pull --rebase origin "$CURRENT_BRANCH" || {
29
- echo "拉取 '$CURRENT_BRANCH' 失敗,請手動處理。"
29
+ echo "Failed to pull '$CURRENT_BRANCH'. Please resolve manually."
30
30
  exit 1
31
31
  }
32
32
  fi
package/.husky/pre-push CHANGED
@@ -21,7 +21,7 @@ BRANCH=$(git rev-parse --abbrev-ref HEAD)
21
21
 
22
22
  # 在 dev/qa 分支的 force push 跳過所有 pre-push hook(避免干擾強制推送)
23
23
  if [ "$IS_FORCE" = true ] && { [ "$BRANCH" = "dev" ] || [ "$BRANCH" = "qa" ]; }; then
24
- echo "偵測到在 $BRANCH 分支上強制推送,略過 pre-push hooks。"
24
+ echo "Force push detected on $BRANCH, skipping pre-push hooks."
25
25
  exit 0
26
26
  fi
27
27
 
package/.prettierignore CHANGED
@@ -1 +1,2 @@
1
- dist/
1
+ dist/
2
+ CHANGELOG.md