@jetthai/cuora 1.1.357 → 1.1.358-apiv2-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.
package/CHANGELOG.md CHANGED
@@ -2,10 +2,18 @@
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-1](https://github.com/jetthai/cuora-module/compare/v1.1.358...v1.1.358-apiv2-1) (2025-05-09)
6
+
7
+ ### [1.1.358](https://github.com/jetthai/cuora-module/compare/v1.1.357...v1.1.358) (2025-05-09)
8
+
5
9
  ### [1.1.357](https://github.com/jetthai/cuora-module/compare/v1.1.356...v1.1.357) (2025-05-06)
6
10
 
7
11
  ### [1.1.356](https://github.com/jetthai/cuora-module/compare/v1.1.355...v1.1.356) (2025-04-29)
8
12
 
13
+ ### [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)
14
+
15
+ ### [1.1.355-apiv2-1](https://github.com/jetthai/cuora-module/compare/v1.1.355...v1.1.355-apiv2-1) (2025-05-05)
16
+
9
17
  ### [1.1.355](https://github.com/jetthai/cuora-module/compare/v1.1.353-data-1...v1.1.355) (2025-04-22)
10
18
 
11
19
  ### [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-1",
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 } }),
@@ -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,6 +85,10 @@ 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
94
  actions: ['setGameInfo', 'setLang'],
@@ -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,54 @@ 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
+ ]
5
53
 
6
54
  function isValid(value) {
7
55
  return value !== undefined && value !== null
@@ -24,7 +72,8 @@ export default class Request {
24
72
  axiosConfig.headers['X-TH1GAMES-VERSION'] = this.config.version
25
73
  axiosConfig.headers['X-TH1GAMES-PLATFORM'] = this.config.platform
26
74
  if (this.getToken()) {
27
- axiosConfig.headers.Authorization = this.getToken()
75
+ // 為了支援V2版本的API接口新增Bearer來進行身份驗證
76
+ axiosConfig.headers.Authorization = `Bearer ${this.getToken()}`
28
77
  }
29
78
  return axiosConfig
30
79
  })
@@ -85,9 +134,15 @@ export default class Request {
85
134
 
86
135
  _createConfig(req, cancelToken) {
87
136
  const { method, url, params, isPublic, isFormData, headers } = req
137
+ let fullURL = this.config.fullURL
138
+ // 有些API會將參數(/?)直接帶在URL上,所以要將參數排除
139
+ if (supportVersion2List.includes(url.split('?')[0])) {
140
+ console.log('*[DEV_ONLY]有支援V2的API:', url.split('?')[0])
141
+ fullURL = fullURL.replace('/v1/', '/v2/')
142
+ }
88
143
  if (isFormData) {
89
144
  return {
90
- baseURL: this.config.fullURL,
145
+ baseURL: fullURL,
91
146
  method,
92
147
  url,
93
148
  cancelToken,
@@ -97,7 +152,7 @@ export default class Request {
97
152
  }
98
153
  } else {
99
154
  return {
100
- baseURL: this.config.fullURL,
155
+ baseURL: fullURL,
101
156
  method,
102
157
  url,
103
158
  cancelToken,