@jetthai/cuora 1.1.463-dev.2 → 1.1.463
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/commands/auto-git-flow.md +12 -5
- package/.claude/commands/create-branch.md +142 -0
- package/.claude/commands/sync-ai-prompts.md +1 -88
- package/.claude/settings.local.json +1 -3
- package/.github/copilot-instructions.md +1 -0
- package/.husky/post-checkout +3 -3
- package/.husky/pre-push +1 -1
- package/.prettierignore +1 -2
- package/AGENTS.md +1 -0
- package/AI_PROMPT_SOURCE.md +1 -0
- package/CHANGELOG.md +0 -65
- package/CLAUDE.md +1 -0
- package/GEMINI.md +1 -0
- package/package.json +1 -1
- package/scripts/auto-version.js +0 -1
- package/src/api/activity.js +2 -2
- package/src/index.js +2 -2
- package/src/machine/auth.js +37 -33
- package/src/machine/common.js +21 -11
- package/src/machine/deposit/direct_cash.js +7 -2
- package/src/machine/deposit/loadcard_cash.js +23 -7
- package/src/machine/deposit/qrcode_cash.js +23 -9
- package/src/machine/user_sign_up.js +4 -18
- package/src/util/index.js +1 -3
- package/src/util/amount.js +0 -8
- package/src/util/paramStore.js +0 -139
|
@@ -13,19 +13,25 @@ git checkout master
|
|
|
13
13
|
git fetch --prune
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
刪除已合併至 master 的 remote 分支(排除 master/qa/dev/HEAD):
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
-
git branch -r --merged master | grep -v -E "(master|dev|
|
|
19
|
+
git branch -r --merged origin/master | grep -v -E "(master|qa|dev|HEAD)" | sed 's/origin\///' | xargs -r -I {} git push origin --delete {}
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
刪除已合併至 master 的 local 分支(排除 master/qa/dev):
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
git branch --merged master | grep -v -E "^\*?\s*(master|dev
|
|
25
|
+
git branch --merged master | grep -v -E "^\*?\s*(master|qa|dev)$" | xargs -r git branch -d
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
### Step 5 — 刪除不合規 tags
|
|
29
|
+
|
|
30
|
+
執行 `scripts/clean-tags.sh` 清理不符合正式版號格式的本地及遠端 tags:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
sh scripts/clean-tags.sh
|
|
34
|
+
```
|
|
29
35
|
|
|
30
36
|
---
|
|
31
37
|
|
|
@@ -42,4 +48,5 @@ git checkout master
|
|
|
42
48
|
回報以下資訊:
|
|
43
49
|
|
|
44
50
|
- 刪除了多少已合併分支
|
|
51
|
+
- 刪除了多少不合規 tags
|
|
45
52
|
- 當前所在分支
|
|
@@ -0,0 +1,142 @@
|
|
|
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>`
|
|
@@ -6,96 +6,9 @@
|
|
|
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
|
-
|
|
96
9
|
## Step 1 — 讀取來源檔
|
|
97
10
|
|
|
98
|
-
讀取 `AI_PROMPT_SOURCE.md`
|
|
11
|
+
讀取 `AI_PROMPT_SOURCE.md` 完整內容。
|
|
99
12
|
|
|
100
13
|
---
|
|
101
14
|
|
|
@@ -309,6 +309,7 @@ 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)
|
|
312
313
|
- **Mailbox filtering**: if `customerMessageEnable === false`, the count of CUSTOMER-type messages is deducted from the mailbox total
|
|
313
314
|
|
|
314
315
|
### 2.8 API Request Lifecycle
|
package/.husky/post-checkout
CHANGED
|
@@ -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 "
|
|
22
|
+
echo "分支 '$CURRENT_BRANCH' 有 $LOCAL_AHEAD 個尚未推送的 commit,略過自動拉取。"
|
|
23
23
|
exit 0
|
|
24
24
|
fi
|
|
25
25
|
|
|
26
26
|
# 自動從遠端拉取最新程式碼(使用 rebase 保持線性歷史)
|
|
27
|
-
echo "
|
|
27
|
+
echo "正在從遠端自動拉取 '$CURRENT_BRANCH'..."
|
|
28
28
|
git pull --rebase origin "$CURRENT_BRANCH" || {
|
|
29
|
-
echo "
|
|
29
|
+
echo "拉取 '$CURRENT_BRANCH' 失敗,請手動處理。"
|
|
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 "
|
|
24
|
+
echo "偵測到在 $BRANCH 分支上強制推送,略過 pre-push hooks。"
|
|
25
25
|
exit 0
|
|
26
26
|
fi
|
|
27
27
|
|
package/.prettierignore
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
dist/
|
|
2
|
-
CHANGELOG.md
|
|
1
|
+
dist/
|
package/AGENTS.md
CHANGED
|
@@ -309,6 +309,7 @@ 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)
|
|
312
313
|
- **Mailbox filtering**: if `customerMessageEnable === false`, the count of CUSTOMER-type messages is deducted from the mailbox total
|
|
313
314
|
|
|
314
315
|
### 2.8 API Request Lifecycle
|
package/AI_PROMPT_SOURCE.md
CHANGED
|
@@ -307,6 +307,7 @@ 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 不需瀏覽器追蹤)
|
|
310
311
|
- **信箱過濾**:若 `customerMessageEnable === false`,從信箱總數中扣除 CUSTOMER 類型訊息數
|
|
311
312
|
|
|
312
313
|
### 2.8 API 請求生命週期
|
package/CHANGELOG.md
CHANGED
|
@@ -2,33 +2,6 @@
|
|
|
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.2](https://github.com/jetthai/cuora-module/compare/v1.1.463-dev.1...v1.1.463-dev.2) (2026-08-16)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
### Bug Fixes
|
|
9
|
-
|
|
10
|
-
* **deposit:** 切換存款活動不再重設使用者已選的通道 ([b9c1de2](https://github.com/jetthai/cuora-module/commit/b9c1de2f3665c56f52d7b074e892837e836d02fa))
|
|
11
|
-
|
|
12
|
-
### [1.1.463-dev.1](https://github.com/jetthai/cuora-module/compare/v1.1.463-dev.0...v1.1.463-dev.1) (2026-08-13)
|
|
13
|
-
|
|
14
|
-
### [1.1.463-dev.0](https://github.com/jetthai/cuora-module/compare/v1.1.463...v1.1.463-dev.0) (2026-08-13)
|
|
15
|
-
|
|
16
|
-
### [1.1.455-dev.8](https://github.com/jetthai/cuora-module/compare/v1.1.455...v1.1.455-dev.8) (2026-08-09)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
### Features
|
|
20
|
-
|
|
21
|
-
* **api:** add GeeMee click-id & front-event fields to sendPixel builder ([d33e488](https://github.com/jetthai/cuora-module/commit/d33e488062f81976cff35ea43ea0f2c366a2a615))
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
### Bug Fixes
|
|
25
|
-
|
|
26
|
-
* **error:** 讓新錯誤可覆寫舊狀態避免 SET_ERROR 鎖死 ([4113751](https://github.com/jetthai/cuora-module/commit/4113751ee6cb4ced8fe1dc2fda0ce9fbac21ec06))
|
|
27
|
-
* **request:** 非 public 請求缺少 token 時提前返回,不再送出後端 ([065095e](https://github.com/jetthai/cuora-module/commit/065095e31ffe1cb640f9aaf6c76bbd5c6892355c))
|
|
28
|
-
* **request:** 非 public 請求缺少 token 時改為 reject ERR_A103,觸發登出流程 ([e46281f](https://github.com/jetthai/cuora-module/commit/e46281f3ea16679404160366e4532969c3bf02ff))
|
|
29
|
-
* **user_sign_up:** 明確輸入判定改用 !== undefined,修復三層解析成為死碼 ([770450e](https://github.com/jetthai/cuora-module/commit/770450e6065d42d497504d2f8630c6740ec1e7c4))
|
|
30
|
-
* **withdraw:** 修正法幣提款計算錯誤時的狀態轉移 ([a951ba8](https://github.com/jetthai/cuora-module/commit/a951ba803cccd1564a7dbe2645ea7c8d50f7da31))
|
|
31
|
-
|
|
32
5
|
### [1.1.463](https://github.com/jetthai/cuora-module/compare/v1.1.462...v1.1.463) (2026-08-12)
|
|
33
6
|
|
|
34
7
|
### [1.1.462](https://github.com/jetthai/cuora-module/compare/v1.1.461...v1.1.462) (2026-08-10)
|
|
@@ -45,44 +18,6 @@ All notable changes to this project will be documented in this file. See [standa
|
|
|
45
18
|
|
|
46
19
|
### [1.1.456](https://github.com/jetthai/cuora-module/compare/v1.1.455...v1.1.456) (2026-08-09)
|
|
47
20
|
|
|
48
|
-
### [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)
|
|
49
|
-
|
|
50
|
-
### [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)
|
|
51
|
-
|
|
52
|
-
### [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)
|
|
53
|
-
|
|
54
|
-
### [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)
|
|
55
|
-
|
|
56
|
-
### [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)
|
|
57
|
-
|
|
58
|
-
### [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)
|
|
59
|
-
|
|
60
|
-
### [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)
|
|
61
|
-
|
|
62
|
-
### [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)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
### Bug Fixes
|
|
66
|
-
|
|
67
|
-
- **user_sign_up:** 明確輸入判定改用 !== undefined,修復三層解析成為死碼 ([770450e](https://github.com/jetthai/cuora-module/commit/770450e6065d42d497504d2f8630c6740ec1e7c4))
|
|
68
|
-
|
|
69
|
-
### [1.1.455-dev.0](https://github.com/jetthai/cuora-module/compare/v1.1.455...v1.1.455-dev.0) (2026-08-04)
|
|
70
|
-
|
|
71
|
-
### [1.1.454-dev.0](https://github.com/jetthai/cuora-module/compare/v1.1.453...v1.1.454-dev.0) (2026-07-29)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
### Features
|
|
75
|
-
|
|
76
|
-
- **api:** add GeeMee click-id & front-event fields to sendPixel builder ([d33e488](https://github.com/jetthai/cuora-module/commit/d33e488062f81976cff35ea43ea0f2c366a2a615))
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
### Bug Fixes
|
|
80
|
-
|
|
81
|
-
- **error:** 讓新錯誤可覆寫舊狀態避免 SET_ERROR 鎖死 ([4113751](https://github.com/jetthai/cuora-module/commit/4113751ee6cb4ced8fe1dc2fda0ce9fbac21ec06))
|
|
82
|
-
- **request:** 非 public 請求缺少 token 時提前返回,不再送出後端 ([065095e](https://github.com/jetthai/cuora-module/commit/065095e31ffe1cb640f9aaf6c76bbd5c6892355c))
|
|
83
|
-
- **request:** 非 public 請求缺少 token 時改為 reject ERR_A103,觸發登出流程 ([e46281f](https://github.com/jetthai/cuora-module/commit/e46281f3ea16679404160366e4532969c3bf02ff))
|
|
84
|
-
- **withdraw:** 修正法幣提款計算錯誤時的狀態轉移 ([a951ba8](https://github.com/jetthai/cuora-module/commit/a951ba803cccd1564a7dbe2645ea7c8d50f7da31))
|
|
85
|
-
|
|
86
21
|
### [1.1.455](https://github.com/jetthai/cuora-module/compare/v1.1.453...v1.1.455) (2026-08-03)
|
|
87
22
|
|
|
88
23
|
### Bug Fixes
|
package/CLAUDE.md
CHANGED
|
@@ -309,6 +309,7 @@ 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)
|
|
312
313
|
- **Mailbox filtering**: if `customerMessageEnable === false`, the count of CUSTOMER-type messages is deducted from the mailbox total
|
|
313
314
|
|
|
314
315
|
### 2.8 API Request Lifecycle
|
package/GEMINI.md
CHANGED
|
@@ -309,6 +309,7 @@ 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)
|
|
312
313
|
- **Mailbox filtering**: if `customerMessageEnable === false`, the count of CUSTOMER-type messages is deducted from the mailbox total
|
|
313
314
|
|
|
314
315
|
### 2.8 API Request Lifecycle
|
package/package.json
CHANGED
package/scripts/auto-version.js
CHANGED
package/src/api/activity.js
CHANGED
|
@@ -130,9 +130,9 @@ export default {
|
|
|
130
130
|
method: 'get',
|
|
131
131
|
params: { appSecret },
|
|
132
132
|
}),
|
|
133
|
-
getProgressDetail: ({ appSecret
|
|
133
|
+
getProgressDetail: ({ appSecret }) => ({
|
|
134
134
|
url: 'activities/progress-details',
|
|
135
135
|
method: 'get',
|
|
136
|
-
params: { appSecret
|
|
136
|
+
params: { appSecret },
|
|
137
137
|
}),
|
|
138
138
|
}
|
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
|
|
5
|
+
import util, { constant, storage } from './util/index.js'
|
|
6
6
|
|
|
7
|
-
export { api, machine, Request, Config, util, constant, storage
|
|
7
|
+
export { api, machine, Request, Config, util, constant, storage }
|
package/src/machine/auth.js
CHANGED
|
@@ -5,7 +5,6 @@ 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'
|
|
9
8
|
|
|
10
9
|
export default function (request) {
|
|
11
10
|
const { appSecret, clientId, sentry } = request.config
|
|
@@ -470,18 +469,7 @@ export default function (request) {
|
|
|
470
469
|
|
|
471
470
|
const dt = deviceTokenEnable ? await request.config.getDt?.() : undefined
|
|
472
471
|
|
|
473
|
-
|
|
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',先 normalize 才不會蓋掉網址/儲存層的真值
|
|
479
|
-
const friendCode = normalize(fc) || readParamFromLocation(FC_KEYS).value
|
|
480
|
-
|
|
481
|
-
// 本段結尾以 window.location.href 離站,離站後 SPA 記憶體全丟;導頁前先落地雙寫
|
|
482
|
-
writeParam('ac', affiliateCode, { sentry })
|
|
483
|
-
writeParam('fc', friendCode, { sentry })
|
|
484
|
-
|
|
472
|
+
const affiliateCode = storage.get('ac')
|
|
485
473
|
const nickname = storage.get('nk')
|
|
486
474
|
const phone = storage.get('tp_phone')
|
|
487
475
|
const countryCode = storage.get('tp_countryCode')
|
|
@@ -490,30 +478,35 @@ export default function (request) {
|
|
|
490
478
|
const messages = {
|
|
491
479
|
url: window.location.href,
|
|
492
480
|
affiliateCode,
|
|
493
|
-
acSource: hasExplicitAc ? 'event' : acRead.from,
|
|
494
481
|
nickname,
|
|
495
482
|
}
|
|
496
483
|
|
|
497
484
|
sentry?.captureMessage(`[Auth] RedirectTo3Party Data: ${JSON.stringify(messages)}`, { level: 'info' })
|
|
498
485
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
)
|
|
486
|
+
const referralObj = {}
|
|
487
|
+
if (![undefined, 'undefined', null, 'null'].includes(affiliateCode)) {
|
|
488
|
+
referralObj.ac = affiliateCode
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
if (![undefined, 'undefined', null, 'null'].includes(nickname)) {
|
|
492
|
+
referralObj.nick_name = nickname
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
if (![undefined, 'undefined', null, 'null'].includes(phone)) {
|
|
496
|
+
referralObj.phone = phone
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
if (![undefined, 'undefined', null, 'null'].includes(countryCode)) {
|
|
500
|
+
referralObj.countryCode = countryCode
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
if (![undefined, 'undefined', null, 'null'].includes(email)) {
|
|
504
|
+
referralObj.email = email
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
if (![undefined, 'undefined', null, 'null'].includes(birthday)) {
|
|
508
|
+
referralObj.birthday = birthday
|
|
509
|
+
}
|
|
517
510
|
|
|
518
511
|
storage.remove('tp_phone')
|
|
519
512
|
storage.remove('tp_countryCode')
|
|
@@ -522,7 +515,18 @@ export default function (request) {
|
|
|
522
515
|
|
|
523
516
|
const fullURL = request.config.fullURL
|
|
524
517
|
|
|
525
|
-
const redirectURL = urljoin(
|
|
518
|
+
const redirectURL = urljoin(
|
|
519
|
+
fullURL,
|
|
520
|
+
'login?' +
|
|
521
|
+
new URLSearchParams({
|
|
522
|
+
provider,
|
|
523
|
+
redirectURI: `${window.location.protocol}//${window.location.host}${context.base}`,
|
|
524
|
+
...referralObj,
|
|
525
|
+
dt,
|
|
526
|
+
platform: 'pwa',
|
|
527
|
+
fc,
|
|
528
|
+
}).toString()
|
|
529
|
+
)
|
|
526
530
|
|
|
527
531
|
window.location.href = redirectURL
|
|
528
532
|
},
|
package/src/machine/common.js
CHANGED
|
@@ -3,10 +3,9 @@ import { assign, createMachine } from 'xstate'
|
|
|
3
3
|
import pickBy from 'lodash/pickBy.js'
|
|
4
4
|
import api from '../api/common.js'
|
|
5
5
|
import storage from '../util/storage.js'
|
|
6
|
-
import { readParam, writeParam, AC_KEYS, FC_KEYS } from '../util/paramStore.js'
|
|
7
6
|
|
|
8
7
|
export default function (request) {
|
|
9
|
-
const { appSecret
|
|
8
|
+
const { appSecret } = request.config
|
|
10
9
|
return createMachine(
|
|
11
10
|
{
|
|
12
11
|
id: 'common',
|
|
@@ -277,17 +276,28 @@ export default function (request) {
|
|
|
277
276
|
kpix,
|
|
278
277
|
}
|
|
279
278
|
}),
|
|
280
|
-
setAgent: assign(() => {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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')
|
|
284
287
|
|
|
285
|
-
|
|
286
|
-
|
|
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
|
+
})
|
|
287
296
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
297
|
+
return {
|
|
298
|
+
affiliateCode,
|
|
299
|
+
friendCode,
|
|
300
|
+
}
|
|
291
301
|
}
|
|
292
302
|
}),
|
|
293
303
|
clearAnnouncements: assign((context, event) => {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import payment from '../../api/payment.js'
|
|
3
|
-
import { isAmountInRange } from '../../util/amount.js'
|
|
4
3
|
|
|
5
4
|
export default function (request, context) {
|
|
6
5
|
const { paymentDetail = [], promotion, selectedAmount } = context || {}
|
|
@@ -178,7 +177,13 @@ export default function (request, context) {
|
|
|
178
177
|
isPromotionChanged: (context, event) => {
|
|
179
178
|
return event.data?.promotionsNo !== context.promotion?.promotionsNo
|
|
180
179
|
},
|
|
181
|
-
isCalculable: (
|
|
180
|
+
isCalculable: (context, event) => {
|
|
181
|
+
const {
|
|
182
|
+
selectedAmount,
|
|
183
|
+
selectedDirect: { maximum, minimum },
|
|
184
|
+
} = context
|
|
185
|
+
return selectedAmount && minimum <= +selectedAmount && +selectedAmount <= maximum
|
|
186
|
+
},
|
|
182
187
|
isSubmittable: (context, event) => {
|
|
183
188
|
const { selectedAmount, selectedDirect, selectedUserBank } = context
|
|
184
189
|
return selectedAmount && selectedDirect && selectedUserBank
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import payment from '../../api/payment.js'
|
|
3
|
-
import { isAmountInRange } from '../../util/amount.js'
|
|
4
3
|
|
|
5
4
|
export default function (request, context) {
|
|
6
5
|
const { paymentDetail = [], promotion, selectedAmount } = context || {}
|
|
@@ -34,7 +33,22 @@ export default function (request, context) {
|
|
|
34
33
|
debouncing: {
|
|
35
34
|
entry: 'clearCalculation',
|
|
36
35
|
after: {
|
|
37
|
-
1000: [
|
|
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
|
+
],
|
|
38
52
|
},
|
|
39
53
|
},
|
|
40
54
|
calculating: {
|
|
@@ -109,11 +123,14 @@ export default function (request, context) {
|
|
|
109
123
|
}
|
|
110
124
|
}),
|
|
111
125
|
setPromotion: assign((context, event) => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
126
|
+
const promotion = event.data
|
|
127
|
+
const loadcards = context.loadcards
|
|
128
|
+
const selectedLoadcard = loadcards[0]
|
|
115
129
|
return {
|
|
116
|
-
promotion
|
|
130
|
+
promotion,
|
|
131
|
+
loadcards,
|
|
132
|
+
selectedLoadcard,
|
|
133
|
+
options: selectedLoadcard?.optional,
|
|
117
134
|
calculation: null,
|
|
118
135
|
}
|
|
119
136
|
}),
|
|
@@ -166,7 +183,6 @@ export default function (request, context) {
|
|
|
166
183
|
isPromotionChanged: (context, event) => {
|
|
167
184
|
return event.data?.promotionsNo !== context.promotion?.promotionsNo
|
|
168
185
|
},
|
|
169
|
-
isCalculable: ({ selectedLoadcard, selectedAmount }) => isAmountInRange(selectedAmount, selectedLoadcard),
|
|
170
186
|
},
|
|
171
187
|
services: {
|
|
172
188
|
fetchCalculation: async (context, event) => {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import payment from '../../api/payment.js'
|
|
3
|
-
import { isAmountInRange } from '../../util/amount.js'
|
|
4
3
|
|
|
5
4
|
export default function (request, context) {
|
|
6
5
|
const { paymentDetail = [], promotion, selectedAmount } = context || {}
|
|
@@ -46,7 +45,22 @@ export default function (request, context) {
|
|
|
46
45
|
debouncing: {
|
|
47
46
|
entry: 'clearCalculation',
|
|
48
47
|
after: {
|
|
49
|
-
1000: [
|
|
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
|
+
],
|
|
50
64
|
},
|
|
51
65
|
},
|
|
52
66
|
calculating: {
|
|
@@ -65,7 +79,6 @@ export default function (request, context) {
|
|
|
65
79
|
on: {
|
|
66
80
|
SUBMIT: {
|
|
67
81
|
target: 'submitting',
|
|
68
|
-
cond: 'isSubmittable',
|
|
69
82
|
},
|
|
70
83
|
},
|
|
71
84
|
},
|
|
@@ -121,11 +134,14 @@ export default function (request, context) {
|
|
|
121
134
|
}
|
|
122
135
|
}),
|
|
123
136
|
setPromotion: assign((context, event) => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
137
|
+
const promotion = event.data
|
|
138
|
+
const qrcodes = context.qrcodes
|
|
139
|
+
const selectedQrcode = qrcodes[0]
|
|
127
140
|
return {
|
|
128
|
-
promotion
|
|
141
|
+
promotion,
|
|
142
|
+
qrcodes,
|
|
143
|
+
selectedQrcode,
|
|
144
|
+
options: selectedQrcode?.optional,
|
|
129
145
|
calculation: null,
|
|
130
146
|
}
|
|
131
147
|
}),
|
|
@@ -179,8 +195,6 @@ export default function (request, context) {
|
|
|
179
195
|
hasQrcodeMethods: (context, event) => {
|
|
180
196
|
return context.paymentDetail?.filter((element) => element.category === context.currentCategory).length > 0
|
|
181
197
|
},
|
|
182
|
-
isCalculable: ({ selectedQrcode, selectedAmount }) => isAmountInRange(selectedAmount, selectedQrcode),
|
|
183
|
-
isSubmittable: ({ selectedQrcode, selectedAmount }) => isAmountInRange(selectedAmount, selectedQrcode),
|
|
184
198
|
},
|
|
185
199
|
services: {
|
|
186
200
|
fetchCalculation: async (context, event) => {
|
|
@@ -1,7 +1,6 @@
|
|
|
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'
|
|
5
4
|
|
|
6
5
|
// 註冊強制綁定多型出款:轉發各綁定型別欄位(BANK / CRYPTO / EWALLET),只帶有值的欄位
|
|
7
6
|
const BIND_FIELDS = [
|
|
@@ -84,8 +83,7 @@ export default function (request) {
|
|
|
84
83
|
}),
|
|
85
84
|
setFriendCode: assign((context, event) => {
|
|
86
85
|
const { fc } = event.data
|
|
87
|
-
|
|
88
|
-
return { fc: normalize(fc) }
|
|
86
|
+
return { fc }
|
|
89
87
|
}),
|
|
90
88
|
setSignUpId: assign((context, event) => {
|
|
91
89
|
const {
|
|
@@ -106,7 +104,6 @@ export default function (request) {
|
|
|
106
104
|
return {
|
|
107
105
|
signUpData: {
|
|
108
106
|
provider: 'local',
|
|
109
|
-
birthday,
|
|
110
107
|
...pickBindData(event.data),
|
|
111
108
|
birthday,
|
|
112
109
|
email,
|
|
@@ -130,7 +127,6 @@ export default function (request) {
|
|
|
130
127
|
return {
|
|
131
128
|
signUpData: {
|
|
132
129
|
provider: 'phone',
|
|
133
|
-
birthday,
|
|
134
130
|
...pickBindData(event.data),
|
|
135
131
|
birthday,
|
|
136
132
|
email,
|
|
@@ -153,7 +149,6 @@ export default function (request) {
|
|
|
153
149
|
return {
|
|
154
150
|
signUpData: {
|
|
155
151
|
provider: 'email',
|
|
156
|
-
birthday,
|
|
157
152
|
...pickBindData(event.data),
|
|
158
153
|
birthday,
|
|
159
154
|
email,
|
|
@@ -193,19 +188,10 @@ export default function (request) {
|
|
|
193
188
|
const { signUpData, deviceTokenEnable } = context
|
|
194
189
|
const dt = deviceTokenEnable ? await request.config.getDt?.() : undefined
|
|
195
190
|
|
|
196
|
-
|
|
197
|
-
// 判定用 `!== undefined` 而非 hasOwnProperty:上面的 setSignUpId/Phone/Email 是以解構寫入
|
|
198
|
-
// signUpData,宿主沒帶時 key 仍然存在(值為 undefined),hasOwnProperty 會恆為 true、
|
|
199
|
-
// 讓三層解析變成死碼。也不能用 `||`,否則使用者刻意清空送出的空字串會被吃掉、
|
|
200
|
-
// 退回三層解析把剛清掉的舊代理碼從網址撿回來。
|
|
201
|
-
const { affiliateCode: explicitAffiliateCode, ...signUpRest } = signUpData || {}
|
|
202
|
-
const hasExplicitAc = explicitAffiliateCode !== undefined
|
|
203
|
-
const acRead = readParamFromLocation(AC_KEYS)
|
|
204
|
-
const affiliateCode = hasExplicitAc ? normalize(explicitAffiliateCode) : acRead.value
|
|
191
|
+
const affiliateCode = storage.get('ac') || signUpData?.affiliateCode
|
|
205
192
|
const messages = {
|
|
206
193
|
url: window.location.href,
|
|
207
194
|
affiliateCode,
|
|
208
|
-
acSource: hasExplicitAc ? 'signUpData' : acRead.from,
|
|
209
195
|
}
|
|
210
196
|
|
|
211
197
|
// 因 client-pwa-cash PR #805 的問題,暫時註解此 Sentry 上報
|
|
@@ -219,11 +205,11 @@ export default function (request) {
|
|
|
219
205
|
|
|
220
206
|
return await request.send(
|
|
221
207
|
auth.register({
|
|
222
|
-
...
|
|
208
|
+
...signUpData,
|
|
223
209
|
...referralObj,
|
|
224
210
|
dt,
|
|
225
211
|
reCaptchaToken: context.reCaptchaToken,
|
|
226
|
-
fc: context.fc
|
|
212
|
+
fc: context.fc,
|
|
227
213
|
})
|
|
228
214
|
)
|
|
229
215
|
},
|
package/src/util/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import storage from './storage.js'
|
|
2
|
-
import paramStore from './paramStore.js'
|
|
3
2
|
import * as constant from './constant.js'
|
|
4
3
|
import { max } from './math.js'
|
|
5
|
-
import { isAmountInRange } from './amount.js'
|
|
6
4
|
|
|
7
5
|
export default {}
|
|
8
|
-
export { constant, storage,
|
|
6
|
+
export { constant, storage, max }
|
package/src/util/amount.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
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/paramStore.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
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 }
|