@jetthai/cuora 1.1.478 → 1.1.480

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 (74) hide show
  1. package/.github/copilot-instructions.md +64 -57
  2. package/AGENTS.md +64 -57
  3. package/AI_PROMPT_SOURCE.md +64 -57
  4. package/CHANGELOG.md +26 -0
  5. package/CLAUDE.md +64 -57
  6. package/GEMINI.md +64 -57
  7. package/README.md +11 -12
  8. package/package.json +1 -1
  9. package/src/api/account.js +0 -1
  10. package/src/api/activity.js +0 -37
  11. package/src/api/auth.js +0 -31
  12. package/src/api/game.js +0 -10
  13. package/src/api/payment.js +0 -51
  14. package/src/api/user.js +0 -16
  15. package/src/index.js +2 -2
  16. package/src/machine/activity/diamond_shop_activity_cash.js +0 -1
  17. package/src/machine/activity/fafafa_activity.js +0 -10
  18. package/src/machine/activity/index.js +0 -12
  19. package/src/machine/auth.js +1 -60
  20. package/src/machine/auth_otp_v3.js +0 -3
  21. package/src/machine/common.js +0 -55
  22. package/src/machine/deposit/index.js +0 -28
  23. package/src/machine/deposit/manual_cash.js +0 -8
  24. package/src/machine/game_info.js +1 -12
  25. package/src/machine/game_v2_1.js +1 -89
  26. package/src/machine/inbox.js +0 -12
  27. package/src/machine/index.js +0 -32
  28. package/src/machine/reward_cash.js +0 -39
  29. package/src/machine/user_reset_password.js +0 -13
  30. package/src/machine/websocket.js +0 -4
  31. package/src/machine/withdraw/index.js +0 -6
  32. package/src/request/request.js +4 -28
  33. package/src/util/constant.js +0 -1
  34. package/src/util/index.js +1 -4
  35. package/src/machine/activity/activity.js +0 -209
  36. package/src/machine/activity/diamond_shop_activity_fc.js +0 -196
  37. package/src/machine/activity/diamond_shop_activity_vn.js +0 -178
  38. package/src/machine/activity/invite_friends_activity.js +0 -114
  39. package/src/machine/activity/mini_game_activity.js +0 -68
  40. package/src/machine/activity/return_bonus_activity.js +0 -153
  41. package/src/machine/auth_otp_v2.js +0 -177
  42. package/src/machine/bank_binding_amb.js +0 -146
  43. package/src/machine/bonus.js +0 -76
  44. package/src/machine/deposit/amb.js +0 -93
  45. package/src/machine/deposit/crypto_bank.js +0 -330
  46. package/src/machine/deposit/crypto_qrcode.js +0 -148
  47. package/src/machine/deposit/crypto_way.js +0 -252
  48. package/src/machine/deposit/deposit_fc.js +0 -272
  49. package/src/machine/deposit/direct.js +0 -310
  50. package/src/machine/deposit/float.js +0 -375
  51. package/src/machine/deposit/krway.js +0 -151
  52. package/src/machine/deposit/loadcard_vn.js +0 -351
  53. package/src/machine/deposit/manual_vn.js +0 -458
  54. package/src/machine/deposit/qrcode_v2.js +0 -338
  55. package/src/machine/deposit/usdt.js +0 -144
  56. package/src/machine/deposit/virtual_bank_vn.js +0 -269
  57. package/src/machine/deposit/vpay.js +0 -368
  58. package/src/machine/game_hot_new.js +0 -79
  59. package/src/machine/game_replay.js +0 -46
  60. package/src/machine/game_search_v2.js +0 -401
  61. package/src/machine/honor_board.js +0 -132
  62. package/src/machine/merge.js +0 -57
  63. package/src/machine/payment_data.js +0 -86
  64. package/src/machine/promotions.js +0 -170
  65. package/src/machine/reward.js +0 -255
  66. package/src/machine/reward_fc.js +0 -98
  67. package/src/machine/side.js +0 -154
  68. package/src/machine/side_v2.js +0 -211
  69. package/src/machine/vip_table.js +0 -57
  70. package/src/machine/welcome.js +0 -110
  71. package/src/machine/withdraw/withdraw_crypto_cash.js +0 -327
  72. package/src/machine/withdraw/withdraw_krway.js +0 -223
  73. package/src/machine/withdraw/withdraw_manual.js +0 -536
  74. package/src/util/math.js +0 -4
