@jetthai/cuora 1.1.427 → 1.1.428-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,19 @@
1
1
  #!/usr/bin/env sh
2
2
 
3
- # Auto version bump on dev/qa branches
4
- # Called from pre-push hook — receives remote name as $1
3
+ # 在 dev/qa 分支自動升版並發布
4
+ # 由 pre-push hook 呼叫,$1 為遠端名稱(預設 origin)
5
5
 
6
+ # 取得遠端名稱(未傳入則預設為 origin)
6
7
  REMOTE=${1:-origin}
8
+ # 取得當前分支名稱
7
9
  BRANCH=$(git rev-parse --abbrev-ref HEAD)
8
10
 
11
+ # 僅在 dev 或 qa 分支執行自動升版流程
9
12
  if [ "$BRANCH" = "dev" ] || [ "$BRANCH" = "qa" ]; then
10
- # Compute next prerelease version (scans git log to prevent regression)
13
+ # 透過 Node 腳本計算下一個 prerelease 版號(會掃描 git log 避免版號回退)
11
14
  NEXT_VERSION=$(node scripts/auto-version.js)
12
15
 
16
+ # 若版號無變化,跳過發布流程
13
17
  if [ -z "$NEXT_VERSION" ]; then
14
18
  echo "Version unchanged, skipping release."
15
19
  exit 0
@@ -18,12 +22,12 @@ if [ "$BRANCH" = "dev" ] || [ "$BRANCH" = "qa" ]; then
18
22
  echo "Branch: $BRANCH"
19
23
  echo "Next version: $NEXT_VERSION"
20
24
 
21
- # Bump version, update CHANGELOG, create commit + tag
25
+ # 使用 standard-version 升版:更新 package.json 版號、產生 CHANGELOG、建立 commit + tag
22
26
  npx standard-version --release-as "$NEXT_VERSION"
23
27
 
24
- # Push + npm publish
28
+ # 推送到遠端並執行 npm publish
25
29
  node scripts/branch-auto-npm-publish.js "$REMOTE" "$BRANCH"
26
30
 
27
- # Abort the original git push (scripts already pushed)
31
+ # 以 exit 1 中斷原本的 git push(因為上面的腳本已經完成推送了)
28
32
  exit 1
29
33
  fi
@@ -1,21 +1,23 @@
1
+ // 自動推送 commit + tag 並發布到 npm
2
+ // 由 auto-version.sh 呼叫,接收參數:remote(遠端名稱)、branch(分支名稱)
3
+
1
4
  import { execSync } from 'node:child_process'
2
5
  import { readFileSync } from 'node:fs'
3
6
 
7
+ // 取得遠端名稱與分支名稱(預設為 origin 和當前分支)
4
8
  const remote = process.argv[2] || 'origin'
5
9
  const branch = process.argv[3] || execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf8' }).trim()
6
10
 
11
+ // 讀取 package.json 中的版號(此時已被 standard-version 更新過)
7
12
  const { version } = JSON.parse(readFileSync('package.json', 'utf8'))
8
13
 
9
14
  console.log(`Branch: ${branch}`)
10
15
  console.log(`Version: ${version}`)
11
16
 
12
- // Pull remote changes before push (avoid rejection)
13
- execSync(`git pull --rebase --no-verify ${remote} ${branch}`, { stdio: 'inherit' })
14
-
15
- // Push commit and tags
17
+ // 推送 commit 與 tag 到遠端(--no-verify 避免觸發 pre-push hook 造成無限迴圈)
16
18
  execSync(`git push --no-verify --follow-tags ${remote} ${branch}`, { stdio: 'inherit' })
17
19
 
