@jetthai/cuora 1.1.462 → 1.1.463-dev.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.
@@ -13,25 +13,19 @@ git checkout master
13
13
  git fetch --prune
14
14
  ```
15
15
 
16
- 刪除已合併至 master 的 remote 分支(排除 master/qa/dev/HEAD):
16
+ 刪除已合併的 remote 分支(排除 master/dev/qa/HEAD):
17
17
 
18
18
  ```bash
19
- git branch -r --merged origin/master | grep -v -E "(master|qa|dev|HEAD)" | sed 's/origin\///' | xargs -r -I {} git push origin --delete {}
19
+ git branch -r --merged master | grep -v -E "(master|dev|qa|HEAD)" | sed 's/origin\///' | xargs -r -I {} git push origin --delete {}
20
20
  ```
21
21
 
22
- 刪除已合併至 master 的 local 分支(排除 master/qa/dev):
22
+ 刪除已合併的 local 分支(排除 master/dev/qa):
23
23
 
24
24
  ```bash
25
- git branch --merged master | grep -v -E "^\*?\s*(master|qa|dev)$" | xargs -r git branch -d
25
+ git branch --merged master | grep -v -E "^\*?\s*(master|dev|qa)$" | xargs -r git branch -d
26
26
  ```
27
27
 
28
- ### Step 5 — 刪除不合規 tags
29
-
30
- 執行 `scripts/clean-tags.sh` 清理不符合正式版號格式的本地及遠端 tags:
31
-
32
- ```bash
33
- sh scripts/clean-tags.sh
34
- ```
28
+ > ⚠️ 衝突處理:如果刪除分支時遇到任何錯誤,立即暫停所有動作,列出錯誤訊息,等待使用者確認後再繼續。
35
29
 
36
30
  ---
37
31
 
@@ -48,5 +42,4 @@ git checkout master
48
42
  回報以下資訊:
49
43
 
50
44
  - 刪除了多少已合併分支
51
- - 刪除了多少不合規 tags
52
45
  - 當前所在分支
@@ -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
  }
@@ -309,7 +309,6 @@ io(`${socketURL}/frontend`, {
309
309
 
310
310
  - **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.**
311
311
  - **Broadcast rotation**: `picking` (5s) → `display` (5s) → `picking`, selecting `type === '0'` entries from `broadcastList`; already-shown items are added to `sentNormalBroadcastList` and not repeated
312
- - **Cocos native app detection**: when `window.CC_JSB === true`, **all agent/channel/cookie setup is skipped** (native apps don't need browser tracking)
313
312
  - **Mailbox filtering**: if `customerMessageEnable === false`, the count of CUSTOMER-type messages is deducted from the mailbox total
314
313
 
315
314
  ### 2.8 API Request Lifecycle
@@ -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
package/AGENTS.md CHANGED
@@ -309,7 +309,6 @@ io(`${socketURL}/frontend`, {
309
309
 
310
310
  - **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.**
311
311
  - **Broadcast rotation**: `picking` (5s) → `display` (5s) → `picking`, selecting `type === '0'` entries from `broadcastList`; already-shown items are added to `sentNormalBroadcastList` and not repeated
312
- - **Cocos native app detection**: when `window.CC_JSB === true`, **all agent/channel/cookie setup is skipped** (native apps don't need browser tracking)
313
312
  - **Mailbox filtering**: if `customerMessageEnable === false`, the count of CUSTOMER-type messages is deducted from the mailbox total
314
313
 
315
314
  ### 2.8 API Request Lifecycle
@@ -307,7 +307,6 @@ io(`${socketURL}/frontend`, {
307
307
 
308
308
  - **siteConfig 解碼**:回應為編碼字串,`setConfig` action 中 base64 解碼才得到實際設定(`loginMethods`、`paymentMethods`、`csChat` 等)。**下游前端的 store 不再解碼一次。**
309
309
  - **廣播輪播機制**:`picking`(5s)→ `display`(5s)→ `picking`,從 `broadcastList` 選 `type === '0'`,已顯示的加入 `sentNormalBroadcastList` 不再重複
310
- - **Cocos 原生 App 偵測**:`window.CC_JSB === true` 時**跳過所有 agent/channel/cookie 設定**(原生 App 不需瀏覽器追蹤)
311
310
  - **信箱過濾**:若 `customerMessageEnable === false`,從信箱總數中扣除 CUSTOMER 類型訊息數
312
311
 
313
312
  ### 2.8 API 請求生命週期
package/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
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.463-dev.0](https://github.com/jetthai/cuora-module/compare/v1.1.463...v1.1.463-dev.0) (2026-08-13)
6
+
7
+ ### [1.1.455-dev.8](https://github.com/jetthai/cuora-module/compare/v1.1.455...v1.1.455-dev.8) (2026-08-09)
8
+
9
+
10
+ ### Features
11
+
12
+ * **api:** add GeeMee click-id & front-event fields to sendPixel builder ([d33e488](https://github.com/jetthai/cuora-module/commit/d33e488062f81976cff35ea43ea0f2c366a2a615))
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * **error:** 讓新錯誤可覆寫舊狀態避免 SET_ERROR 鎖死 ([4113751](https://github.com/jetthai/cuora-module/commit/4113751ee6cb4ced8fe1dc2fda0ce9fbac21ec06))
18
+ * **request:** 非 public 請求缺少 token 時提前返回,不再送出後端 ([065095e](https://github.com/jetthai/cuora-module/commit/065095e31ffe1cb640f9aaf6c76bbd5c6892355c))
19
+ * **request:** 非 public 請求缺少 token 時改為 reject ERR_A103,觸發登出流程 ([e46281f](https://github.com/jetthai/cuora-module/commit/e46281f3ea16679404160366e4532969c3bf02ff))
20
+ * **user_sign_up:** 明確輸入判定改用 !== undefined,修復三層解析成為死碼 ([770450e](https://github.com/jetthai/cuora-module/commit/770450e6065d42d497504d2f8630c6740ec1e7c4))
21
+ * **withdraw:** 修正法幣提款計算錯誤時的狀態轉移 ([a951ba8](https://github.com/jetthai/cuora-module/commit/a951ba803cccd1564a7dbe2645ea7c8d50f7da31))
22
+
23
+ ### [1.1.463](https://github.com/jetthai/cuora-module/compare/v1.1.462...v1.1.463) (2026-08-12)
24
+
5
25
  ### [1.1.462](https://github.com/jetthai/cuora-module/compare/v1.1.461...v1.1.462) (2026-08-10)
6
26
 
7
27
  ### [1.1.461](https://github.com/jetthai/cuora-module/compare/v1.1.460...v1.1.461) (2026-08-10)
@@ -16,6 +36,44 @@ All notable changes to this project will be documented in this file. See [standa
16
36
 
17
37
  ### [1.1.456](https://github.com/jetthai/cuora-module/compare/v1.1.455...v1.1.456) (2026-08-09)
18
38
 
39
+ ### [1.1.455-dev.8](https://github.com/jetthai/cuora-module/compare/v1.1.455-dev.7...v1.1.455-dev.8) (2026-08-09)
40
+
41
+ ### [1.1.455-dev.7](https://github.com/jetthai/cuora-module/compare/v1.1.455-dev.6...v1.1.455-dev.7) (2026-08-07)
42
+
43
+ ### [1.1.455-dev.6](https://github.com/jetthai/cuora-module/compare/v1.1.455-dev.5...v1.1.455-dev.6) (2026-08-07)
44
+
45
+ ### [1.1.455-dev.5](https://github.com/jetthai/cuora-module/compare/v1.1.455-dev.4...v1.1.455-dev.5) (2026-08-07)
46
+
47
+ ### [1.1.455-dev.4](https://github.com/jetthai/cuora-module/compare/v1.1.455-dev.3...v1.1.455-dev.4) (2026-08-07)
48
+
49
+ ### [1.1.455-dev.3](https://github.com/jetthai/cuora-module/compare/v1.1.455-dev.2...v1.1.455-dev.3) (2026-08-07)
50
+
51
+ ### [1.1.455-dev.2](https://github.com/jetthai/cuora-module/compare/v1.1.455-dev.1...v1.1.455-dev.2) (2026-08-06)
52
+
53
+ ### [1.1.455-dev.1](https://github.com/jetthai/cuora-module/compare/v1.1.455-dev.0...v1.1.455-dev.1) (2026-08-04)
54
+
55
+
56
+ ### Bug Fixes
57
+
58
+ - **user_sign_up:** 明確輸入判定改用 !== undefined,修復三層解析成為死碼 ([770450e](https://github.com/jetthai/cuora-module/commit/770450e6065d42d497504d2f8630c6740ec1e7c4))
59
+
60
+ ### [1.1.455-dev.0](https://github.com/jetthai/cuora-module/compare/v1.1.455...v1.1.455-dev.0) (2026-08-04)
61
+
62
+ ### [1.1.454-dev.0](https://github.com/jetthai/cuora-module/compare/v1.1.453...v1.1.454-dev.0) (2026-07-29)
63
+
64
+
65
+ ### Features
66
+
67
+ - **api:** add GeeMee click-id & front-event fields to sendPixel builder ([d33e488](https://github.com/jetthai/cuora-module/commit/d33e488062f81976cff35ea43ea0f2c366a2a615))
68
+
69
+
70
+ ### Bug Fixes
71
+
72
+ - **error:** 讓新錯誤可覆寫舊狀態避免 SET_ERROR 鎖死 ([4113751](https://github.com/jetthai/cuora-module/commit/4113751ee6cb4ced8fe1dc2fda0ce9fbac21ec06))
73
+ - **request:** 非 public 請求缺少 token 時提前返回,不再送出後端 ([065095e](https://github.com/jetthai/cuora-module/commit/065095e31ffe1cb640f9aaf6c76bbd5c6892355c))
74
+ - **request:** 非 public 請求缺少 token 時改為 reject ERR_A103,觸發登出流程 ([e46281f](https://github.com/jetthai/cuora-module/commit/e46281f3ea16679404160366e4532969c3bf02ff))
75
+ - **withdraw:** 修正法幣提款計算錯誤時的狀態轉移 ([a951ba8](https://github.com/jetthai/cuora-module/commit/a951ba803cccd1564a7dbe2645ea7c8d50f7da31))
76
+
19
77
  ### [1.1.455](https://github.com/jetthai/cuora-module/compare/v1.1.453...v1.1.455) (2026-08-03)
20
78
 
21
79
  ### Bug Fixes
package/CLAUDE.md CHANGED
@@ -309,7 +309,6 @@ io(`${socketURL}/frontend`, {
309
309
 
310
310
  - **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.**
311
311
  - **Broadcast rotation**: `picking` (5s) → `display` (5s) → `picking`, selecting `type === '0'` entries from `broadcastList`; already-shown items are added to `sentNormalBroadcastList` and not repeated
312
- - **Cocos native app detection**: when `window.CC_JSB === true`, **all agent/channel/cookie setup is skipped** (native apps don't need browser tracking)
313
312
  - **Mailbox filtering**: if `customerMessageEnable === false`, the count of CUSTOMER-type messages is deducted from the mailbox total
314
313
 
315
314
  ### 2.8 API Request Lifecycle
package/GEMINI.md CHANGED
@@ -309,7 +309,6 @@ io(`${socketURL}/frontend`, {
309
309
 
310
310
  - **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.**
311
311
  - **Broadcast rotation**: `picking` (5s) → `display` (5s) → `picking`, selecting `type === '0'` entries from `broadcastList`; already-shown items are added to `sentNormalBroadcastList` and not repeated
312
- - **Cocos native app detection**: when `window.CC_JSB === true`, **all agent/channel/cookie setup is skipped** (native apps don't need browser tracking)
313
312
  - **Mailbox filtering**: if `customerMessageEnable === false`, the count of CUSTOMER-type messages is deducted from the mailbox total
314
313
 
315
314
  ### 2.8 API Request Lifecycle
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.462",
3
+ "version": "1.1.463-dev.0",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ // Copyright 2024 The Terasology Foundation
2
3
 
3
4
  // dev/qa 分支自動計算下一個 prerelease 版號
4
5
  // 版號格式:{master 版號}-{分支名}.{遞增編號}
@@ -130,9 +130,9 @@ export default {
130
130
  method: 'get',
131
131
  params: { appSecret },
132
132
  }),
133
- getProgressDetail: ({ appSecret }) => ({
133
+ getProgressDetail: ({ appSecret, locale }) => ({
134
134
  url: 'activities/progress-details',
135
135
  method: 'get',
136
- params: { appSecret },
136
+ params: { appSecret, locale },
137
137
  }),
138
138
  }
package/src/api/user.js CHANGED
@@ -66,16 +66,16 @@ export default {
66
66
  getUserPhotoList: () => ({ url: 'getAllAvatar', method: 'get' }),
67
67
  updateUserPhoto: (data) => ({ url: 'updateUserAvatar', method: 'post', params: data }),
68
68
  getUserProfile: () => ({ url: 'user-info/get-profile', method: 'get' }),
69
- subscribeStatus: ({ fingerprintId, domain }) => ({
69
+ subscribeStatus: ({ fingerprintId, domain, appSecret }) => ({
70
70
  url: 'notification-subscription/status',
71
71
  method: 'post',
72
- params: { fingerprintId, domain },
72
+ params: { fingerprintId, domain, appSecret },
73
73
  isPublic: true,
74
74
  }),
75
- subscribeUpdate: ({ fingerprintId, domain, action = 'subscribe' }) => ({
75
+ subscribeUpdate: ({ fingerprintId, domain, appSecret, action = 'subscribe' }) => ({
76
76
  url: 'notification-subscription/update',
77
77
  method: 'post',
78
- params: { fingerprintId, domain, action },
78
+ params: { fingerprintId, domain, action, appSecret },
79
79
  isPublic: true,
80
80
  }),
81
81
  }
package/src/index.js CHANGED
@@ -2,6 +2,6 @@ import api from './api/index.js'
2
2
  import machine from './machine/index.js'
3
3
  import Request from './request/request.js'
4
4
  import Config from './request/config.js'
5
- import util, { constant, storage } from './util/index.js'
5
+ import util, { constant, storage, paramStore } from './util/index.js'
6
6
 
7
- export { api, machine, Request, Config, util, constant, storage }
7
+ export { api, machine, Request, Config, util, constant, storage, paramStore }
@@ -5,6 +5,7 @@ import user from '../api/user.js'
5
5
  import storage from '../util/storage.js'
6
6
  import common from '../api/common.js'
7
7
  import pickBy from 'lodash/pickBy.js'
8
+ import { readParamFromLocation, writeParam, normalize, AC_KEYS, FC_KEYS } from '../util/paramStore.js'
8
9
 
9
10
  export default function (request) {
10
11
  const { appSecret, clientId, sentry } = request.config
@@ -469,7 +470,18 @@ export default function (request) {
469
470
 
470
471
  const dt = deviceTokenEnable ? await request.config.getDt?.() : undefined
471
472
 
472
- const affiliateCode = storage.get('ac')
473
+ // 宿主若明確帶了 ac(使用者在補資料頁/代理碼彈窗按下確認,含刻意留白)以它為準:
474
+ // 網址層仍留著進站時的 ?ac=,不讓步的話使用者剛清掉的值會被網址撿回來又寫回兩個媒介
475
+ const hasExplicitAc = !!event.data && Object.prototype.hasOwnProperty.call(event.data, 'ac')
476
+ const acRead = readParamFromLocation(AC_KEYS)
477
+ const affiliateCode = hasExplicitAc ? normalize(event.data.ac) : acRead.value
478
+ // 尾綴 undefined 是刻意的:全空時維持原本序列化成 fc=undefined 的行為,不改為 fc=null
479
+ const friendCode = fc || readParamFromLocation(FC_KEYS).value || undefined
480
+
481
+ // 本段結尾以 window.location.href 離站,離站後 SPA 記憶體全丟;導頁前先落地雙寫
482
+ writeParam('ac', affiliateCode, { sentry })
483
+ writeParam('fc', friendCode, { sentry })
484
+
473
485
  const nickname = storage.get('nk')
474
486
  const phone = storage.get('tp_phone')
475
487
  const countryCode = storage.get('tp_countryCode')
@@ -478,6 +490,7 @@ export default function (request) {
478
490
  const messages = {
479
491
  url: window.location.href,
480
492
  affiliateCode,
493
+ acSource: hasExplicitAc ? 'event' : acRead.from,
481
494
  nickname,
482
495
  }
483
496
 
@@ -524,7 +537,7 @@ export default function (request) {
524
537
  ...referralObj,
525
538
  dt,
526
539
  platform: 'pwa',
527
- fc,
540
+ fc: friendCode,
528
541
  }).toString()
529
542
  )
530
543
 
@@ -3,9 +3,10 @@ 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 } = request.config
9
+ const { appSecret, sentry } = request.config
9
10
  return createMachine(
10
11
  {
11
12
  id: 'common',
@@ -276,28 +277,17 @@ export default function (request) {
276
277
  kpix,
277
278
  }
278
279
  }),
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 affiliateCode = urlParams.get('ac') || urlParams.get('referralCode') || storage.get('ac') || storage.get('referralCode')
286
- const friendCode = urlParams.get('fc') || urlParams.get('affiliate') || storage.get('fc') || storage.get('affiliate')
280
+ setAgent: assign(() => {
281
+ const urlParams = new URLSearchParams(window.location.search)
282
+ const ac = readParam(urlParams, AC_KEYS)
283
+ const fc = readParam(urlParams, FC_KEYS)
287
284
 
288
- storage.set('ac', affiliateCode, {
289
- path: '/',
290
- maxAge: 60 * 60 * 24 * 7,
291
- })
292
- storage.set('fc', friendCode, {
293
- path: '/',
294
- maxAge: 60 * 60 * 24 * 7,
295
- })
285
+ writeParam('ac', ac.value, { sentry })
286
+ writeParam('fc', fc.value, { sentry })
296
287
 
297
- return {
298
- affiliateCode,
299
- friendCode,
300
- }
288
+ return {
289
+ affiliateCode: ac.value,
290
+ friendCode: fc.value,
301
291
  }
302
292
  }),
303
293
  clearAnnouncements: assign((context, event) => {
@@ -1,5 +1,6 @@
1
1
  import { assign, createMachine } from 'xstate'
2
2
  import payment from '../../api/payment.js'
3
+ import { isAmountInRange } from '../../util/amount.js'
3
4
 
4
5
  export default function (request, context) {
5
6
  const { paymentDetail = [], promotion, selectedAmount } = context || {}
@@ -177,13 +178,7 @@ export default function (request, context) {
177
178
  isPromotionChanged: (context, event) => {
178
179
  return event.data?.promotionsNo !== context.promotion?.promotionsNo
179
180
  },
180
- isCalculable: (context, event) => {
181
- const {
182
- selectedAmount,
183
- selectedDirect: { maximum, minimum },
184
- } = context
185
- return selectedAmount && minimum <= +selectedAmount && +selectedAmount <= maximum
186
- },
181
+ isCalculable: ({ selectedDirect, selectedAmount }) => isAmountInRange(selectedAmount, selectedDirect),
187
182
  isSubmittable: (context, event) => {
188
183
  const { selectedAmount, selectedDirect, selectedUserBank } = context
189
184
  return selectedAmount && selectedDirect && selectedUserBank
@@ -1,5 +1,6 @@
1
1
  import { assign, createMachine } from 'xstate'
2
2
  import payment from '../../api/payment.js'
3
+ import { isAmountInRange } from '../../util/amount.js'
3
4
 
4
5
  export default function (request, context) {
5
6
  const { paymentDetail = [], promotion, selectedAmount } = context || {}
@@ -33,22 +34,7 @@ export default function (request, context) {
33
34
  debouncing: {
34
35
  entry: 'clearCalculation',
35
36
  after: {
36
- 1000: [
37
- {
38
- target: 'calculating',
39
- cond: (context, event) => {
40
- const { selectedLoadcard, selectedAmount } = context
41
- if (selectedLoadcard && selectedAmount) {
42
- return selectedLoadcard.minimum <= selectedAmount && selectedAmount <= selectedLoadcard.maximum
43
- } else {
44
- return false
45
- }
46
- },
47
- },
48
- {
49
- target: 'loaded',
50
- },
51
- ],
37
+ 1000: [{ target: 'calculating', cond: 'isCalculable' }, { target: 'loaded' }],
52
38
  },
53
39
  },
54
40
  calculating: {
@@ -183,6 +169,7 @@ export default function (request, context) {
183
169
  isPromotionChanged: (context, event) => {
184
170
  return event.data?.promotionsNo !== context.promotion?.promotionsNo
185
171
  },
172
+ isCalculable: ({ selectedLoadcard, selectedAmount }) => isAmountInRange(selectedAmount, selectedLoadcard),
186
173
  },
187
174
  services: {
188
175
  fetchCalculation: async (context, event) => {
@@ -1,5 +1,6 @@
1
1
  import { assign, createMachine } from 'xstate'
2
2
  import payment from '../../api/payment.js'
3
+ import { isAmountInRange } from '../../util/amount.js'
3
4
 
4
5
  export default function (request, context) {
5
6
  const { paymentDetail = [], promotion, selectedAmount } = context || {}
@@ -45,22 +46,7 @@ export default function (request, context) {
45
46
  debouncing: {
46
47
  entry: 'clearCalculation',
47
48
  after: {
48
- 1000: [
49
- {
50
- target: 'calculating',
51
- cond: (context, event) => {
52
- const { selectedQrcode, selectedAmount } = context
53
- if (selectedQrcode && selectedAmount) {
54
- return selectedQrcode.minimum <= selectedAmount && selectedAmount <= selectedQrcode.maximum
55
- } else {
56
- return false
57
- }
58
- },
59
- },
60
- {
61
- target: 'loaded',
62
- },
63
- ],
49
+ 1000: [{ target: 'calculating', cond: 'isCalculable' }, { target: 'loaded' }],
64
50
  },
65
51
  },
66
52
  calculating: {
@@ -79,6 +65,7 @@ export default function (request, context) {
79
65
  on: {
80
66
  SUBMIT: {
81
67
  target: 'submitting',
68
+ cond: 'isSubmittable',
82
69
  },
83
70
  },
84
71
  },
@@ -195,6 +182,8 @@ export default function (request, context) {
195
182
  hasQrcodeMethods: (context, event) => {
196
183
  return context.paymentDetail?.filter((element) => element.category === context.currentCategory).length > 0
197
184
  },
185
+ isCalculable: ({ selectedQrcode, selectedAmount }) => isAmountInRange(selectedAmount, selectedQrcode),
186
+ isSubmittable: ({ selectedQrcode, selectedAmount }) => isAmountInRange(selectedAmount, selectedQrcode),
198
187
  },
199
188
  services: {
200
189
  fetchCalculation: async (context, event) => {
@@ -1,6 +1,7 @@
1
1
  import { assign, createMachine } from 'xstate'
2
2
  import auth from '../api/auth.js'
3
3
  import storage from '../util/storage.js'
4
+ import { readParamFromLocation, normalize, AC_KEYS, FC_KEYS } from '../util/paramStore.js'
4
5
 
5
6
  // 註冊強制綁定多型出款:轉發各綁定型別欄位(BANK / CRYPTO / EWALLET),只帶有值的欄位
6
7
  const BIND_FIELDS = [
@@ -104,6 +105,7 @@ export default function (request) {
104
105
  return {
105
106
  signUpData: {
106
107
  provider: 'local',
108
+ birthday,
107
109
  ...pickBindData(event.data),
108
110
  birthday,
109
111
  email,
@@ -127,6 +129,7 @@ export default function (request) {
127
129
  return {
128
130
  signUpData: {
129
131
  provider: 'phone',
132
+ birthday,
130
133
  ...pickBindData(event.data),
131
134
  birthday,
132
135
  email,
@@ -149,6 +152,7 @@ export default function (request) {
149
152
  return {
150
153
  signUpData: {
151
154
  provider: 'email',
155
+ birthday,
152
156
  ...pickBindData(event.data),
153
157
  birthday,
154
158
  email,
@@ -188,10 +192,19 @@ export default function (request) {
188
192
  const { signUpData, deviceTokenEnable } = context
189
193
  const dt = deviceTokenEnable ? await request.config.getDt?.() : undefined
190
194
 
191
- const affiliateCode = storage.get('ac') || signUpData?.affiliateCode
195
+ // 宿主明確帶入的 affiliateCode(註冊表單的代理碼欄位)優先於網址/儲存這類環境值。
196
+ // 判定用 `!== undefined` 而非 hasOwnProperty:上面的 setSignUpId/Phone/Email 是以解構寫入
197
+ // signUpData,宿主沒帶時 key 仍然存在(值為 undefined),hasOwnProperty 會恆為 true、
198
+ // 讓三層解析變成死碼。也不能用 `||`,否則使用者刻意清空送出的空字串會被吃掉、
199
+ // 退回三層解析把剛清掉的舊代理碼從網址撿回來。
200
+ const { affiliateCode: explicitAffiliateCode, ...signUpRest } = signUpData || {}
201
+ const hasExplicitAc = explicitAffiliateCode !== undefined
202
+ const acRead = readParamFromLocation(AC_KEYS)
203
+ const affiliateCode = hasExplicitAc ? normalize(explicitAffiliateCode) : acRead.value
192
204
  const messages = {
193
205
  url: window.location.href,
194
206
  affiliateCode,
207
+ acSource: hasExplicitAc ? 'signUpData' : acRead.from,
195
208
  }
196
209
 
197
210
  // 因 client-pwa-cash PR #805 的問題,暫時註解此 Sentry 上報
@@ -205,11 +218,11 @@ export default function (request) {
205
218
 
206
219
  return await request.send(
207
220
  auth.register({
208
- ...signUpData,
221
+ ...signUpRest,
209
222
  ...referralObj,
210
223
  dt,
211
224
  reCaptchaToken: context.reCaptchaToken,
212
- fc: context.fc,
225
+ fc: context.fc || readParamFromLocation(FC_KEYS).value || undefined,
213
226
  })
214
227
  )
215
228
  },
@@ -0,0 +1,8 @@
1
+ export function isAmountInRange(raw, payment) {
2
+ if (!payment) return false
3
+ const amount = Number(raw)
4
+ if (!Number.isFinite(amount) || amount <= 0) return false
5
+ const minimum = payment.minimum ?? 0
6
+ const maximum = payment.maximum ?? Infinity
7
+ return amount >= minimum && amount <= maximum
8
+ }
package/src/util/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import storage from './storage.js'
2
+ import paramStore from './paramStore.js'
2
3
  import * as constant from './constant.js'
3
4
  import { max } from './math.js'
5
+ import { isAmountInRange } from './amount.js'
4
6
 
5
7
  export default {}
6
- export { constant, storage, max }
8
+ export { constant, storage, paramStore, max, isAmountInRange }
@@ -0,0 +1,139 @@
1
+ import Cookies from 'universal-cookie'
2
+ import storage from './storage.js'
3
+
4
+ export const PARAM_MAX_AGE = 60 * 60 * 24 * 7
5
+ export const AC_KEYS = ['ac', 'referralCode']
6
+ export const FC_KEYS = ['fc', 'affiliate']
7
+
8
+ const DIRTY_VALUES = ['undefined', 'null', 'NaN']
9
+
10
+ const reportedOnce = new Set()
11
+
12
+ function cookieJar() {
13
+ return typeof document === 'undefined' ? null : new Cookies()
14
+ }
15
+
16
+ export function normalize(value) {
17
+ if (value === undefined || value === null) return null
18
+ const trimmed = String(value).trim()
19
+ if (trimmed === '' || DIRTY_VALUES.includes(trimmed)) return null
20
+ return trimmed
21
+ }
22
+
23
+ // storage.js 的 JSON.parse 未包在 try/catch 內,localStorage 若存有同名裸字串會 throw,
24
+ // 未攔截會沿 xstate entry chain 往上炸掉整條 setUA→setAgent→setPixel→setKPixel→setFbclid
25
+ function readLocal(name) {
26
+ try {
27
+ return normalize(storage.get(name))
28
+ } catch (error) {
29
+ return null
30
+ }
31
+ }
32
+
33
+ function readCookie(name) {
34
+ const jar = cookieJar()
35
+ if (!jar) return null
36
+ try {
37
+ return normalize(jar.get(name, { doNotParse: true }))
38
+ } catch (error) {
39
+ return null
40
+ }
41
+ }
42
+
43
+ export function readParam(urlParams, keys) {
44
+ for (const key of keys) {
45
+ const value = normalize(urlParams?.get?.(key))
46
+ if (value) return { value, from: `url:${key}` }
47
+ }
48
+ for (const key of keys) {
49
+ const value = readLocal(key)
50
+ if (value) return { value, from: `local:${key}` }
51
+ }
52
+ for (const key of keys) {
53
+ const value = readCookie(key)
54
+ if (value) return { value, from: `cookie:${key}` }
55
+ }
56
+ return { value: null, from: 'none' }
57
+ }
58
+
59
+ export function readParamFromLocation(keys) {
60
+ const search = typeof window === 'undefined' ? '' : window.location.search
61
+ return readParam(new URLSearchParams(search), keys)
62
+ }
63
+
64
+ function report(sentry, name, medium, reason) {
65
+ // 去重必須在確定送得出去之後才登錄,否則早於 sentry 注入的那次失敗會把 fingerprint 佔走,
66
+ // 導致之後真正有 sentry 時被自己的去重擋掉、永遠不上報
67
+ if (!sentry?.captureMessage) return
68
+ const fingerprint = `${name}:${medium}:${reason}`
69
+ if (reportedOnce.has(fingerprint)) return
70
+ reportedOnce.add(fingerprint)
71
+ sentry?.captureMessage?.(`[ParamStore] ${medium} persist ${reason}: ${name}`, {
72
+ level: 'warning',
73
+ tags: { feature: 'url-param-fallback', param_key: name, storage_medium: medium, failure_reason: reason },
74
+ })
75
+ }
76
+
77
+ function clearParam(name) {
78
+ const result = { local: 'ok', cookie: 'ok', cleared: true }
79
+ try {
80
+ storage.remove(name)
81
+ } catch (error) {
82
+ result.local = 'throw'
83
+ }
84
+ const jar = cookieJar()
85
+ if (jar) {
86
+ try {
87
+ jar.remove(name, { path: '/' })
88
+ } catch (error) {
89
+ result.cookie = 'throw'
90
+ }
91
+ }
92
+ return result
93
+ }
94
+
95
+ export function writeParam(name, value, options = {}) {
96
+ const { sentry, allowClear = false } = options
97
+ const normalized = normalize(value)
98
+
99
+ if (normalized === null) {
100
+ return allowClear ? clearParam(name) : { local: 'skipped', cookie: 'skipped', skipped: true }
101
+ }
102
+
103
+ const result = { local: 'ok', cookie: 'ok' }
104
+
105
+ try {
106
+ storage.set(name, normalized, { path: '/', maxAge: PARAM_MAX_AGE })
107
+ } catch (error) {
108
+ result.local = 'throw'
109
+ }
110
+ if (result.local === 'ok' && readLocal(name) !== normalized) {
111
+ result.local = 'mismatch'
112
+ }
113
+
114
+ const jar = cookieJar()
115
+ if (!jar) {
116
+ result.cookie = 'unavailable'
117
+ } else {
118
+ try {
119
+ jar.set(name, normalized, {
120
+ path: '/',
121
+ maxAge: PARAM_MAX_AGE,
122
+ sameSite: 'lax',
123
+ secure: typeof window !== 'undefined' && window.location.protocol === 'https:',
124
+ })
125
+ } catch (error) {
126
+ result.cookie = 'throw'
127
+ }
128
+ if (result.cookie === 'ok' && readCookie(name) !== normalized) {
129
+ result.cookie = 'mismatch'
130
+ }
131
+ }
132
+
133
+ if (result.local !== 'ok') report(sentry, name, 'localStorage', result.local)
134
+ if (result.cookie !== 'ok') report(sentry, name, 'cookie', result.cookie)
135
+
136
+ return result
137
+ }
138
+
139
+ export default { PARAM_MAX_AGE, AC_KEYS, FC_KEYS, normalize, readParam, readParamFromLocation, writeParam }
@@ -1,142 +0,0 @@
1
- # Create Branch
2
-
3
- 從目前 HEAD 建立新分支(feat / fix / hotfix),**建立後切換到該分支**。
4
-
5
- - 分支命名:
6
- - `feat` → `feat/well/{子名稱}`
7
- - `fix` → `fix/well/{子名稱}`
8
- - `hotfix` → `hotfix/{版號}`(例如 `hotfix/1.1.562`)
9
-
10
- 請依序執行每個步驟,每步執行前先告知使用者當前進度。
11
-
12
- ---
13
-
14
- ## Step 1 — 檢查工作區是否乾淨(忽略 submodule)
15
-
16
- 若有未提交的變更(staged、unstaged、untracked),立即終止並提醒使用者先處理(commit 或 stash)。**忽略 submodule 變更。**
17
-
18
- ```bash
19
- git status --porcelain --ignore-submodules=all
20
- ```
21
-
22
- 若輸出非空,停止後續步驟並回報:
23
-
24
- - 工作區目前有未提交的變更,為避免遺失,已中止操作
25
- - 列出 `git status --short --ignore-submodules=all` 的結果
26
- - 建議使用者先 `git commit` 或 `git stash` 後再重新執行
27
-
28
- ---
29
-
30
- ## Step 2 — 詢問 branch 類型
31
-
32
- 使用 `AskUserQuestion` 工具,讓使用者選擇 branch 類型:
33
-
34
- - 問題:`請選擇要建立的 branch 類型?`
35
- - header:`Branch 類型`
36
- - 選項:
37
- - `feat` — 新功能開發
38
- - `fix` — Bug 修正
39
- - `hotfix` — 緊急修復
40
-
41
- 將使用者選擇的答案儲存為 `<BRANCH_TYPE>`。
42
-
43
- ---
44
-
45
- ## Step 3 — 決定最終 branch 名稱
46
-
47
- 依 `<BRANCH_TYPE>` 分支處理:
48
-
49
- ### 若 `<BRANCH_TYPE>` 為 `hotfix`
50
-
51
- 使用 `AskUserQuestion` 工具,請使用者透過「Other」選項輸入版號:
52
-
53
- - 問題:`請輸入 hotfix 版號(例如:1.1.562)?`
54
- - header:`Hotfix 版號`
55
- - 選項:
56
- - 提供 1~2 個範例選項讓使用者參考(例如 `1.0.0`、`1.1.562`)
57
- - 明確提示使用者應該選「Other」自行輸入
58
-
59
- 將使用者輸入的值儲存為 `<HOTFIX_VERSION>`。
60
-
61
- **驗證規則**:
62
-
63
- - 不可為空
64
- - 必須符合 `^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$` 格式(不含 `v` 前綴)
65
- - 若不符合規則,請使用者重新輸入
66
-
67
- 組合:
68
-
69
- ```
70
- <FINAL_BRANCH_NAME> = hotfix/<HOTFIX_VERSION>
71
- ```
72
-
73
- 例如 `hotfix/1.1.562`。跳到 Step 4。
74
-
75
- ### 若 `<BRANCH_TYPE>` 為 `feat` 或 `fix`
76
-
77
- 使用 `AskUserQuestion` 工具,請使用者透過「Other」選項自行輸入 branch 子名稱:
78
-
79
- - 問題:`請輸入 branch 子名稱(例如:login-fix、header-refactor)?`
80
- - header:`子名稱`
81
- - 選項:
82
- - 提供 2 個範例選項讓使用者參考(例如 `example-feature`、`example-bug`)
83
- - 明確提示使用者應該選「Other」自行輸入
84
-
85
- 將使用者輸入的值儲存為 `<BRANCH_SUBNAME>`。
86
-
87
- **驗證規則**:
88
-
89
- - 不可為空
90
- - 只允許英文字母、數字、連字號(`-`)、底線(`_`)、斜線(`/`)
91
- - 若不符合規則,請使用者重新輸入
92
-
93
- 組合:
94
-
95
- ```
96
- <FINAL_BRANCH_NAME> = <BRANCH_TYPE>/well/<BRANCH_SUBNAME>
97
- ```
98
-
99
- 範例:
100
-
101
- - `feat/well/login-page`
102
- - `fix/well/header-layout`
103
-
104
- ---
105
-
106
- ## Step 4 — 檢查 branch 是否已存在
107
-
108
- 檢查 `<FINAL_BRANCH_NAME>` 是否已存在(本地或遠端):
109
-
110
- ```bash
111
- git rev-parse --verify <FINAL_BRANCH_NAME> 2>/dev/null
112
- git ls-remote --exit-code --heads origin <FINAL_BRANCH_NAME> 2>/dev/null
113
- ```
114
-
115
- 若已存在,停止並告知使用者:
116
-
117
- - hotfix 場景:該版號的 hotfix 分支已存在,建議改用其他版號或先處理舊分支再重試
118
- - feat / fix 場景:建議改用其他子名稱
119
-
120
- ---
121
-
122
- ## Step 5 — 建立新 branch 並切換
123
-
124
- 從目前 HEAD 建立新分支,**並切換到該分支**:
125
-
126
- ```bash
127
- git checkout -b <FINAL_BRANCH_NAME>
128
- ```
129
-
130
- 若失敗則停止並回報原因。
131
-
132
- ---
133
-
134
- ## Step 6 — 回報結果
135
-
136
- 顯示完成摘要:
137
-
138
- - 新 branch 名稱:`<FINAL_BRANCH_NAME>`
139
- - 基於的 commit SHA(短版,`git log -1 --pretty=format:'%h'`)與訊息首行(`git log -1 --pretty=format:'%s'`)
140
- - 已切換到新分支
141
- - 提示使用者:
142
- - 若要推送到遠端,可執行 `git push -u origin <FINAL_BRANCH_NAME>`