@@ -97,7 +97,9 @@
97
97
  | Request | `src/request/` | Token 注入、V1→V2 路徑轉換、維護模式偵測、自訂序列化、請求取消 |
98
98
  | API | `src/api/` | 每個函式回傳**請求描述物件**(不發請求) |
99
99
  | Machine | `src/machine/` | XState v4 狀態機,工廠模式接收 `request` |
100
- | Util | `src/util/` | storage(含 `maxAge` TTL)、deviceToken、constant、math |
100
+ | Util | `src/util/` | storage(含 `maxAge` TTL)、constant、err998SentryExtra |
101
+
102
+ > **deviceToken 不在本套件內**:`auth.js` / `user_sign_up.js` 取得裝置 Token 的方式是呼叫 `request.config.getDt?.()`——實作由下游前端在建立 `request` 時注入,本套件只負責呼叫。是否呼叫由 `siteConfig.dtVerify`(登入流程)或 `deviceTokenEnable` context(註冊流程)決定,未注入時 `?.()` 回傳 `undefined` 而不拋錯。
101
103
 
102
104
  **API 描述物件結構**:
103
105
 
@@ -177,16 +179,13 @@ Token 5min TTL → fetchUserInfo 成功 → extendToken 重設 TTL → 再次輪
177
179
 
178
180
  **輪詢間隔**:基礎 `tick: 2000ms`,**遊戲中乘以 5**(變 10 秒),減少遊戲期間伺服器負擔。
179
181
 
180
- **登入方式分流**(7 種):
182
+ **登入方式分流**(5 種;另有 `LOGIN_TOKEN` 走上述 Token 恢復路徑):
181
183
 
182
184
  | 事件 | 方式 | 特殊處理 |
183
185
  | ---------------- | ---------- | ------------------------------------------- |
184
186
  | `LOGIN_ID` | 帳號密碼 | reCAPTCHA header |
185
187
  | `LOGIN_PHONE` | 手機號碼 | reCAPTCHA header + 國碼 |
186
188
  | `LOGIN_EMAIL` | Email | reCAPTCHA header |
187
- | `LOGIN_LOCAL` | 本地帳號 | 額外存 `cuora_tempuser`(24h TTL) |
188
- | `LOGIN_GUEST` | 訪客 | 無認證資料 |
189
- | `LOGIN_APP` | OAuth App | provider + accessToken |
190
189
  | `LOGIN_TELEGRAM` | Telegram | additionalUserInfo |
191
190
  | `LOGIN_3PARTY` | 第三方跳轉 | **不切換狀態**,直接 `window.location.href` |
192
191
 
@@ -196,33 +195,33 @@ Token 5min TTL → fetchUserInfo 成功 → extendToken 重設 TTL → 再次輪
196
195
 
197
196
  ### 2.2 存款流程模式(Canonical Deposit Pattern)
198
197
 
199
- 所有存款狀態機遵循統一核心流程,各支付方式有變體:
198
+ `src/machine/deposit/` 現存機器全為 cash 站專用(`*_cash.js`),**Non-Cash 版本已不在本套件內**。所有存款狀態機遵循統一核心流程,各支付方式有變體:
200
199
 
201
200
  ```
202
- loading(平行取得 siteConfig + bankList)
203
- → promotion(路由:有最低存款額 → calculating,無 → loaded)
204
- → loaded(使用者選擇銀行/金額)
205
- → debouncing(CALCULATE 事件,1000ms 防抖)
206
- → calculating(呼叫 getDepositExpectedResult)
207
- → loaded/calculated(顯示計算結果)
208
- → submitting → submitted
201
+ loading(always + setInitData:從工廠 context 參數取出 paymentDetail 過濾出本類別支付方式)
202
+ → checking(invoke 取得銀行/網路清單等次級資料)
203
+ → debouncing(entry 清空 calculation,after 1000ms 防抖)
204
+ → calculating(呼叫 getDepositExpectedResult)→ calculated(顯示計算結果)
205
+ → loaded(不可計算時的停留狀態,等使用者補齊選項)
206
+ → submitting → submitted
209
207
  ```
210
208
 