18
- // Publish to npm with branch dist-tag
20
+ // 發布到 npm,使用分支名稱作為 dist-tag(例如 npm install @jetthai/cuora@dev)
19
21
  try {
20
22
  execSync(`npm publish --tag ${branch}`, { stdio: 'inherit' })
21
23
  console.log(`✅ npm publish succeeded: ${version} (tag: ${branch})`)
@@ -1,22 +1,24 @@
1
1
  #!/usr/bin/env sh
2
2
 
3
- # Delete local and remote tags that do NOT match the compliant pattern
4
- # Compliant pattern: v1.2.3 (e.g., v0.1.0, v1.12.123)
3
+ # 清理不符合規範的 git tag(本地 + 遠端)
4
+ # 合規格式:v1.2.3(例如 v0.1.0、v1.12.123)
5
5
  #
6
- # Deletion rules (any match triggers deletion):
7
- # 1. Current branch is dev or qa
8
- # 2. Tag's commit is not reachable from any branch
9
- # 3. Tag's commit is already merged into master
6
+ # 刪除規則(符合任一條件即刪除):
7
+ # 1. 當前分支為 dev 或 qa
8
+ # 2. 該 tag 所指向的 commit 不屬於任何分支(孤立 commit)
9
+ # 3. 該 tag 所指向的 commit 已被合併進 master
10
10
  PATTERN="^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$"
11
11
 
12
+ # 取得當前分支名稱
12
13
  BRANCH=$(git rev-parse --abbrev-ref HEAD)
13
14
 
14
- # Find the latest tag (by creation date) regardless of format
15
+ # 取得最新的 tag(依建立時間排序),無論格式是否合規都會保留
15
16
  LATEST_TAG=$(git tag -l --sort=-creatordate | head -n 1)
16
17
 
17
- # Collect non-compliant tags
18
+ # 篩選出所有不符合合規格式的 tag
18
19
  TAGS=$(git tag -l | grep -vE "$PATTERN")
19
20
 
21
+ # 若沒有不合規的 tag,直接結束
20
22
  if [ -z "$TAGS" ]; then
21
23
  echo "No non-compliant tags found."
22
24
  exit 0
@@ -24,7 +26,9 @@ fi
24
26
 
25
27
  echo "Latest tag (preserved): $LATEST_TAG"
26
28
 
29
+ # 逐一檢查每個不合規的 tag
27
30
  for TAG in $TAGS; do
31
+ # 最新的 tag 一律跳過,避免誤刪正在使用的版本
28
32
  if [ "$TAG" = "$LATEST_TAG" ]; then
29
33
  echo "Skipping tag $TAG (latest tag)"
30
34
  continue
@@ -33,13 +37,13 @@ for TAG in $TAGS; do
33
37
  SHOULD_DELETE=false
34
38
  REASON=""
35
39
 
36
- # Rule 1: Current branch is dev or qa
40
+ # 規則 1:當前在 dev 或 qa 分支,直接刪除所有不合規 tag
37
41
  if [ "$BRANCH" = "dev" ] || [ "$BRANCH" = "qa" ]; then
38
42
  SHOULD_DELETE=true
39
43
  REASON="on $BRANCH branch"
40
44
  fi
41
45
 
42
- # Rule 2: Tag's commit is not reachable from any branch
46
+ # 規則 2:該 tag 的 commit 不屬於任何分支(孤立的 commit)
43
47
  if [ "$SHOULD_DELETE" = false ]; then
44
48
  BRANCHES=$(git branch -a --contains "$TAG" 2>/dev/null)
45
49
  if [ -z "$BRANCHES" ]; then
@@ -48,7 +52,7 @@ for TAG in $TAGS; do
48
52
  fi
49
53
  fi
50
54
 
51
- # Rule 3: Tag's commit is already merged into master
55
+ # 規則 3:該 tag 的 commit 已合併進 master(代表該 tag 已無保留必要)
52
56
  if [ "$SHOULD_DELETE" = false ]; then
53
57
  if git merge-base --is-ancestor "$TAG" master 2>/dev/null; then
54
58
  SHOULD_DELETE=true
@@ -56,6 +60,7 @@ for TAG in $TAGS; do
56
60
  fi
57
61
  fi
58
62
 
63
+ # 執行刪除:先刪遠端再刪本地,遠端刪除失敗不中斷流程
59
64
  if [ "$SHOULD_DELETE" = true ]; then
60
65
  echo "Deleting tag $TAG ($REASON)"
61
66
  git push origin --delete "$TAG" --no-verify 2>/dev/null || true
@@ -120,4 +120,9 @@ export default {
120
120
  method: 'post',
121
121
  params: { startDate, endDate, appSecret },
122
122
  }),
123
+ getMissionHistory: ({ activityNo, appSecret }) => ({
124
+ url: 'activities/mission-history',
125
+ method: 'get',
126
+ params: { activityNo, appSecret },
127
+ }),
123
128
  }
@@ -110,6 +110,28 @@ export default function (request) {
110
110
  },
111
111
  },
