@jetthai/cuora 1.1.380-dev → 1.1.380-dev-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,6 +2,14 @@
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.380-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.387...v1.1.380-dev-2) (2025-09-25)
6
+
7
+ ### [1.1.380-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.380-dev...v1.1.380-dev-1) (2025-09-15)
8
+
9
+ ### [1.1.380-dev](https://github.com/jetthai/cuora-module/compare/v1.1.380...v1.1.380-dev) (2025-09-12)
10
+
11
+ ### [1.1.380-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.380-dev...v1.1.380-dev-1) (2025-09-15)
12
+
5
13
  ### [1.1.380-dev](https://github.com/jetthai/cuora-module/compare/v1.1.380...v1.1.380-dev) (2025-09-12)
6
14
 
7
15
  ### [1.1.380](https://github.com/jetthai/cuora-module/compare/v1.1.379...v1.1.380) (2025-09-11)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.380-dev",
3
+ "version": "1.1.380-dev-2",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -85,6 +85,7 @@ export default {
85
85
  exchange: (data) => ({ url: 'activities/exchange', method: 'post', params: data }),
86
86
  collect: (data) => ({ url: 'activities/collect', method: 'post', params: data }),
87
87
  getVipTable: ({ appSecret }) => ({ url: 'activities/viptable', method: 'get', params: { appSecret } }),
88
+ getLevelBonusInfo: () => ({ url: 'activities/level-bonus/info', method: 'get' }),
88
89
  getRankingList: () => ({ url: 'activities/ranking', method: 'get' }),
89
90
  exchangeDiamond: ({ activityNo, exchangeAward = [] }) => ({
90
91
  url: 'activities/exchange/diamond',
package/src/api/user.js CHANGED
@@ -44,7 +44,7 @@ export default {
44
44
  params: { requestId, target, appSecret },
45
45
  isPublic: true,
46
46
  }),
47
- passwordV2Change: ({ requestId, target, newPassword }) => ({
47
+ passwordV2Change: ({ requestId, target, newPassword, appSecret }) => ({
48
48
  url: 'recovery/v2/changePassword',
49
49
  method: 'post',
50
50
  params: { requestId, target, newPassword, appSecret },
@@ -136,7 +136,8 @@ export default function (request, context) {
136
136
  },
137
137
  receiveReward: async (context, event) => {
138
138
  const { activityNo, receiveNo } = context
139
- const { data } = await request.send(api.getReward({ activityNo, receiveNo, appSecret }))
139
+ const validateReceiveNo = Number(receiveNo) > 0 ? Number(receiveNo) : undefined
140
+ const { data } = await request.send(api.getReward({ activityNo, receiveNo: validateReceiveNo, appSecret }))
140
141
  return data
141
142
  },
142
143
  },
@@ -165,7 +165,8 @@ export default function (request, context) {
165
165
  },
166
166
  receiveReward: async (context, event) => {
167
167
  const { activityNo, receiveNo } = context
168
- const { data } = await request.send(api.getReward({ activityNo, receiveNo, appSecret }))
168
+ const validateReceiveNo = Number(receiveNo) > 0 ? Number(receiveNo) : undefined
169
+ const { data } = await request.send(api.getReward({ activityNo, receiveNo: validateReceiveNo, appSecret }))
169
170
  return data
170
171
  },
171
172
  },
@@ -139,7 +139,8 @@ export default function (request) {
139
139
  },
140
140
  receiveReward: async (context, event) => {
141
141
  const { activityNo, receiveNo } = context.rewardList[0]
142
- const { data } = await request.send(api.getReward({ activityNo, receiveNo, appSecret }))
142
+ const validateReceiveNo = Number(receiveNo) > 0 ? Number(receiveNo) : undefined
143
+ const { data } = await request.send(api.getReward({ activityNo, receiveNo: validateReceiveNo, appSecret }))
143
144
  return data
144
145
  },
145
146
  fetchRewardList: async (context, event) => {
@@ -147,7 +147,8 @@ export default function (request, context) {
147
147
  },
148
148
  receiveReward: async (context, event) => {
149
149
  const { activityNo, receiveNo } = context
150
- const { data } = await request.send(api.getReward({ activityNo, receiveNo, appSecret }))
150
+ const validateReceiveNo = Number(receiveNo) > 0 ? Number(receiveNo) : undefined
151
+ const { data } = await request.send(api.getReward({ activityNo, receiveNo: validateReceiveNo, appSecret }))
151
152
  return data
152
153
  },
153
154
  },
@@ -147,7 +147,8 @@ export default function (request, context) {
147
147
  },
148
148
  receiveReward: async (context, event) => {
149
149
  const { activityNo, receiveNo } = context.activityDetail
150
- const { data } = await request.send(api.getReward({ activityNo, receiveNo, appSecret }))
150
+ const validateReceiveNo = Number(receiveNo) > 0 ? Number(receiveNo) : undefined
151
+ const { data } = await request.send(api.getReward({ activityNo, receiveNo: validateReceiveNo, appSecret }))
151
152
  return data
152
153
  },
153
154
  },
@@ -126,7 +126,8 @@ export default function (request, context) {
126
126
  },
127
127
  receiveReward: async (context, event) => {
128
128
  const { activityNo, receiveNo } = context.activityDetail
129
- const { data } = await request.send(api.getReward({ activityNo, receiveNo, appSecret }))
129
+ const validateReceiveNo = Number(receiveNo) > 0 ? Number(receiveNo) : undefined
130
+ const { data } = await request.send(api.getReward({ activityNo, receiveNo: validateReceiveNo, appSecret }))
130
131
  return data
131
132
  },
132
133
  },
@@ -3,6 +3,7 @@ import { assign, createMachine } from 'xstate'
3
3
  import pickBy from 'lodash/pickBy.js'
4
4
  import api from '../api/common.js'
5
5
  import storage from '../util/storage.js'
6
+ import sessionStorage from '../util/sessionStorage.js'
6
7
 
7
8
  export default function (request) {
8
9
  const { appSecret, defaultChannel, defaultSubchannel } = request.config
@@ -258,7 +259,7 @@ export default function (request) {
258
259
  const channel = urlParams.get('channel') || storage.get('channel') || defaultChannel || 'official'
259
260
  const subchannel = urlParams.get('subchannel') || storage.get('subchannel') || defaultSubchannel || 'pwa'
260
261
  const affiliateCode = urlParams.get('ac') || urlParams.get('referralCode') || storage.get('ac') || storage.get('referralCode')
261
- const friendCode = urlParams.get('fc') || urlParams.get('affiliate') || storage.get('fc') || storage.get('affiliate')
262
+ const friendCode = urlParams.get('fc') || urlParams.get('affiliate') || sessionStorage.get('fc') || sessionStorage.get('affiliate')
262
263
 
263
264
  storage.set('channel', channel, {
264
265
  path: '/',
@@ -272,7 +273,7 @@ export default function (request) {
272
273
  path: '/',
273
274
  maxAge: 60 * 60 * 24 * 7,
274
275
  })
275
- storage.set('fc', friendCode, {
276
+ sessionStorage.set('fc', friendCode, {
276
277
  path: '/',
277
278
  maxAge: 60 * 60 * 24 * 7,
278
279
  })
@@ -264,7 +264,7 @@ export default function (request) {
264
264
  setGameCode: assign((context, event) => {
265
265
  const { gameList } = context
266
266
  const gameCode = event.data
267
- const gameCodeIndex = gameList.findIndex((game) => game === gameCode)
267
+ const gameCodeIndex = gameList.findIndex((game) => game?.gameCode === gameCode)
268
268
  return {
269
269
  gameCode,
270
270
  gameCodeIndex,
@@ -305,7 +305,7 @@ export default function (request) {
305
305
  setGameCode: assign((context, event) => {
306
306
  const { gameList } = context
307
307
  const gameCode = event.data
308
- const gameCodeIndex = gameList.findIndex((game) => game === gameCode)
308
+ const gameCodeIndex = gameList.findIndex((game) => game?.gameCode === gameCode)
309
309
  return {
310
310
  gameCode,
311
311
  gameCodeIndex,
@@ -243,7 +243,8 @@ export default function (request, context) {
243
243
  },
244
244
  receiveReward: async (context, event) => {
245
245
  const { activityNo, receiveNo, attended } = event.data
246
- return await request.send(activity.getReward({ activityNo, receiveNo, appSecret, attended }))
246
+ const validateReceiveNo = Number(receiveNo) > 0 ? Number(receiveNo) : undefined
247
+ return await request.send(activity.getReward({ activityNo, receiveNo: validateReceiveNo, appSecret, attended }))
247
248
  },
248
249
  receiveAllPoints: async (context, event) => {
249
250
  return await request.send(activity.collect({ collectType: 'collectPoints', appSecret }))
@@ -263,7 +263,9 @@ export default function (request, context) {
263
263
  },
264
264
  receiveReward: async (context, event) => {
265
265
  const { activityNo, receiveNo, attended } = event.data
266
- return await request.send(activity.getReward({ activityNo, receiveNo, appSecret, attended }))
266
+ // Number("")-> 0 / Number(" ") -> 0 需要收到實際的數字才傳給後端
267
+ const validateReceiveNo = Number(receiveNo) > 0 ? Number(receiveNo) : undefined
268
+ return await request.send(activity.getReward({ activityNo, receiveNo: validateReceiveNo, appSecret, attended }))
267
269
  },
268
270
  receiveAllPoints: async (context, event) => {
269
271
  return await request.send(activity.collect({ collectType: 'collectPoints', appSecret }))
@@ -89,7 +89,8 @@ export default function (request) {
89
89
  },
90
90
  receiveReward: async (context, event) => {
91
91
  const { activityNo, receiveNo, attended } = event.data
92
- return await request.send(activity.getReward({ activityNo, receiveNo, appSecret, attended }))
92
+ const validateReceiveNo = Number(receiveNo) > 0 ? Number(receiveNo) : undefined
93
+ return await request.send(activity.getReward({ activityNo, receiveNo: validateReceiveNo, appSecret, attended }))
93
94
  },
94
95
  },
95
96
  }
@@ -111,6 +111,7 @@ const supportVersion2List = [
111
111
  'activities/types',
112
112
  'activities/promo',
113
113
  'activities/viptable',
114
+ 'activities/level-bonus/info',
114
115
  'activities/numbers',
115
116
  'activities/honorBroadcast',
116
117
  'activities/exchange/diamond/max-amount',
@@ -159,6 +160,30 @@ export default class Request {
159
160
  }
160
161
 
161
162
  initialize() {
163
+ // 自定義參數序列化器 - 避免使用 URLSearchParams
164
+ this.axios.defaults.paramsSerializer = function (params) {
165
+ return Object.keys(params)
166
+ .map((key) => {
167
+ let value = params[key]
168
+ if (value === null || value === undefined) {
169
+ return null
170
+ }
171
+ // 針對key為q的參數進行手動編碼,避免雙重編碼
172
+ if (key === 'q' && typeof value === 'string') {
173
+ // 處理其他需要編碼的字符
174
+ value = encodeURIComponent(value).replace(/[!'()*]/g, function (c) {
175
+ return '%' + c.charCodeAt(0).toString(16).toUpperCase()
176
+ })
177
+ } else {
178
+ // 對其他參數使用標準編碼
179
+ value = encodeURIComponent(value)
180
+ }
181
+ return `${encodeURIComponent(key)}=${value}`
182
+ })
183
+ .filter(Boolean)
184
+ .join('&')
185
+ }
186
+
162
187
  this.axios.interceptors.request.use((axiosConfig) => {
163
188
  axiosConfig.headers['X-TH1GAMES-VERSION'] = this.config.version
164
189
  axiosConfig.headers['X-TH1GAMES-PLATFORM'] = this.config.platform
@@ -0,0 +1,28 @@
1
+ export default {
2
+ get(name, options) {
3
+ const itemStr = sessionStorage.getItem(name)
4
+
5
+ if (!itemStr) {
6
+ return null
7
+ }
8
+
9
+ const item = JSON.parse(itemStr)
10
+ if (item.expiry && new Date().getTime() > item.expiry) {
11
+ sessionStorage.removeItem(name)
12
+ return null
13
+ }
14
+
15
+ return item.value
16
+ },
17
+ set(name, value, options) {
18
+ const item = { value }
19
+
20
+ if (options?.maxAge) {
21
+ item.expiry = new Date().getTime() + options.maxAge * 1000
22
+ }
23
+ sessionStorage.setItem(name, JSON.stringify(item))
24
+ },
25
+ remove(name, options) {
26
+ sessionStorage.removeItem(name)
27
+ },
28
+ }