@jetthai/cuora 1.1.439 → 1.1.440
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/.husky/post-checkout +3 -3
- package/.husky/pre-push +1 -1
- package/CHANGELOG.md +22 -0
- package/README.md +30 -5
- package/package.json +1 -1
- package/src/api/auth.js +2 -2
- package/src/machine/auth.js +5 -10
- package/src/machine/deposit/crypto_bank_cash.js +2 -1
- package/src/machine/deposit/crypto_way_cash.js +2 -1
- package/src/machine/user_sign_up.js +5 -4
- package/src/machine/withdraw/withdraw_manual_cash.js +33 -4
- package/src/request/config.js +2 -0
- package/src/util/index.js +1 -2
- package/src/lib/fingerprint_v3_11_12.js +0 -11433
- package/src/util/deviceToken.js +0 -59
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/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,28 @@
|
|
|
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.440](https://github.com/jetthai/cuora-module/compare/v1.1.439...v1.1.440) (2026-06-09)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- **auth:** telegram login 新增 idToken 參數 ([77e870a](https://github.com/jetthai/cuora-module/commit/77e870a0e17082b9d80f97b65247386d9ccc8672))
|
|
10
|
+
- **withdraw:** 現金站手動出款新增雙錢包出款規則閘門 ([1dc6073](https://github.com/jetthai/cuora-module/commit/1dc6073a0df10012ffbcc55d7a85996304f514ff))
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- **withdraw:** 現金站雙錢包出款閘門改用 truthy 比較 enableWithdraw ([833764d](https://github.com/jetthai/cuora-module/commit/833764da303bca6935d8af43fd4c446f7ba2e5c2))
|
|
15
|
+
|
|
16
|
+
## [1.2.0](https://github.com/jetthai/cuora-module/compare/v1.1.439...v1.2.0) (2026-06-09)
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
- **auth:** telegram login 新增 idToken 參數 ([77e870a](https://github.com/jetthai/cuora-module/commit/77e870a0e17082b9d80f97b65247386d9ccc8672))
|
|
21
|
+
- **withdraw:** 現金站手動出款新增雙錢包出款規則閘門 ([1dc6073](https://github.com/jetthai/cuora-module/commit/1dc6073a0df10012ffbcc55d7a85996304f514ff))
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
- **withdraw:** 現金站雙錢包出款閘門改用 truthy 比較 enableWithdraw ([833764d](https://github.com/jetthai/cuora-module/commit/833764da303bca6935d8af43fd4c446f7ba2e5c2))
|
|
26
|
+
|
|
5
27
|
### [1.1.439](https://github.com/jetthai/cuora-module/compare/v1.1.438...v1.1.439) (2026-05-20)
|
|
6
28
|
|
|
7
29
|
### [1.1.438](https://github.com/jetthai/cuora-module/compare/v1.1.437...v1.1.438) (2026-05-18)
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @jetthai/cuora
|
|
2
2
|
|
|
3
|
-
`@jetthai/cuora
|
|
3
|
+
`@jetthai/cuora` 是一個純 ESM JavaScript 函式庫,無建置步驟,原始 `.js` 檔案直接發佈至 npm。透過 XState v4 狀態機整合 API 呼叫與業務邏輯,服務於線上遊戲平台,處理認證、支付(存款/提款)、遊戲管理、活動及即時 WebSocket 通訊。設計用於 Nuxt.js 客戶端應用程式(`ssr: false`)。
|
|
4
4
|
|
|
5
5
|
- **模組格式**:`"type": "module"`
|
|
6
6
|
- **進入點**:`./src/index.js`
|
|
@@ -8,6 +8,28 @@
|
|
|
8
8
|
- **程式碼格式化**:Prettier(不加分號、單引號、2 空格縮排、150 字元行寬、ES5 尾隨逗號)
|
|
9
9
|
- **Pre-commit Hook**:Husky 執行 `npm run format && git add .`
|
|
10
10
|
|
|
11
|
+
## 目錄
|
|
12
|
+
|
|
13
|
+
- [Installation](#installation)
|
|
14
|
+
- [Setup](#setup)
|
|
15
|
+
- [Usage](#usage)
|
|
16
|
+
- [模組匯出](#模組匯出)
|
|
17
|
+
- [Config](#config)
|
|
18
|
+
- [Request](#request)
|
|
19
|
+
- [API](#api)
|
|
20
|
+
- [Machine](#machine)
|
|
21
|
+
- [Utilities](#utilities)
|
|
22
|
+
- [Dependencies](#dependencies)
|
|
23
|
+
- [Architecture](#architecture)
|
|
24
|
+
- [Development](#development)
|
|
25
|
+
- [Git 分支版本發佈流程](#git-分支版本發佈流程)
|
|
26
|
+
- [分支策略](#分支策略)
|
|
27
|
+
- [腳本權責分離](#腳本權責分離)
|
|
28
|
+
- [dev / qa 分支自動版本流程](#dev--qa-分支自動版本流程)
|
|
29
|
+
- [版號計算規則](#版號計算規則)
|
|
30
|
+
- [Husky Hooks 總覽](#husky-hooks-總覽)
|
|
31
|
+
- [License](#license)
|
|
32
|
+
|
|
11
33
|
## Installation
|
|
12
34
|
|
|
13
35
|
```bash
|
|
@@ -136,10 +158,9 @@ storage.set('key', value, ttl)
|
|
|
136
158
|
storage.get('key')
|
|
137
159
|
|
|
138
160
|
// 遊戲類型常數
|
|
139
|
-
constant.
|
|
140
|
-
constant.
|
|
141
|
-
constant.
|
|
142
|
-
constant.SPORT
|
|
161
|
+
constant.GAME_TYPE_LIST // 16 種遊戲類型陣列,每筆為 { typeId, name, gameTypeMappingId }
|
|
162
|
+
constant.MY_FAVORITE // 'MyFavorite'
|
|
163
|
+
constant.GAME_SEARCH // 'GameSearch'
|
|
143
164
|
```
|
|
144
165
|
|
|
145
166
|
## Dependencies
|
|
@@ -281,3 +302,7 @@ git log 發現歷史有 "1.1.430-dev.4"
|
|
|
281
302
|
| `post-merge` | `.husky/post-merge` | (保留,目前無額外操作) |
|
|
282
303
|
|
|
283
304
|
> **注意**:`pre-push` hook 完成推送後會以 `exit 1` 中止原始 push(因為已推送完成),終端會顯示 push 失敗訊息,但實際發佈已成功。以 `Released x.x.x on {branch}` 訊息為準。
|
|
305
|
+
|
|
306
|
+
## License
|
|
307
|
+
|
|
308
|
+
ISC
|
package/package.json
CHANGED
package/src/api/auth.js
CHANGED
|
@@ -5,10 +5,10 @@ export default {
|
|
|
5
5
|
method: 'post',
|
|
6
6
|
isPublic: true,
|
|
7
7
|
}),
|
|
8
|
-
login: ({ username, password, provider, countryCode, phone, email, dt, reCaptchaToken, additionalUserInfo, loginType, isSignature }) => ({
|
|
8
|
+
login: ({ username, password, provider, countryCode, phone, email, dt, reCaptchaToken, additionalUserInfo, loginType, isSignature, idToken }) => ({
|
|
9
9
|
url: 'login',
|
|
10
10
|
method: 'post',
|
|
11
|
-
params: { username, password, provider, countryCode, phone, email, dt, additionalUserInfo, loginType, isSignature },
|
|
11
|
+
params: { username, password, provider, countryCode, phone, email, dt, additionalUserInfo, loginType, isSignature, idToken },
|
|
12
12
|
isPublic: true,
|
|
13
13
|
headers: { 'x-access-captcha': reCaptchaToken },
|
|
14
14
|
}),
|
package/src/machine/auth.js
CHANGED
|
@@ -3,12 +3,11 @@ import { assign, createMachine } from 'xstate'
|
|
|
3
3
|
import auth from '../api/auth.js'
|
|
4
4
|
import user from '../api/user.js'
|
|
5
5
|
import storage from '../util/storage.js'
|
|
6
|
-
import { getDeviceTokenWithRetry } from '../util/deviceToken.js'
|
|
7
6
|
import common from '../api/common.js'
|
|
8
7
|
import pickBy from 'lodash/pickBy.js'
|
|
9
8
|
|
|
10
9
|
export default function (request) {
|
|
11
|
-
const { appSecret, clientId,
|
|
10
|
+
const { appSecret, clientId, sentry, defaultChannel, defaultSubchannel } = request.config
|
|
12
11
|
const tokenKey = `cuora_${clientId}`
|
|
13
12
|
const userKey = `cuora_tempuser`
|
|
14
13
|
const phoneCountryCode = 'phone_countrycode'
|
|
@@ -394,13 +393,14 @@ export default function (request) {
|
|
|
394
393
|
}
|
|
395
394
|
}),
|
|
396
395
|
setLoginTelegram: assign((context, event) => {
|
|
397
|
-
const { loginType, additionalUserInfo, isSignature } = event.data
|
|
396
|
+
const { loginType, additionalUserInfo, isSignature, idToken } = event.data
|
|
398
397
|
return {
|
|
399
398
|
loginData: {
|
|
400
399
|
provider: 'telegram',
|
|
401
400
|
loginType,
|
|
402
401
|
additionalUserInfo,
|
|
403
402
|
isSignature,
|
|
403
|
+
idToken,
|
|
404
404
|
},
|
|
405
405
|
}
|
|
406
406
|
}),
|
|
@@ -467,12 +467,7 @@ export default function (request) {
|
|
|
467
467
|
const { provider, channel, subchannel, fc } = event.data
|
|
468
468
|
const deviceTokenEnable = context.siteConfig?.dtVerify
|
|
469
469
|
|
|
470
|
-
const dt = await
|
|
471
|
-
fpToken,
|
|
472
|
-
sentry,
|
|
473
|
-
hosts: request.hosts,
|
|
474
|
-
enable: deviceTokenEnable,
|
|
475
|
-
})
|
|
470
|
+
const dt = deviceTokenEnable ? await request.config.getDt?.() : undefined
|
|
476
471
|
|
|
477
472
|
const affiliateCode = storage.get('ac')
|
|
478
473
|
const nickname = storage.get('nk')
|
|
@@ -574,7 +569,7 @@ export default function (request) {
|
|
|
574
569
|
if (deviceTokenEnable) {
|
|
575
570
|
const { exist } = await request.send(user.checkDt())
|
|
576
571
|
if (!exist) {
|
|
577
|
-
const dt = await
|
|
572
|
+
const dt = await request.config.getDt?.()
|
|
578
573
|
// 確定有dt再取得updateDt
|
|
579
574
|
if (dt) {
|
|
580
575
|
await request.send(user.updateDt({ dt }))
|
|
@@ -164,6 +164,7 @@ export default function (request, context) {
|
|
|
164
164
|
selectedCrypto: defaultCrypto[0],
|
|
165
165
|
selectedAddress: defaultAddresses[0],
|
|
166
166
|
options: cryptoBank.optional,
|
|
167
|
+
selectedAmount: max(context.promotion?.minimumAmount, defaultCrypto[0]?.minimum || cryptoBank?.minimum, context.selectedAmount, 0),
|
|
167
168
|
}
|
|
168
169
|
}),
|
|
169
170
|
setCrypto: assign((context, event) => {
|
|
@@ -182,7 +183,7 @@ export default function (request, context) {
|
|
|
182
183
|
addresses,
|
|
183
184
|
selectedCrypto: selectedCrypto,
|
|
184
185
|
selectedAddress: addresses[0],
|
|
185
|
-
selectedAmount:
|
|
186
|
+
selectedAmount: max(context.promotion?.minimumAmount, selectedCrypto?.minimum || cryptoBank?.minimum, 0),
|
|
186
187
|
calculation: null,
|
|
187
188
|
options: cryptoBank.optional,
|
|
188
189
|
}
|
|
@@ -153,6 +153,7 @@ export default function (request, context) {
|
|
|
153
153
|
cryptos,
|
|
154
154
|
selectedCrypto: defaultCrypto,
|
|
155
155
|
options: defaultCrypto?.optional || [],
|
|
156
|
+
selectedAmount: max(context.promotion?.minimumAmount, defaultCrypto?.minimum, context.selectedAmount, 0),
|
|
156
157
|
}
|
|
157
158
|
}),
|
|
158
159
|
setCrypto: assign((context, event) => {
|
|
@@ -160,7 +161,7 @@ export default function (request, context) {
|
|
|
160
161
|
const selectedCrypto = cryptos.find((crypto) => crypto.label === event.data.label)
|
|
161
162
|
return {
|
|
162
163
|
selectedCrypto: selectedCrypto,
|
|
163
|
-
selectedAmount:
|
|
164
|
+
selectedAmount: max(context.promotion?.minimumAmount, selectedCrypto?.minimum, 0),
|
|
164
165
|
calculation: null,
|
|
165
166
|
options: selectedCrypto?.optional || [],
|
|
166
167
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import auth from '../api/auth.js'
|
|
3
|
-
import { getDeviceTokenWithRetry } from '../util/deviceToken.js'
|
|
4
3
|
import storage from '../util/storage.js'
|
|
5
4
|
|
|
6
5
|
export default function (request) {
|
|
7
|
-
const {
|
|
6
|
+
const { sentry, defaultChannel, defaultSubchannel } = request.config
|
|
8
7
|
return createMachine(
|
|
9
8
|
{
|
|
10
9
|
id: 'user_sign_up',
|
|
@@ -204,7 +203,7 @@ export default function (request) {
|
|
|
204
203
|
services: {
|
|
205
204
|
authenticate: async (context, event) => {
|
|
206
205
|
const { channel, subchannel, signUpData, deviceTokenEnable } = context
|
|
207
|
-
const dt =
|
|
206
|
+
const dt = deviceTokenEnable ? await request.config.getDt?.() : undefined
|
|
208
207
|
|
|
209
208
|
const affiliateCode = storage.get('ac') || signUpData?.affiliateCode
|
|
210
209
|
const messages = {
|
|
@@ -217,7 +216,9 @@ export default function (request) {
|
|
|
217
216
|
affiliateCode,
|
|
218
217
|
}
|
|
219
218
|
|
|
220
|
-
|
|
219
|
+
// 因 client-pwa-cash PR #805 的問題,暫時註解此 Sentry 上報
|
|
220
|
+
// https://github.com/jetthai/client-pwa-cash/pull/805
|
|
221
|
+
// sentry?.captureMessage(`[SignUp] Authenticate Data: ${JSON.stringify(messages)}`, { level: 'info' })
|
|
221
222
|
|
|
222
223
|
const referralObj = {}
|
|
223
224
|
if (![undefined, 'undefined', null, 'null'].includes(affiliateCode)) {
|
|
@@ -3,13 +3,14 @@ import payment from '../../api/payment.js'
|
|
|
3
3
|
import user from '../../api/user.js'
|
|
4
4
|
|
|
5
5
|
export default function (request, context) {
|
|
6
|
-
const { paymentDetail = [] } = context || {}
|
|
6
|
+
const { paymentDetail = [], doubleWalletWithdrawLimitCheck = '0' } = context || {}
|
|
7
7
|
return createMachine(
|
|
8
8
|
{
|
|
9
9
|
id: 'withdraw_manual_cash',
|
|
10
10
|
initial: 'loading',
|
|
11
11
|
context: {
|
|
12
12
|
paymentDetail,
|
|
13
|
+
doubleWalletWithdrawLimitCheck,
|
|
13
14
|
currentPayment: null,
|
|
14
15
|
banks: [],
|
|
15
16
|
paymentInfo: null,
|
|
@@ -234,11 +235,39 @@ export default function (request, context) {
|
|
|
234
235
|
},
|
|
235
236
|
},
|
|
236
237
|
services: {
|
|
238
|
+
// 雙錢包出款規則閘門(對齊 client-pwa-ssr useWithdrawManual.initialize 流程):
|
|
239
|
+
// - '0':只抓 CASH withdrawRule
|
|
240
|
+
// - '1':只抓 ACTIVITY withdrawRule(不論達標與否,CASH 規則不參與閘門,省一次 API)
|
|
241
|
+
// - '2' + ACTIVITY 不可提:略過 CASH withdrawRule(少一次 API)
|
|
242
|
+
// - '2' + ACTIVITY 達標:續抓 CASH withdrawRule 作為最終出款依據
|
|
237
243
|
fetchInitData: async (context, event) => {
|
|
238
|
-
const { paymentDetail = [] } = context
|
|
244
|
+
const { paymentDetail = [], doubleWalletWithdrawLimitCheck = '0' } = context
|
|
239
245
|
const currentPayment = paymentDetail.find((element) => element.category === 'manual' && element.transferType === 'withdraw')
|
|
240
246
|
|
|
241
|
-
|
|
247
|
+
let prefetchedRule = null
|
|
248
|
+
if (doubleWalletWithdrawLimitCheck === '2' || doubleWalletWithdrawLimitCheck === '1') {
|
|
249
|
+
const activityRule = await request.send(payment.getDoubleWalletWithdrawRule({ walletType: 'ACTIVITY' }))
|
|
250
|
+
// '1' 模式僅看 ACTIVITY,'2' 模式 ACTIVITY 不可提則 CASH 不參與閘門 — 兩種情況都用 activityRule 為依據。
|
|
251
|
+
// enableWithdraw 用 truthy 比較對齊 client-pwa-ssr useWithdrawManual(!enableWithdraw.value),避免 backend 回傳非 boolean truthy 值(如 1)時誤判。
|
|
252
|
+
if (doubleWalletWithdrawLimitCheck === '1' || !activityRule?.enableWithdraw) {
|
|
253
|
+
prefetchedRule = activityRule
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (prefetchedRule) {
|
|
258
|
+
const [paymentInfo, orders] = await Promise.all([
|
|
259
|
+
request.send(payment.getBindingPaymentInfo()),
|
|
260
|
+
request.send(payment.getPendingOrder({ transferType: 'WITHDRAW' })),
|
|
261
|
+
])
|
|
262
|
+
return {
|
|
263
|
+
currentPayment,
|
|
264
|
+
paymentInfo,
|
|
265
|
+
withdrawRule: prefetchedRule,
|
|
266
|
+
processing: orders[0],
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const [paymentInfo, cashRule, orders] = await Promise.all([
|
|
242
271
|
request.send(payment.getBindingPaymentInfo()),
|
|
243
272
|
request.send(payment.getDoubleWalletWithdrawRule({ walletType: 'CASH' })),
|
|
244
273
|
request.send(payment.getPendingOrder({ transferType: 'WITHDRAW' })),
|
|
@@ -247,7 +276,7 @@ export default function (request, context) {
|
|
|
247
276
|
return {
|
|
248
277
|
currentPayment,
|
|
249
278
|
paymentInfo,
|
|
250
|
-
withdrawRule,
|
|
279
|
+
withdrawRule: cashRule,
|
|
251
280
|
processing: orders[0],
|
|
252
281
|
}
|
|
253
282
|
},
|
package/src/request/config.js
CHANGED
|
@@ -16,6 +16,7 @@ export default class Config {
|
|
|
16
16
|
defaultSubchannel,
|
|
17
17
|
socketURL,
|
|
18
18
|
bucketName,
|
|
19
|
+
getDt,
|
|
19
20
|
}) {
|
|
20
21
|
this.apiURL = apiURL
|
|
21
22
|
this.apiVersion = apiVersion
|
|
@@ -30,6 +31,7 @@ export default class Config {
|
|
|
30
31
|
this.defaultSubchannel = defaultSubchannel
|
|
31
32
|
this.socketURL = socketURL
|
|
32
33
|
this.bucketName = bucketName
|
|
34
|
+
this.getDt = getDt
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
setApiURL(url) {
|
package/src/util/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { getDeviceToken, getDeviceTokenWithRetry } from './deviceToken.js'
|
|
2
1
|
import storage from './storage.js'
|
|
3
2
|
import * as constant from './constant.js'
|
|
4
3
|
import { max } from './math.js'
|
|
5
4
|
|
|
6
|
-
export default {
|
|
5
|
+
export default {}
|
|
7
6
|
export { constant, storage, max }
|