112
112
  otpChecking: {
113
+ initial: 'pending',
114
+ states: {
115
+ pending: {
116
+ after: {
117
+ TIMEOUT: {
118
+ target: 'fetching',
119
+ },
120
+ },
121
+ },
122
+ fetching: {
123
+ invoke: {
124
+ src: 'fetchUserInfo',
125
+ onDone: {
126
+ target: 'pending',
127
+ actions: ['setUserInfo', 'extendToken'],
128
+ },
129
+ onError: {
130
+ target: 'pending',
131
+ },
132
+ },
133
+ },
134
+ },
113
135
  on: {
114
136
  OTP_VERIFIED: {
115
137
  target: 'loginSuccess',
@@ -56,8 +56,9 @@ export default function (request, context) {
56
56
  target: 'calculated',
57
57
  actions: 'setCalculation',
58
58
  },
59
+ // 計算失敗回到 loaded,避免進入 calculated 造成 UI 與 state 不一致
59
60
  onError: {
60
- target: 'calculated',
61
+ target: 'loaded',
61
62
  },
62
63
  },
63
64
  },
@@ -167,14 +168,22 @@ export default function (request, context) {
167
168
  setAmount: assign((context, event) => {
168
169
  // 現金網可自由填額度,grandTotalEnable 欄位感覺不再需要?
169
170
  if (context.selectedCrypto?.grandTotalEnable === 1) {
171
+ // 累加模式:用 Math.max 確保累加結果不低於 0
172
+ const result = preciseAdd(`${parseFloat(context.selectedAmount || 0)}`, `${parseFloat(event.data)}`)
170
173
  return {
171
- selectedAmount: preciseAdd(`${parseFloat(context.selectedAmount || 0)}`, `${parseFloat(event.data)}`),
174
+ selectedAmount: Math.max(result, 0),
172
175
  }
173
176
  } else {
177
+ // 直接設定模式:拒絕 NaN 及負數,返回空物件使 context 不變
178
+ const val = parseFloat(event.data)
179
+ if (isNaN(val) || val < 0) return {}
174
180
  return { selectedAmount: event.data }
175
181
  }
176
182
  }),
177
183
  inputAmount: assign((context, event) => {
184
+ // 驗證輸入值:NaN 或負數時忽略此次輸入
185
+ const val = parseFloat(event.data)
186
+ if (isNaN(val) || val < 0) return {}
178
187
  return { selectedAmount: event.data }
179
188
  }),
180
189
  setAddress: assign((context, event) => {
@@ -231,9 +240,17 @@ export default function (request, context) {
231
240
  const { selectedCrypto, selectedAmount } = context
232
241
  return selectedCrypto && selectedAmount && selectedCrypto.minimum <= +selectedAmount && +selectedAmount <= selectedCrypto.maximum
233
242
  },
243
+ // 提交前最後一道 guard:重新驗證 amount 的合法性(與 isCalculable 同等嚴格)
234
244
  isSubmittable: (context, event) => {
235
245
  const { selectedCrypto, selectedAmount, calculation } = context
236
- return selectedCrypto && selectedAmount && calculation
246
+ return (
247
+ selectedCrypto &&
248
+ selectedAmount &&
249
+ +selectedAmount > 0 &&
250
+ selectedCrypto.minimum <= +selectedAmount &&
251
+ +selectedAmount <= selectedCrypto.maximum &&
252
+ calculation
253
+ )
237
254
  },
238
255
  },
239
256
  services: {
@@ -250,10 +267,15 @@ export default function (request, context) {
250
267
  },
251
268
  submitDeposit: async (context, event) => {
252
269
  const { selectedCrypto, selectedAmount, sourceAddress, promotion } = context
270
+ // 防禦性檢查:將 amount 轉為數字型別,並驗證範圍合法性,避免非法金額送出 API
271
+ const amount = +selectedAmount
272
+ if (!amount || amount <= 0 || amount < selectedCrypto.minimum || amount > selectedCrypto.maximum) {
273
+ throw new Error('INVALID_AMOUNT')
274
+ }
253
275
  return await request.send(
254
276
  payment.submitDepositTransactionCrypto({
255
277
  method: selectedCrypto.method,
256
- amount: selectedAmount,
278
+ amount: amount,
257
279
  cryptoCurrency: selectedCrypto.channel,
258
280
  cryptoNetwork: selectedCrypto.networkCode,
259
281
  sourceAddress: sourceAddress,
@@ -465,8 +465,10 @@ export default function (request) {
465
465
  const { providerId, gameId, gameTypeId, mappingId, portrait, gameCode, name, gameName } = context.switchGame
466
466
  return { game: { providerId, gameId, gameTypeId, mappingId, portrait: portrait ? 1 : 0, gameCode, name, gameName } }
467
467
  }),
468
+ // 頁面刷新或深層連結時,event.data.walletType 可能為 undefined/null
469
+ // 使用 ?? 確保不會覆蓋 context 中已有的 walletType,避免後端收到 selectedWalletType=null
468
470
  setWalletType: assign((context, event) => {
469
- return { walletType: event.data.walletType }
471
+ return { walletType: event.data.walletType ?? context.walletType }
470
472
  }),
471
473
  setLang: assign((context, event) => {
472
474
  const lang = event.data.locale.replace('-', '_')
@@ -654,7 +656,7 @@ export default function (request) {
654
656
  is_demo: false,
655
657
  is_mobile: isMobile === 'mobile' ? 'y' : null,
656
658
  lang,
657
- selected_wallet_type: walletType,
659
+ selected_wallet_type: walletType || null, // 統一 undefined → null,確保後端收到一致的值
658
660
  return_url: returnProviders.includes(providerId)
659
661
  ? `${window.location.origin}${context.base}return`
660
662
  : window.location.href?.split('?')?.[0], // For providers to return.