211
- **Cash vs Non-Cash 變體**:
209
+ **Cash machine 的共同結構特徵**(與一般狀態機不同、易踩之處):
210
+
211
+ | 面向 | 寫法 |
212
+ | ------------ | ------------------------------------------------------------------------------- |
213
+ | 建構子 | `(request, context) => createMachine()`——初始資料由**呼叫端預載入**,不自行抓取 |
214
+ | loading 階段 | `always` 立即跳轉,不做非同步請求 |
215
+ | 全域事件 | `internal: false`(強制外部轉換,確保 entry/exit 重跑) |
216
+ | 防抖 | `debouncing` 用 `after: { 1000 }` + `cond`,不是獨立的 CALCULATE 事件 |
212
217
 
213
- | 面向 | Non-Cash(如 `direct.js`) | Cash(如 `direct_cash.js`) |
214
- | ------------ | ------------------------------ | --------------------------------------- |
215
- | 建構子 | `(request) => createMachine()` | `(request, context) => createMachine()` |
216
- | 初始資料 | 非同步取得(init → fetching) | context 參數預載入 |
217
- | loading 階段 | 兩個子狀態(init + fetching) | `always` 直接跳至 checking |
218
- | 全域事件 | `internal: true`(預設) | `internal: false`(強制外部轉換) |
219
- | 銀行清單 | 每次重新取得 | `bankMap` 快取(依 method 為 key) |
218
+ **Promotion**:`SET_PROMOTION` 全域事件設定 promotion context,多數機器搭配 `isPromotionChanged` guard 避免同值重跑;`direct_cash.js` 另有 `bankMap` 依 method 為 key 快取銀行清單。
220
219
 
221
- **Promotion & Bonus 預覽**:`SET_PROMOTION` 全域事件設定 promotion context;若 `siteConfig.bonusPreviewEnable === true` 且 `promotion.activityNo !== 'none'`,額外呼叫 `getBonusPreview`。
220
+ > ⚠️ **`promotionsNo` vs `activityNo`(易踩)**:**存款**流程的 promotion 一律用 `promotion?.promotionsNo`(7 台 deposit machine 與 `api/payment.js` 皆是);**活動系統**用的則是 `activityNo`。兩者是不同欄位,不可互換。
222
221
 
223
- > ⚠️ **命名不一致(易踩)**:Non-Cash 用 `promotion?.activityNo`,Cash 用 `promotion?.promotionsNo`。
222
+ > ℹ️ `api/payment.js` 的 `getBonusPreview`(參數為 `promotionsNo`)目前**沒有任何 machine 呼叫**,`siteConfig.bonusPreviewEnable` 在本套件內也已無引用。要接回 bonus 預覽需自行接線。
224
223
 
225
- **resultMap 快取**(`usdt.js`、`usdt_cash.js`):以 `selectedNetwork.value` 為 key 快取,避免重複取得同一網路地址。
224
+ **resultMap 快取**(`usdt_cash.js`):以 `selectedNetwork.value` 為 key 快取,避免重複取得同一網路地址。
226
225
 
227
226
  > ⚠️ **V2 API 回應格式不一致**:同一端點可能回傳 `{ data: {...} }` 或直接 `{...}`,所有機器都需防禦性處理:
228
227
  >
@@ -235,26 +234,36 @@ loading(平行取得 siteConfig + bankList)
235
234
  >
236
235
  > 此寫法假設 `event.data` 必為物件;`send()` 可能 resolve `undefined`,在 assign 內解構會拋錯卡死 machine(見 2.9 第 13 點)。
237
236
 
238
- **processing 狀態檢查**:`crypto_bank.js`、`manual_cash.js` 初始化時檢查是否有進行中的存款訂單,有則直接跳至 `submitted`,防止重複提交。
237
+ **processing 狀態檢查**:`manual_cash.js`、`virtual_bank_cash.js` 以 `isProcessing` guard 檢查是否有進行中的存款訂單,有則直接跳至 `submitted`,防止重複提交。
239
238
 
240
239
  ### 2.3 提款流程與 OTP
241
240
 
242
- **五步驟資格驗證鏈**(`withdraw_manual.js`),任一不過就轉到對應的擋下狀態:
241
+ `src/machine/withdraw/` 只有 `withdraw_manual_cash.js` 一台。主流程:
243
242
 
