@jetthai/cuora 1.1.357 → 1.1.358-apiv2-2

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,10 +2,22 @@
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.358-apiv2-2](https://github.com/jetthai/cuora-module/compare/v1.1.359...v1.1.358-apiv2-2) (2025-05-27)
6
+
7
+ ### [1.1.359](https://github.com/jetthai/cuora-module/compare/v1.1.358...v1.1.359) (2025-05-23)
8
+
9
+ ### [1.1.358-apiv2-1](https://github.com/jetthai/cuora-module/compare/v1.1.358...v1.1.358-apiv2-1) (2025-05-09)
10
+
11
+ ### [1.1.358](https://github.com/jetthai/cuora-module/compare/v1.1.357...v1.1.358) (2025-05-09)
12
+
5
13
  ### [1.1.357](https://github.com/jetthai/cuora-module/compare/v1.1.356...v1.1.357) (2025-05-06)
6
14
 
7
15
  ### [1.1.356](https://github.com/jetthai/cuora-module/compare/v1.1.355...v1.1.356) (2025-04-29)
8
16
 
17
+ ### [1.1.355-apiv2-2](https://github.com/jetthai/cuora-module/compare/v1.1.355-apiv2-1...v1.1.355-apiv2-2) (2025-05-07)
18
+
19
+ ### [1.1.355-apiv2-1](https://github.com/jetthai/cuora-module/compare/v1.1.355...v1.1.355-apiv2-1) (2025-05-05)
20
+
9
21
  ### [1.1.355](https://github.com/jetthai/cuora-module/compare/v1.1.353-data-1...v1.1.355) (2025-04-22)
10
22
 
11
23
  ### [1.1.354](https://github.com/jetthai/cuora-module/compare/v1.1.353...v1.1.354) (2025-04-14)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.357",
3
+ "version": "1.1.358-apiv2-2",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
package/src/api/game.js CHANGED
@@ -4,6 +4,7 @@ export default {
4
4
  removeFavoriteGame: (code) => ({ method: 'post', url: 'game/myfavorite/remove', params: { games: [code] } }),
5
5
  getStatements: () => ({ url: 'game/statements', method: 'get' }),
6
6
  playGame: (params) => ({ url: 'game/play', method: 'get', params }),
7
+ demoGame: (params) => ({ url: 'game/demo', method: 'get', params, isPublic: true }),
7
8
  logoutGame: ({ uid_site, provider_id }) => ({ url: 'game/logout', method: 'get', params: { uid_site, provider_id } }),
8
9
 
9
10
  getGameTags: ({ q, lang }) => ({ url: 'game/search', method: 'get', params: { q, lang } }),
@@ -242,4 +242,5 @@ export default {
242
242
  getPendingOrder: ({ transferType }) => ({ url: 'payment/v2/pendingOrder', method: 'post', params: { transferType } }),
243
243
  withdrawCheck: () => ({ url: `payment/v2/withdrawCheck`, method: 'post' }),
244
244
  updateUtr: ({ applyId, utr }) => ({ url: 'payment/v2/updateUtr', method: 'post', params: { applyId, utr } }),
245
+ uploadCommonSlip: ({ applyId, slip }) => ({ url: 'payment/v2/uploadCommonSlip', method: 'post', params: { applyId, slip } }),
245
246
  }
@@ -39,9 +39,11 @@ export default function (request) {
39
39
  portrait: null,
40
40
  gameCode: null,
41
41
  name: null,
42
+ isDemo: false,
42
43
  },
43
44
  walletType: null,
44
45
  lang: 'en_US',
46
+ site: '',
45
47
  isMobile: new UAParser().getResult().device.type,
46
48
  gameURL: null,
47
49
  gameToken: null,
@@ -83,9 +85,13 @@ export default function (request) {
83
85
  target: 'connecting',
84
86
  actions: ['setGameInfo', 'setLang', 'setwalletType'],
85
87
  },
88
+ DEMO_GAME: {
89
+ target: 'demoGame',
90
+ actions: ['setGameInfo', 'setLang', 'setSite'],
91
+ },
86
92
  MENU_ENTER_GAME: {
87
93
  target: 'connecting',
88
- actions: ['setGameInfo', 'setLang'],
94
+ actions: ['setGameInfo', 'setLang', 'setwalletType'],
89
95
  },
90
96
  UPDATE: {
91
97
  target: 'updating',
@@ -172,6 +178,24 @@ export default function (request) {
172
178
  },
173
179
  },
174
180
  },
181
+ demoGame: {
182
+ invoke: {
183
+ src: 'demoGame',
184
+ onDone: {
185
+ target: 'playingDemo',
186
+ actions: 'setGameURL',
187
+ },
188
+ onError: {
189
+ target: 'idle',
190
+ actions: 'setGameURL',
191
+ },
192
+ },
193
+ on: {
194
+ EXIT_GAME: {
195
+ target: 'disconnect',
196
+ },
197
+ },
198
+ },
175
199
  connectSwitching: {
176
200
  invoke: {
177
201
  src: 'disconnectGame',
@@ -207,6 +231,20 @@ export default function (request) {
207
231
  },
208
232
  },
209
233
  },
234
+ playingDemo: {
235
+ on: {
236
+ EXIT_GAME: {
237
+ target: 'disconnect',
238
+ },
239
+ EXIT_DEMO_GAME: {
240
+ target: 'idle',
241
+ },
242
+ ENTER_GAME: {
243
+ target: 'connecting',
244
+ actions: ['setGameInfo', 'setLang', 'setwalletType'],
245
+ },
246
+ },
247
+ },
210
248
  refreshing: {
211
249
  invoke: {
212
250
  src: 'disconnectGame',
@@ -424,6 +462,10 @@ export default function (request) {
424
462
  const lang = event.data.locale.replace('-', '_')
425
463
  return { lang }
426
464
  }),
465
+ setSite: assign((context, event) => {
466
+ const site = event.data.site
467
+ return { site }
468
+ }),
427
469
  setPageLoadingDone: assign((context, event) => {
428
470
  return {
429
471
  pageLoading: true,
@@ -572,6 +614,23 @@ export default function (request) {
572
614
  const { type, redirect_url, gameToken, gameHtml, wallet_type } = await request.send(api.playGame(params))
573
615
  return { type, gameToken, gameHtml, gameURL: redirect_url, gameWalletType: wallet_type }
574
616
  },
617
+ demoGame: async (context, event) => {
618
+ const { lang, site, isMobile, game } = context
619
+ const { providerId, gameId, gameTypeId, mappingId } = context.game
620
+ const params = {
621
+ site,
622
+ provider_id: providerId,
623
+ game_id: gameId,
624
+ gametype_id: gameTypeId,
625
+ mapping_id: mappingId,
626
+ is_mobile: isMobile === 'mobile' ? 'y' : null,
627
+ lang,
628
+ }
629
+ const { type, redirect_url, gameToken, gameHtml, is_demo } = await request.send(api.demoGame(params))
630
+ // 將 is_demo 設置到 context.game.isDemo
631
+ game.isDemo = is_demo
632
+ return { type, gameToken, gameHtml, gameURL: redirect_url, game }
633
+ },
575
634
  disconnectGame: async (context, event) => {
576
635
  const uid_site = event.data
577
636
  const provider_id = context.game.providerId
@@ -2,6 +2,80 @@ import pickBy from 'lodash/pickBy.js'
2
2
  import storage from '../util/storage.js'
3
3
 
4
4
  // const pickBy = require('lodash/pickBy')
5
+ const supportVersion2List = [
6
+ 'game/play',
7
+ 'game/gameReplay',
8
+ 'game/logout',
9
+ 'game/list/v3/root',
10
+ 'game/list/v3/category',
11
+ 'game/list/v3/addition',
12
+ 'game/list/v3/categoryByRange',
13
+ 'game/list/v3/additionByRange',
14
+ 'game/list/v3/myFavorite',
15
+ 'game/list/v3/addMyFavorite',
16
+ 'game/list/v3/removeMyFavorite',
17
+ 'login',
18
+ 'callback/:strategy',
19
+ 'guestLogin',
20
+ 'appLogin',
21
+ 'logout',
22
+ 'self',
23
+ 'register',
24
+ 'settings/password',
25
+ 'verify',
26
+ 'reset',
27
+ 'acknowledge',
28
+ 'friends',
29
+ 'friends/home',
30
+ 'friends/reward-list',
31
+ 'recovery',
32
+ 'recovery/abandon',
33
+ 'recovery/acknowledge',
34
+ 'checkDt',
35
+ 'updateDt',
36
+ 'checkAC',
37
+ 'checkAccount',
38
+ 'getAllAvatar',
39
+ 'updateUserAvatar',
40
+ 'getConfig',
41
+ 'getQuickLayout',
42
+ 'getNavbarSetting',
43
+ 'getAffiliateCode',
44
+ 'get-site-config',
45
+ 'friends/dashboard',
46
+ 'friends/dashboard/list',
47
+ 'mailbox/sendMessage',
48
+ 'mailbox/getMessageList',
49
+ 'mailbox/getMessage',
50
+ 'mailbox/updateMessage',
51
+ 'mailbox/getMessageTypes',
52
+ ]
53
+
54
+ const version2ListName = {
55
+ 'game/gameReplay': 'game/game-replay',
56
+ 'game/list/v3/categoryByRange': 'game/list/v3/category-by-range',
57
+ 'game/list/v3/additionByRange': 'game/list/v3/addition-by-range',
58
+ 'game/list/v3/myFavorite': 'game/list/v3/my-favorite',
59
+ 'game/list/v3/addMyFavorite': 'game/list/v3/add-my-favorite',
60
+ 'game/list/v3/removeMyFavorite': 'game/list/v3/remove-my-favorite',
61
+ guestLogin: 'guest-login',
62
+ appLogin: 'app-login',
63
+ checkDt: 'check-dt',
64
+ updateDt: 'update-dt',
65
+ checkAC: 'check-ac',
66
+ checkAccount: 'check-account',
67
+ getAllAvatar: 'get-all-avatar',
68
+ updateUserAvatar: 'update-user-avatar',
69
+ getConfig: 'get-config',
70
+ getQuickLayout: 'get-quick-layout',
71
+ getNavbarSetting: 'get-navbar-setting',
72
+ getAffiliateCode: 'get-affiliate-code',
73
+ 'mailbox/sendMessage': 'mailbox/send-message',
74
+ 'mailbox/getMessageList': 'mailbox/get-message-list',
75
+ 'mailbox/getMessage': 'mailbox/get-message',
76
+ 'mailbox/updateMessage': 'mailbox/update-message',
77
+ 'mailbox/getMessageTypes': 'mailbox/get-message-types',
78
+ }
5
79
 
6
80
  function isValid(value) {
7
81
  return value !== undefined && value !== null
@@ -24,7 +98,8 @@ export default class Request {
24
98
  axiosConfig.headers['X-TH1GAMES-VERSION'] = this.config.version
25
99
  axiosConfig.headers['X-TH1GAMES-PLATFORM'] = this.config.platform
26
100
  if (this.getToken()) {
27
- axiosConfig.headers.Authorization = this.getToken()
101
+ // 為了支援V2版本的API接口新增Bearer來進行身份驗證
102
+ axiosConfig.headers.Authorization = `Bearer ${this.getToken()}`
28
103
  }
29
104
  return axiosConfig
30
105
  })
@@ -85,11 +160,21 @@ export default class Request {
85
160
 
86
161
  _createConfig(req, cancelToken) {
87
162
  const { method, url, params, isPublic, isFormData, headers } = req
163
+ let fullURL = this.config.fullURL
164
+ let urlName = url
165
+ // 有些API會將參數(/?)直接帶在URL上,所以要將參數排除
166
+ if (supportVersion2List.includes(url.split('?')[0])) {
167
+ fullURL = fullURL.replace('/v1/', '/v2/')
168
+ urlName = version2ListName[url] || url
169
+ console.log('*[DEV_ONLY]支援V2API-原本路徑:', url)
170
+ console.log('*[DEV_ONLY]支援V2API-調整路徑:', fullURL, urlName)
171
+ }
172
+
88
173
  if (isFormData) {
89
174
  return {
90
- baseURL: this.config.fullURL,
175
+ baseURL: fullURL,
91
176
  method,
92
- url,
177
+ url: urlName,
93
178
  cancelToken,
94
179
  isPublic,
95
180
  headers: { 'Content-Type': 'multipart/form-data' },
@@ -97,9 +182,9 @@ export default class Request {
97
182
  }
98
183
  } else {
99
184
  return {
100
- baseURL: this.config.fullURL,
185
+ baseURL: fullURL,
101
186
  method,
102
- url,
187
+ url: urlName,
103
188
  cancelToken,
104
189
  isPublic,
105
190
  headers,