@jetthai/cuora 1.1.413-qa-1 → 1.1.413

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/CHANGELOG.md CHANGED
@@ -2,12 +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.413-qa-1](https://github.com/jetthai/cuora-module/compare/v1.1.413...v1.1.413-qa-1) (2026-03-02)
6
-
7
- ### Bug Fixes
8
-
9
- - add null check for appendContent to prevent TypeError ([ba1eabd](https://github.com/jetthai/cuora-module/commit/ba1eabd6a6b42a89fb88d55363f02c37e84a2dd3))
10
-
11
5
  ### [1.1.413](https://github.com/jetthai/cuora-module/compare/v1.1.412...v1.1.413) (2026-02-09)
12
6
 
13
7
  ### [1.1.412](https://github.com/jetthai/cuora-module/compare/v1.1.411...v1.1.412) (2026-02-09)
package/README.md CHANGED
@@ -1,177 +1,33 @@
1
- # @jetthai/cuora
1
+ # cuora
2
2
 
3
- ESM JavaScript 函式庫,透過 XState v4 狀態機整合 API 呼叫與業務邏輯,服務於線上遊戲平台。處理認證、支付(存款/提款)、遊戲管理、活動及即時 WebSocket 通訊。
4
-
5
- 設計用於 Nuxt.js 客戶端應用程式(`ssr: false`)。
3
+ Integrate API and logic by xstate.
6
4
 
7
5
  ## Installation
8
6
 
7
+ Add @jetthai/cuora dependency to your project:
8
+
9
9
  ```bash
10
- npm install @jetthai/cuora
10
+ npm install --save @jetthai/cuora
11
11
  ```
12
12
 
13
13
  ## Setup
14
14
 
15
- 在 `nuxt.config.js` 中加入以下設定:
15
+ Add config in `nuxt.config.js` to support latest ECMAScript.
16
16
 
17
17
  ```js
18
18
  // nuxt.config.js
19
- export default {
20
- ssr: false,
21
- build: {
22
- transpile: ['@jetthai/cuora'],
23
- },
19
+ {
20
+ ssr: false
24
21
  }
25
22
  ```
26
23
 
27
- ## Usage
28
-
29
- ```js
30
- import { api, machine, Request, Config, util, constant, storage } from '@jetthai/cuora'
31
- ```
32
-
33
- ### Config
34
-
35
- 初始化 API 設定:
36
-
37
- ```js
38
- const config = new Config({
39
- apiURL: 'https://api.example.com',
40
- apiVersion: 'v1',
41
- clientId: 'your-client-id',
42
- appSecret: 'your-app-secret',
43
- platform: 'web',
44
- socketURL: 'wss://socket.example.com',
45
- })
46
- ```
47
-
48
- ### Request
49
-
50
- 建立請求實例,自動處理 Bearer token 注入、API 版本轉換(V1 → V2)及維護模式偵測:
51
-
52
- ```js
53
- const request = new Request(config)
54
- ```
55
-
56
- ### API
57
-
58
- API 模組提供各領域的請求描述物件:
59
-
60
24
  ```js
61
- // 回傳格式:{ url, method, params, isPublic?, headers?, isFormData? }
62
- api.auth.login({ username, password })
63
- api.game.getGameList()
64
- api.payment.deposit(params)
65
- ```
66
-
67
- 可用的 API 模組:
68
-
69
- | 模組 | 說明 |
70
- | ---------- | ------------------------- |
71
- | `auth` | 認證(登入、註冊、Token) |
72
- | `account` | 帳戶管理 |
73
- | `activity` | 活動與促銷 |
74
- | `common` | 共用端點 |
75
- | `form` | 表單相關 |
76
- | `game` | 遊戲列表、搜尋、收藏 |
77
- | `mailbox` | 站內信 |
78
- | `otp` | OTP 驗證 |
79
- | `payment` | 存款與提款 |
80
- | `ranking` | 排行榜 |
81
- | `user` | 使用者資訊 |
82
-
83
- ### Machine
84
-
85
- 狀態機工廠函式,接收 `request` 實例並回傳 XState `createMachine()` 定義:
86
-
87
- ```js
88
- import { machine, Request, Config } from '@jetthai/cuora'
89
- import { interpret } from 'xstate'
90
-
91
- const config = new Config({
92
- /* ... */
93
- })
94
- const request = new Request(config)
95
-
96
- const authMachine = machine.auth(request)
97
- const service = interpret(authMachine).start()
98
- ```
99
-
100
- 可用的狀態機分類:
101
-
102
- | 分類 | 狀態機 |
103
- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------- |
104
- | **核心** | `auth`, `common`, `error`, `websocket` |
105
- | **遊戲** | `game_v2_1`, `game_favorite_v2`, `game_search_v2`, `game_search_cash`, `game_hot_new`, `game_info`, `game_replay`, `game_betslip` |
106
- | **存款** | `deposit_direct`, `deposit_manual`, `deposit_qrcode`, `deposit_usdt`, `deposit_crypto`, `deposit_virtual_bank`, `deposit_loadcard` 等 |
107
- | **提款** | `withdraw_manual`, `withdraw_manual_cash`, `withdraw_crypto_cash`, `withdraw_krway` |
108
- | **活動** | `sign_in_activity`, `ranking_activity`, `time_bomb_activity`, `mini_game_activity`, `diamond_shop_activity`, `jackpot` 等 |
109
- | **使用者** | `user_info`, `user_sign_up`, `user_reset_password`, `user_photo`, `bank_binding` |
110
- | **OTP** | `auth_otp_v2`, `auth_otp_v3` |
111
- | **UI** | `navbar`, `setting`, `inbox`, `side`, `side_v2` |
112
-
113
- ### Utilities
114
-
115
- ```js
116
- import { util, constant, storage } from '@jetthai/cuora'
117
-
118
- // LocalStorage 封裝,支援 TTL/過期機制
119
- storage.set('key', value, ttl)
120
- storage.get('key')
121
-
122
- // 遊戲類型常數
123
- constant.SLOT
124
- constant.FISH
125
- constant.LIVE
126
- constant.SPORT
127
- ```
128
-
129
- ## Architecture
130
-
131
- ```
132
- src/
133
- ├── index.js # 進入點
134
- ├── api/ # API 請求描述物件
135
- │ ├── auth.js
136
- │ ├── account.js
137
- │ ├── activity.js
138
- │ ├── common.js
139
- │ ├── form.js
140
- │ ├── game.js
141
- │ ├── mailbox.js
142
- │ ├── otp.js
143
- │ ├── payment.js
144
- │ ├── ranking.js
145
- │ └── user.js
146
- ├── machine/ # XState v4 狀態機
147
- │ ├── auth.js # 登入/註冊流程
148
- │ ├── common.js # 網站設定、UA、聯盟行銷
149
- │ ├── websocket.js # Socket.IO 即時通訊
150
- │ ├── deposit/ # 存款狀態機 (22+)
151
- │ ├── withdraw/ # 提款狀態機 (4)
152
- │ └── activity/ # 活動狀態機 (24+)
153
- ├── request/
154
- │ ├── config.js # Config 設定類別
155
- │ └── request.js # Axios 封裝 + 攔截器
156
- ├── util/
157
- │ ├── constant.js # 遊戲類型常數
158
- │ ├── storage.js # LocalStorage + TTL
159
- │ └── deviceToken.js # FingerprintJS 整合
160
- └── lib/
161
- └── fingerprint_v3_11_12.js
162
- ```
163
-
164
- ## Development
165
-
166
- ```bash
167
- # 格式化程式碼(Prettier)
168
- npm run format
169
-
170
- # 發佈新版本(standard-version + git push + npm publish)
171
- npm run release
172
-
173
- # 發佈並標記為 latest
174
- npm run release:latest
25
+ // nuxt.config.js
26
+ {
27
+ build: {
28
+ transpile: '@jetthai/cuora'
29
+ }
30
+ }
175
31
  ```
176
32
 
177
- 程式碼風格由 Prettier 管理(無分號、單引號、尾隨逗號 ES5、2 空格縮排、150 字元行寬),Husky pre-commit hook 會在每次提交時自動格式化。
33
+ ## Usage
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.413-qa-1",
3
+ "version": "1.1.413",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
7
7
  "scripts": {
8
8
  "release": "standard-version && git push --follow-tags origin master && npm publish",
9
- "release:latest": "standard-version && git push --follow-tags origin master && npm publish && npm dist-tag add @jetthai/cuora@$(node -p \"require('./package.json').version\") latest",
10
9
  "format": "prettier --write .",
11
10
  "prepare": "husky install"
12
11
  },
@@ -0,0 +1,101 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ # 切換到 master 分支
6
+ git checkout master
7
+ if [ $? -ne 0 ]; then
8
+ echo "切換到 master 分支失敗"
9
+ exit 1
10
+ fi
11
+
12
+ # 從遠端獲取最新的 master 分支更新
13
+ git pull origin master
14
+ if [ $? -ne 0 ]; then
15
+ echo "從 origin 拉取 master 分支失敗"
16
+ exit 1
17
+ fi
18
+
19
+ # 刪除本地的 dev 分支
20
+ git branch -D dev
21
+ if [ $? -ne 0 ]; then
22
+ echo "刪除本地 dev 分支失敗"
23
+ exit 1
24
+ fi
25
+
26
+ # 刪除遠端的 dev 分支
27
+ git push origin --delete dev
28
+ if [ $? -ne 0 ]; then
29
+ echo "刪除遠端 dev 分支失敗"
30
+ exit 1
31
+ fi
32
+
33
+ # 建立並切換到新的 dev 分支
34
+ git checkout -b dev
35
+ if [ $? -ne 0 ]; then
36
+ echo "建立並切換到新的 dev 分支失敗"
37
+ exit 1
38
+ fi
39
+
40
+ # 強制推送新的 dev 分支到遠端
41
+ git push -f origin dev
42
+ if [ $? -ne 0 ]; then
43
+ echo "強制推送新的 dev 分支到遠端失敗"
44
+ exit 1
45
+ fi
46
+
47
+ # 設定 dev 分支的上游分支為 origin/dev
48
+ git branch --set-upstream-to=origin/dev dev
49
+ if [ $? -ne 0 ]; then
50
+ echo "設定 dev 分支的上游分支為 origin/dev 失敗"
51
+ exit 1
52
+ fi
53
+
54
+ # 切換到 master
55
+ git checkout master
56
+ if [ $? -ne 0 ]; then
57
+ echo "切換到 master 分支失敗"
58
+ exit 1
59
+ fi
60
+
61
+ # 建立並切換到新的 qa 分支
62
+ git checkout -b qa
63
+ if [ $? -ne 0 ]; then
64
+ echo "建立並切換到新的 qa 分支失敗"
65
+ exit 1
66
+ fi
67
+
68
+ # 強制推送新的 qa 分支到遠端
69
+ git push -f origin qa
70
+ if [ $? -ne 0 ]; then
71
+ echo "強制推送新的 qa 分支到遠端失敗"
72
+ exit 1
73
+ fi
74
+
75
+ # 設定 qa 分支的上游分支為 origin/qa
76
+ git branch --set-upstream-to=origin/qa qa
77
+ if [ $? -ne 0 ]; then
78
+ echo "設定 qa 分支的上游分支為 origin/qa 失敗"
79
+ exit 1
80
+ fi
81
+
82
+ # 切換到 master
83
+ git checkout master
84
+ if [ $? -ne 0 ]; then
85
+ echo "切換到 master 分支失敗"
86
+ exit 1
87
+ fi
88
+
89
+ # 刪除所有已經合併到 master 分支的本地分支,除了 master 分支本身
90
+ git branch --merged master | grep -v "^\* master$" | grep -vE "^[* ]*(dev|qa)$" | xargs -r git branch -d
91
+ if [ $? -ne 0 ]; then
92
+ echo "刪除已合併到 master 分支的本地分支失敗"
93
+ exit 1
94
+ fi
95
+
96
+ # 刪除所有已經合併到 master 分支的遠端分支,除了 master 分支本身
97
+ git branch -r --merged master | grep -v "master" | grep -vE "(dev|qa)$" | sed 's/origin\///' | xargs -r -I {} git push origin --delete {}
98
+ if [ $? -ne 0 ]; then
99
+ echo "刪除已合併到 master 分支的遠端分支失敗"
100
+ exit 1
101
+ fi
@@ -176,12 +176,12 @@ export default {
176
176
  params: { transferType: 'DEPOSIT', amount, promotionsNo },
177
177
  }),
178
178
  submitWithdrawTransactionCrypto: ({ method, amount, cryptoCurrency, cryptoNetwork, targetAddress, applyerHolderName }) => ({
179
- url: `/payment/v2/${method}/withdraw-otp/verify`,
179
+ url: `payment/v2/${method}/transaction`,
180
180
  method: 'post',
181
181
  params: { transferType: 'WITHDRAW', amount, cryptoCurrency, cryptoNetwork, targetAddress, applyerHolderName },
182
182
  }),
183
183
  submitWithdrawTransactionVN: ({ method, amount, applyerBankCode, applyerAccountNumber, applyerIfscCode, branch, applyerHolderName }) => ({
184
- url: `/payment/v2/${method}/withdraw-otp/verify`,
184
+ url: `payment/v2/${method}/transaction`,
185
185
  method: 'post',
186
186
  params: {
187
187
  transferType: 'WITHDRAW',
@@ -205,7 +205,7 @@ export default {
205
205
  cryptoNetwork,
206
206
  targetAddress,
207
207
  }) => ({
208
- url: `payment/v2/${method}/withdraw-otp/verify`,
208
+ url: `payment/v2/${method}/transaction`,
209
209
  method: 'post',
210
210
  params: {
211
211
  transferType: 'WITHDRAW',
@@ -247,16 +247,4 @@ export default {
247
247
  withdrawCheck: () => ({ url: `payment/v2/withdrawCheck`, method: 'post' }),
248
248
  updateUtr: ({ applyId, utr }) => ({ url: 'payment/v2/updateUtr', method: 'post', params: { applyId, utr } }),
249
249
  uploadCommonSlip: ({ applyId, slip }) => ({ url: 'payment/v2/uploadCommonSlip', method: 'post', params: { applyId, slip } }),
250
- otpAcknowledge: ({ method, requestId, code }) => ({
251
- url: `/payment/v2/${method}/withdraw-otp/acknowledge`,
252
- method: 'post',
253
- params: { requestId, code },
254
- isPublic: true,
255
- }),
256
- otpReset: ({ method, requestId }) => ({
257
- url: `/payment/v2/${method}/withdraw-otp/reset-otp`,
258
- method: 'post',
259
- params: { requestId },
260
- isPublic: true,
261
- }),
262
250
  }
@@ -390,10 +390,6 @@ export default function (request) {
390
390
  }),
391
391
  appendContent: assign((context, event) => {
392
392
  const { room, additionEnable } = context
393
- // [防呆] 確保有 categoryId
394
- if (!room?.categoryId) {
395
- return
396
- }
397
393
  if (room.categoryId === GAME_SEARCH) {
398
394
  return
399
395
  } else if (additionEnable) {
@@ -1,6 +1,7 @@
1
1
  import { assign, createMachine } from 'xstate'
2
2
  import findLastIndex from 'lodash/findLastIndex.js'
3
3
  import payment from '../../api/payment.js'
4
+ import user from '../../api/user.js'
4
5
 
5
6
  export default function (request) {
6
7
  const { appSecret } = request.config
@@ -35,8 +36,8 @@ export default function (request) {
35
36
 
36
37
  // otp
37
38
  requestId: null,
38
- number: null,
39
- email: null,
39
+ status: null,
40
+ target: null,
40
41
  ttl: null,
41
42
  },
42
43
  states: {
@@ -355,27 +356,26 @@ export default function (request) {
355
356
  return { paymentDetail }
356
357
  }),
357
358
  setOtp: assign((context, event) => {
358
- const { request_id, number, email, ttl } = event.data
359
+ const { requestId, status, target, ttl } = event.data
359
360
  return {
360
- requestId: request_id,
361
- number,
362
- email,
361
+ requestId,
362
+ status,
363
+ target,
363
364
  ttl,
364
365
  }
365
366
  }),
366
367
  decreaseTtl: assign((context, evnet) => {
367
368
  const second = context.ttl
368
369
  return {
369
- ttl: Math.max(second - 1000, 0),
370
+ ttl: Math.max(second - 1, 0),
370
371
  }
371
372
  }),
372
373
  setVerificationData: assign((context, event) => {
373
- const { request_id, number, email, ttl } = event.data
374
+ const { requestId, ttl, target } = event.data
374
375
  return {
375
- requestId: request_id,
376
- number,
377
- email,
376
+ requestId,
378
377
  ttl,
378
+ target,
379
379
  }
380
380
  }),
381
381
  setAttachmentType: assign((context, event) => {
@@ -439,8 +439,7 @@ export default function (request) {
439
439
  return !enableWithdraw || balance < minWithdrawAmount
440
440
  },
441
441
  isOtpRequired: (context, event) => {
442
- const { request_id, number, email } = event.data || {}
443
- return request_id !== undefined && (number || email)
442
+ return event.data?.status === 'otp-verifying'
444
443
  },
445
444
  isNotWithdrawMinDepositAmount: (context, event) => {
446
445
  const { withdrawCheck } = context
@@ -510,15 +509,13 @@ export default function (request) {
510
509
  return await request.send(payment.convertFreeCredit({ exchangeType: 1 }))
511
510
  },
512
511
  resetOtp: async (context, event) => {
513
- const { requestId } = context
514
- const { method } = context.paymentDetail[0]
515
- return await request.send(payment.otpReset({ method: method, requestId }))
512
+ const { requestId, target } = context
513
+ return await request.send(user.otpReset({ requestId, target }))
516
514
  },
517
515
  acknowledge: async (context, event) => {
518
- const { requestId } = context
519
- const { method } = context.paymentDetail[0]
516
+ const { requestId, target } = context
520
517
  const code = event.data
521
- return await request.send(payment.otpAcknowledge({ method: method, requestId, code }))
518
+ return await request.send(user.otpAcknowledge({ requestId, target, code }))
522
519
  },
523
520
  pool: async (context, event) => {
524
521
  const { amount } = context
@@ -23,8 +23,6 @@ export default function (request, context) {
23
23
  requestId: null,
24
24
  status: null,
25
25
  target: null,
26
- email: null,
27
- number: null,
28
26
  ttl: null,
29
27
  },
30
28
  states: {
@@ -119,18 +117,29 @@ export default function (request, context) {
119
117
  RESET_OTP: {
120
118
  target: 'reset',
121
119
  },
122
- BACK: {
123
- target: '#withdraw_manual_cash.calculated',
124
- },
120
+ BACK: [
121
+ // {
122
+ // target: '#withdraw_vn2.activity.convertible',
123
+ // cond: 'isActivity',
124
+ // },
125
+ // {
126
+ // target: '#withdraw_vn2.cash.withdrawable',
127
+ // },
128
+ ],
125
129
  },
126
130
  },
127
131
  acknowledging: {
128
132
  invoke: {
129
133
  src: 'acknowledge',
130
- onDone: {
131
- target: '#withdraw_manual_cash.submitted',
132
- actions: 'setProcessing',
133
- },
134
+ onDone: [
135
+ // {
136
+ // target: '#withdraw_vn2.activity.converted',
137
+ // cond: 'isActivity',
138
+ // },
139
+ // {
140
+ // target: '#withdraw_vn2.cash.submitted',
141
+ // },
142
+ ],
134
143
  onError: {
135
144
  target: 'idle',
136
145
  },
@@ -194,27 +203,26 @@ export default function (request, context) {
194
203
  }
195
204
  }),
196
205
  setOtp: assign((context, event) => {
197
- const { request_id, email, number, ttl } = event.data
206
+ const { requestId, status, target, ttl } = event.data
198
207
  return {
199
- requestId: request_id,
200
- email,
201
- number,
208
+ requestId,
209
+ status,
210
+ target,
202
211
  ttl,
203
212
  }
204
213
  }),
205
214
  decreaseTtl: assign((context, evnet) => {
206
215
  const second = context.ttl
207
216
  return {
208
- ttl: Math.max(second - 1000, 0),
217
+ ttl: Math.max(second - 1, 0),
209
218
  }
210
219
  }),
211
220
  setVerificationData: assign((context, event) => {
212
- const { request_id, ttl, number, email } = event.data
221
+ const { requestId, ttl, target } = event.data
213
222
  return {
214
- requestId: request_id,
223
+ requestId,
215
224
  ttl,
216
- number,
217
- email,
225
+ target,
218
226
  }
219
227
  }),
220
228
  },
@@ -230,7 +238,7 @@ export default function (request, context) {
230
238
  return selectedUserBank && selectedAmount > 0 && currentPayment.minimum <= selectedAmount && selectedAmount <= currentPayment.maximum
231
239
  },
232
240
  isOtpRequired: (context, event) => {
233
- return event.data?.request_id !== undefined
241
+ return event.data?.status === 'otp-verifying'
234
242
  },
235
243
  },
236
244
  services: {
@@ -281,13 +289,13 @@ export default function (request, context) {
281
289
  )
282
290
  },
283
291
  resetOtp: async (context, event) => {
284
- const { currentPayment, requestId } = context
285
- return await request.send(payment.otpReset({ method: currentPayment.method, requestId }))
292
+ const { requestId, target } = context
293
+ return await request.send(user.otpReset({ requestId, target }))
286
294
  },
287
295
  acknowledge: async (context, event) => {
288
- const { currentPayment, requestId } = context
296
+ const { requestId, target } = context
289
297
  const code = event.data
290
- return await request.send(payment.otpAcknowledge({ method: currentPayment.method, requestId, code }))
298
+ return await request.send(user.otpAcknowledge({ requestId, target, code }))
291
299
  },
292
300
  },
293
301
  }
package/CLAUDE.md DELETED
@@ -1,64 +0,0 @@
1
- # CLAUDE.md
2
-
3
- This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
-
5
- ## 專案概述
6
-
7
- `@jetthai/cuora` 是一個 ESM JavaScript 函式庫,透過 XState 狀態機整合 API 呼叫與業務邏輯,服務於線上遊戲平台。處理認證、支付(存款/提款)、遊戲管理、活動及即時 WebSocket 通訊。設計用於 Nuxt.js 客戶端應用程式(`ssr: false`)。
8
-
9
- ## 指令
10
-
11
- - **格式化程式碼:** `npm run format`(Prettier)
12
- - **發佈版本:** `npm run release`(standard-version + git push + npm publish)
13
- - **發佈並標記為 latest:** `npm run release:latest`
14
-
15
- 沒有建置步驟、測試框架或 linter — 原始 `.js` 檔案直接以 ES modules 形式發佈。
16
-
17
- ## Pre-commit Hook
18
-
19
- Husky 在每次 commit 時執行 `npm run format && git add .`,所有程式碼在提交前會自動格式化。
20
-
21
- ## 程式碼風格
22
-
23
- Prettier 設定(`.prettierrc`):不加分號、單引號、尾隨逗號(ES5)、2 空格縮排、150 字元行寬。
24
-
25
- ## 架構
26
-
27
- ### 進入點(`src/index.js`)
28
-
29
- 匯出六個模組:`api`、`machine`、`Request`、`Config`、`util`(含 `constant`、`storage`)。
30
-
31
- ### 請求層(`src/request/`)
32
-
33
- - **`Request.js`** — Axios 封裝,包含攔截器處理認證 token(Bearer)、API 版本控制(透過 `supportVersion2List` 自動將 158+ 個端點從 V1 轉換為 V2 路徑)、維護模式偵測(`ERR_F108`)及自訂參數序列化。
34
- - **`Config.js`** — 設定類別(apiURL、clientId、appSecret、platform、socketURL 等),透過 `url-join` 組合完整 API URL。
35
-
36
- ### API 層(`src/api/`)
37
-
38
- 函式模組回傳請求描述物件,格式為 `{ url, method, params, isPublic?, headers?, isFormData? }`。模組包含:`auth`、`account`、`activity`、`common`、`form`、`game`、`mailbox`、`otp`、`payment`、`ranking`、`user`。
39
-
40
- ### 狀態機層(`src/machine/`)
41
-
42
- 約 40 個 XState(v4)狀態機工廠函式,每個接收 `request` 物件並回傳 `createMachine()` 定義。主要分類:
43
-
44
- - **核心:** `auth.js`(登入/註冊流程、token 管理)、`common.js`(平行狀態機處理網站設定、user-agent、聯盟行銷)、`error.js`
45
- - **支付 — deposit/**(22 個狀態機):直接、手動、QR 碼、加密貨幣(USDT)、虛擬銀行、儲值卡 — 每個皆有 載入 → 銀行選擇 → 金額輸入 → 計算 → 提交 流程
46
- - **支付 — withdraw/**(4 個狀態機):手動、加密貨幣、krway 等變體
47
- - **活動 Activity/**(24 個狀態機):簽到、排名、炸彈、小遊戲、鑽石商店等
48
- - **遊戲 Game:** 遊戲列表(v2)、收藏、搜尋、熱門/最新、回放、投注單
49
- - **OTP 認證:** `auth_otp_v2.js`、`auth_otp_v3.js`
50
- - **WebSocket:** `websocket.js` — Socket.IO 連線,支援自動重連(最多 3 次)
51
- - **使用者 User:** 註冊、密碼重設、銀行綁定、使用者資訊、頭像
52
-
53
- ### 工具模組(`src/util/`)
54
-
55
- - **`storage.js`** — LocalStorage 封裝,支援 TTL/過期機制
56
- - **`deviceToken.js`** — FingerprintJS 整合,含重試邏輯
57
- - **`constant.js`** — 遊戲類型常數(SLOT、FISH、LIVE、SPORT 等)
58
-
59
- ### 關鍵模式
60
-
61
- - **工廠模式:** 所有狀態機皆為預設匯出函式,接收 `request` 並回傳 XState 狀態機設定。
62
- - **Token 管理:** 儲存於 localStorage,key 為 `cuora_{clientId}`,透過請求攔截器自動注入。
63
- - **API 版本控制:** `supportVersion2List` 自動將 V1 camelCase 路徑對應至 V2 kebab-case 路徑。
64
- - **錯誤代碼:** `ERR_F108`(維護中)、`ERR_A103`(缺少認證)、`ERR_800`(已取消)、`ERR_998`(網路/404)。