244
243
  ```
245
- 1. haveProcessing → 有進行中的提款?(有 → inProcessing)
246
- 2. isBankNotBound → 已綁定銀行帳戶?(否 → unbound)
247
- 3. isNotWithdrawMinDepositAmount → 達到最低存款門檻?
248
- 4. isPassWithdrawCooldownTime → 在冷卻期?
249
- 5. isNotWIthdrawServiceTime → 在服務時間內?
250
- 全部通過 → withdrawable
244
+ loading(fetchInitData:雙錢包規則閘門 + getBindingPaymentInfo + getPendingOrder)
245
+ → checking(always:isProcessing → submitted,否則 loaded)
246
+ → loaded ──SET_AMOUNT──▶ debouncing(always:isSubmittable → calculated,否則回 loaded)
247
+ → calculated → submitting / submitting_crypto
248
+ → isOtpRequired → otp(平行狀態)
249
+ → 否則 → submitted
251
250
  ```
252
251
 
253
- **OTP 平行狀態**:提款提交後若回應含 `request_id` 及 `number`/`email`,進入 OTP 驗證。`countdown`(每秒遞減 TTL)與 `verification`(`idle → acknowledging → submitted`)**平行運作**,倒數不阻塞驗證操作。
252
+ 只有 4 個 guard:`hasNoBank`(`REFRESH` 僅在無綁定帳戶時才重載)、`isProcessing`、`isSubmittable`(金額 > 0 且落在 `currentPayment.minimum`~`maximum`)、`isOtpRequired`。`userBanks` 是 `bankList` + `ewalletList` + `cryptoList` 三者攤平,預設選第一筆。
253
+
254
+ **雙錢包出款規則閘門**(`doubleWalletWithdrawLimitCheck`,最不直覺的一段,用意是省 API):
255
+
256
+ | 值 | 行為 |
257
+ | ----- | ------------------------------------------------------------------------------ |
258
+ | `'0'` | 只抓 CASH `withdrawRule` |
259
+ | `'1'` | 只抓 ACTIVITY `withdrawRule`,不論達標與否,CASH 規則都不參與閘門 |
260
+ | `'2'` | 先抓 ACTIVITY;**不可提**則直接採用它(略過 CASH),**達標**才續抓 CASH 為依據 |
261
+
262
+ `enableWithdraw` 刻意用 truthy 比較(`!activityRule?.enableWithdraw`)對齊 client-pwa-ssr,避免後端回傳 `1` 這類非布林 truthy 值時誤判。
254
263
 
255
- **提款規則系統**:`withdrawRules` 陣列依餘額匹配,用 `findLastIndex` 找**最後一個**符合條件的規則(最高金額級距)決定 `maxWithdrawAmount`。
264
+ **OTP 平行狀態**:`isOtpRequired` **只看回應是否含 `request_id`**(`number` / `email` 只用於顯示)。進入後 `countdown` 與 `verification` 兩個子狀態**平行運作**,倒數不阻塞驗證操作。`verification` 內 `idle` 可分岔到 `acknowledging`(成功 → 跳出 OTP 到頂層 `submitted`)或 `reset`(重發,成功 → 回 `idle` 並換新 `requestId`/`ttl`);`BACK` 事件直接回頂層 `calculated`。`ttl` 單位是**毫秒**,`decreaseTtl` 每秒 `Math.max(ttl - 1000, 0)`。
256
265
 
257
- **附件類型**:`withdraw`(正常提款)vs `pool`(獎金/免費額度兌換,呼叫 `restore` API)。
266
+ > ℹ️ `api/payment.js` 的 `restore`(獎金/免費額度兌換)目前**沒有任何 machine 呼叫**。
258
267
 
259
268
  ### 2.4 遊戲管理
260
269
 
@@ -270,11 +279,11 @@ loading(平行取得 siteConfig + bankList)
270
279
 
271
280
  **receiveStatus 枚舉**:`0` 進行中/未達標(→ `progress_status`)、`1` 已領取(→ `received`,終態)、`2` 可領取(→ `receiveable`)。
272
281
 
273
- **紅點未讀狀態**:
282
+ **紅點未讀狀態**(`activity_cash.js`):
274
283
 
275
- - `noRedActivity = [2, 4, 13, 20, 90, 91, 92]` — 這些活動類型**永不顯示紅點**
276
- - 其餘活動的已讀狀態以 `unread_${activityNo}_${uidSite}` 為 key 存 localStorage
284
+ - 已讀狀態以 `unread_${activityNo}_${uidSite}` 為 key 存 localStorage;**查無此 key 時預設 `unread = true`**(新活動一律亮紅點)
277
285
  - 每次更新 `activityList` 時 **clone 整個陣列**避免直接修改
286
+ - 舊版的 `noRedActivity` 類型白名單**已不存在**,目前所有活動類型一視同仁
278
287
 
279
288
  **活動輪詢**:基礎間隔 `tick * 10 = 20 秒`;**遊戲中(`isPlaying === true`)暫停輪詢**。Promotion 取得額外需 `hasToken`。
280
289
 
@@ -306,10 +315,9 @@ io(`${socketURL}/frontend`, {
306
315
 
307
316
  ### 2.7 設定與即時資訊(Common Machine)
308
317
 
309
- **4 個平行子機器**:`config`(siteConfig + layoutConfig,事件觸發)、`feed`(feeds + 信箱 + promotions,20 秒輪詢)、`getAnnouncements`(事件觸發)、`broadcast`(5 秒切換一則)。
318
+ **3 個平行子機器**:`config`(siteConfig + layoutConfig,事件觸發)、`feed`(feeds + 信箱 + promotions,20 秒輪詢)、`getAnnouncements`(事件觸發)。
310
319
 
311
320
  - **siteConfig 解碼**:回應為編碼字串,`setConfig` action 中 base64 解碼才得到實際設定(`loginMethods`、`paymentMethods`、`csChat` 等)。**下游前端的 store 不再解碼一次。**
312
- - **廣播輪播機制**:`picking`(5s)→ `display`(5s)→ `picking`,從 `broadcastList` 選 `type === '0'`,已顯示的加入 `sentNormalBroadcastList` 不再重複
313
321
  - **信箱過濾**:若 `customerMessageEnable === false`,從信箱總數中扣除 CUSTOMER 類型訊息數
314
322
 
315
323
  ### 2.8 API 請求生命週期
@@ -356,19 +364,19 @@ io(`${socketURL}/frontend`, {
356
364
 
357
365
  > 以下每一項在程式碼中都是**兩種寫法並存**——探索程式碼無法判斷哪個才是規範,因此必須明文記錄。新寫的程式碼一律採用「目標」欄;既有程式碼不主動大規模重構(範圍自律)。
358
366
 
359
- | 項目 | 現況 | 目標 |
360
- | ------------------ | -------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
361
- | HTTP method 大小寫 | `'GET'` 與 `'get'` 並存(`request.js` 內部 `toUpperCase()`,功能不受影響) | 統一小寫 `'get'`/`'post'`/`'put'`/`'delete'` |
362
- | 匯入路徑 | 部分檔案用 `@jetthai/cuora` 套件名自我引用 | 統一相對路徑(`'../../api/payment.js'`) |
363
- | lodash 副檔名 | `'lodash/pickBy.js'` 與 `'lodash/pickBy'` 並存 | 統一**不帶**副檔名 |
364
- | URL 前導斜線 | 少數 API 帶前導斜線 | 不加(除非刻意繞過 `url-join`,須註解原因) |
365
- | 查詢參數位置 | 少數直接寫入 URL(`register?${qs}`、`mail?include=cl`),繞過序列化 | 一律用 `params` 欄位 |
366
- | 初始狀態命名 | `idle` / `loading` / `fetching` / `init` / `preparing` 混用 | 依語意:`idle`(等待操作)、`loading`(初始載入)、`fetching`(重新取得)、`submitting` / `submitted` |
367
- | 魔法數字與字串 | 活動類型 ID、錯誤碼、TTL、輪詢 tick、`'DEPOSIT'`/`'WITHDRAW'`、`receiveStatus`、`connectStatus` 散佈各處 | 集中至 `util/constant.js`(`ERROR_CODES` / `TTL` / `INTERVAL` / `TRANSFER_TYPE` / `RECEIVE_STATUS`) |
368
- | 錯誤處理 | 三種並存:靜默轉 `idle`(多數,錯誤資訊遺失)、轉 `fail`、無限重試 | `onError` 搭配 `actions: 'setError'` 保存錯誤至 context;區分可恢復 / 不可恢復;重試須設上限 |
369
- | 參數命名 | 如 `addFavoriteGame(code)` 語意不明 | 具體命名(`gameCode`) |
370
- | 參數驗證 | API 層無任何驗證(如 `makeTransaction({ paymentMethod })` 直接注入 URL) | 在系統邊界驗證:路徑參數非 undefined 且無路徑遍歷字元、金額為正數 |
371
- | 已棄用 API | `api/user.js` 的 V1 `passwordRecovery` 與 V2 `passwordV2*` 並存,V1 無標記 | 先補 `@deprecated`,確認無引用後再移除 |
367
+ | 項目 | 現況 | 目標 |
368
+ | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
369
+ | HTTP method 大小寫 | `'GET'` 與 `'get'` 並存(`request.js` 內部 `toUpperCase()`,功能不受影響) | 統一小寫 `'get'`/`'post'`/`'put'`/`'delete'` |
370
+ | 匯入路徑 | 部分檔案用 `@jetthai/cuora` 套件名自我引用 | 統一相對路徑(`'../../api/payment.js'`) |
371
+ | lodash 副檔名 | `'lodash/pickBy.js'` 與 `'lodash/pickBy'` 並存 | 統一**不帶**副檔名 |
372
+ | URL 前導斜線 | 少數 API 帶前導斜線 | 不加(除非刻意繞過 `url-join`,須註解原因) |
373
+ | 查詢參數位置 | 少數直接寫入 URL(`register?${qs}`、`mail?include=cl`),繞過序列化 | 一律用 `params` 欄位 |
374
+ | 初始狀態命名 | `idle`(27) / `loading`(13) / `fetching`(12) / `pending`(6) / `checking` / `init` 等混用 | 依語意:`idle`(等待操作)、`loading`(初始載入)、`fetching`(重新取得)、`submitting` / `submitted` |
375
+ | 魔法數字與字串 | 活動類型 ID、錯誤碼、TTL、輪詢 tick、`'DEPOSIT'`/`'WITHDRAW'`、`receiveStatus`、`connectStatus` 散佈各處;`util/constant.js` 目前**只有** `GAME_SEARCH` / `GAME_TYPE_LIST` 兩個遊戲分類常數 | 集中至 `util/constant.js`(`ERROR_CODES` / `TTL` / `INTERVAL` / `TRANSFER_TYPE` / `RECEIVE_STATUS`) |
376
+ | 錯誤處理 | 三種並存:靜默轉 `idle`(多數,錯誤資訊遺失)、轉 `fail`、無限重試 | `onError` 搭配 `actions: 'setError'` 保存錯誤至 context;區分可恢復 / 不可恢復;重試須設上限 |
377
+ | 參數命名 | 如 `getFreeGameReward(code)` 語意不明 | 具體命名(`gameCode`) |
378
+ | 參數驗證 | API 層無任何驗證(如 `checkDt()` 之後的動態路徑直接注入 URL) | 在系統邊界驗證:路徑參數非 undefined 且無路徑遍歷字元、金額為正數 |
379
+ | 已棄用 API | `api/payment.js` 的 `getPaymentInfo` 標了「棄用」註解但仍有呼叫端 | 先補 `@deprecated`,確認無引用後再移除 |
372
380
 
373
381
  ---
374
382
 
@@ -380,12 +388,11 @@ io(`${socketURL}/frontend`, {
380
388
  - **無請求快取** — 高頻端點(`fetchUserInfo` 每 2–10 秒、`getConfig` 每次狀態機初始化、`getPaymentDetail` 每次進入存提款頁、`getActivityList` 每 20 秒)皆直打伺服器。可考慮 TTL 快取或 `stale-while-revalidate`。
381
389
  - **無速率限制與退避** — 輪詢為固定間隔,錯誤時不變。可考慮錯誤時指數退避。
382
390
  - **無 Token 自動刷新** — `request.js` 回應攔截器不處理 401,Token 過期即失敗。
383
- - **FingerprintJS 打包** — `src/lib/` 內嵌的 FingerprintJS 即使停用也會在模組初始化載入。建議改動態 `import()` 懶載入。
384
391
  - **無程式碼分割** — `machine/index.js` 即時匯入所有狀態機 + API + Socket.IO + lodash,匯入 `machine` 等於載入全部。建議支援個別匯入以啟用 tree-shaking。
385
- - **計時器管理** — 大量以 `after: { 1000 }` 自我引用轉換做倒數,每秒一次狀態轉換(含 context clone + event dispatch)。建議改 callback service + `setInterval`,並**計算經過時間**而非逐次遞減以避免累積誤差。
386
- - **大型狀態機檔案** — `game_v2_1.js`、`auth.js`、`withdraw_manual.js`、`inbox.js`、`manual_vn.js`、`common.js`、`game_search_v2.js` 皆超過 300 行,可拆為可組合的子狀態機。
392
+ - **計時器管理** — 大量以 `after: { 1000 }` 自我引用轉換做倒數(如 `withdraw_manual_cash.js` 的 OTP `countdown`),每秒一次狀態轉換(含 context clone + event dispatch)。建議改 callback service + `setInterval`,並**計算經過時間**而非逐次遞減以避免累積誤差。
393
+ - **大型狀態機檔案** — `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)、`crypto_bank_cash.js`(306) 皆超過 300 行,可拆為可組合的子狀態機。
387
394
  - **未使用的 context 欄位** — 多個狀態機宣告了從未賦值或讀取的 context 欄位。
388
- - **lodash 可原生替代** — 實際只用到少數幾個函式,`padStart` / `toNumber` 可直接換原生,`findLastIndex` 現代瀏覽器已支援。
395
+ - **lodash 只為兩個函式而存在** — 全 repo 只有 5 處 import:`pickBy`(`request/request.js`、`api/auth.js`、`machine/auth.js`、`machine/common.js`)與 `isEqual`(`activity/fafafa_activity.js`),卻整包列為 dependency。兩者都可用原生實作替代以移除依賴;在那之前至少要先統一副檔名寫法(見「風格收斂目標」)。
389
396
 
390
397
  ---
391
398
 
package/CHANGELOG.md CHANGED
@@ -2,6 +2,32 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.1.480](https://github.com/jetthai/cuora-module/compare/v1.1.479...v1.1.480) (2026-10-19)
6
+
7
+ ### ⚠ BREAKING CHANGES
8
+
9
+ - **export:** 移除頂層 export util 與 Request.sourceUpdate/sourceGenerate
10
+
11
+ Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
12
+
13
+ - **api,machine:** 移除 39 個 api 方法、2 個常數與 14 個 machine 事件
14
+
15
+ Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
16
+
17
+ - **machine:** 移除公開 export machine.bonus、machine.vip_table 與 util 的 max
18
+
19
+ Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
20
+
21
+ ### Bug Fixes
22
+
23
+ - **machine:** 移除三處幽靈 action 引用 ([49009da](https://github.com/jetthai/cuora-module/commit/49009dae604088b819134e0d40f7719fb8e8874d))
24
+
25
+ - **api,machine:** 移除 39 個零呼叫端 API 與 14 個無觸發來源的 machine 事件 ([14fa754](https://github.com/jetthai/cuora-module/commit/14fa75459aba9558cde1a3485d64cbdf2f8294b2))
26
+ - **export:** 移除四個無消費者的對外符號 ([55afe6f](https://github.com/jetthai/cuora-module/commit/55afe6fbfadca8944dd9820d6333ee5b93e0ed25))
27
+ - **machine:** 移除 client-pwa-cash 未使用的 bonus、vip_table 與 util/max ([f49977b](https://github.com/jetthai/cuora-module/commit/f49977bfd480d961f5dc37435b3c60447eb198c0))
28
+
29
+ ### [1.1.479](https://github.com/jetthai/cuora-module/compare/v1.1.478...v1.1.479) (2026-10-19)
30
+
5
31
  ### [1.1.478](https://github.com/jetthai/cuora-module/compare/v1.1.477...v1.1.478) (2026-10-16)
6
32
 
7
33
  ### [1.1.477](https://github.com/jetthai/cuora-module/compare/v1.1.476...v1.1.477) (2026-10-16)
package/CLAUDE.md CHANGED
@@ -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
  >
@@ -237,26 +236,36 @@ loading (fetch siteConfig + bankList in parallel)
237
236
  >
238
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).
239
238
 
240
- **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.
241
240
 
242
241
  ### 2.3 Withdrawal Flow & OTP
243
242
 
244
- **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:
245
244
 
246
245
  ```
247
- 1. haveProcessing → is there a withdrawal in progress? (yes → inProcessing)
248
- 2. isBankNotBound → is a bank account bound? (no → unbound)
249
- 3. isNotWithdrawMinDepositAmount → is the minimum deposit threshold met?
250
- 4. isPassWithdrawCooldownTime → still within the cooldown?
251
- 5. isNotWIthdrawServiceTime → within the service window?
252
- 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
253
252
  ```
254
253
 
255
- **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`.
256
265
 
257
- **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.
258
267
 
259
- **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**.
260
269
 
261
270
  ### 2.4 Game Management
262
271
 
@@ -272,11 +281,11 @@ loading (fetch siteConfig + bankList in parallel)
272
281
 
273
282
  **receiveStatus enum**: `0` in progress / not yet eligible (→ `progress_status`), `1` claimed (→ `received`, terminal), `2` claimable (→ `receiveable`).
274
283
 
275
- **Red-dot unread state**:
284
+ **Red-dot unread state** (`activity_cash.js`):
276
285
 
277
- - `noRedActivity = [2, 4, 13, 20, 90, 91, 92]` — these activity types **never show a red dot**
278
- - 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)
279
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
280
289
 
281
290
  **Activity polling**: base interval `tick * 10 = 20 seconds`; **polling pauses while in a game (`isPlaying === true`)**. Fetching promotions additionally requires `hasToken`.
282
291
 
@@ -308,10 +317,9 @@ io(`${socketURL}/frontend`, {
308
317
 
309
318
  ### 2.7 Configuration & Live Info (Common Machine)
310
319
 
311
- **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).
312
321
 
313
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.**
314
- - **Broadcast rotation**: `picking` (5s) → `display` (5s) → `picking`, selecting `type === '0'` entries from `broadcastList`; already-shown items are added to `sentNormalBroadcastList` and not repeated
315
323
  - **Mailbox filtering**: if `customerMessageEnable === false`, the count of CUSTOMER-type messages is deducted from the mailbox total
316
324
 
317
325
  ### 2.8 API Request Lifecycle
@@ -358,19 +366,19 @@ io(`${socketURL}/frontend`, {
358
366
 
359
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).
360
368
 
361
- | Item | Current state | Target |
362
- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
363
- | HTTP method casing | `'GET'` and `'get'` coexist (`request.js` calls `toUpperCase()` internally, so behavior is unaffected) | Consistently lowercase `'get'`/`'post'`/`'put'`/`'delete'` |
364
- | Import paths | Some files self-reference via the `@jetthai/cuora` package name | Consistently relative paths (`'../../api/payment.js'`) |
365
- | lodash extension | `'lodash/pickBy.js'` and `'lodash/pickBy'` coexist | Consistently **without** the extension |
366
- | URL leading slash | A few APIs carry a leading slash | Omit it (unless deliberately bypassing `url-join`, in which case comment the reason) |
367
- | Query parameter placement | A few write them straight into the URL (`register?${qs}`, `mail?include=cl`), bypassing serialization | Always use the `params` field |
368
- | Initial state naming | `idle` / `loading` / `fetching` / `init` / `preparing` are used interchangeably | By semantics: `idle` (awaiting action), `loading` (initial load), `fetching` (re-fetch), `submitting` / `submitted` |
369
- | 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`) |
370
- | 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 |
371
- | Parameter naming | e.g. `addFavoriteGame(code)` is semantically unclear | Concrete names (`gameCode`) |
372
- | 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 |
373
- | 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 |
374
382
 
375
383
  ---
376
384
 
@@ -382,12 +390,11 @@ io(`${socketURL}/frontend`, {
382
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`.
383
391
  - **No rate limiting or backoff** — polling runs at a fixed interval and does not change on errors. Consider exponential backoff on errors.
384
392
  - **No automatic token refresh** — the response interceptor in `request.js` does not handle 401, so an expired token simply fails.
385
- - **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.
386
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.
387
- - **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.
388
- - **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.
389
396
  - **Unused context fields** — several state machines declare context fields that are never assigned or read.
390
- - **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").
391
398
 
392
399
  ---
393
400