@jetthai/cuora 1.1.393 → 1.1.394-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,16 @@
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.394-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.394-dev-1...v1.1.394-dev-2) (2025-11-10)
6
+
7
+ ### Features
8
+
9
+ - 新增活動週期自動更新檢查機制 ([d80ff18](https://github.com/jetthai/cuora-module/commit/d80ff188b25fb1576fd25edc8ed985ae1f1b6af6))
10
+
11
+ ### [1.1.394-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.394...v1.1.394-dev-1) (2025-11-10)
12
+
13
+ ### [1.1.394](https://github.com/jetthai/cuora-module/compare/v1.1.393...v1.1.394) (2025-11-04)
14
+
5
15
  ### [1.1.393](https://github.com/jetthai/cuora-module/compare/v1.1.392...v1.1.393) (2025-10-17)
6
16
 
7
17
  ### [1.1.392](https://github.com/jetthai/cuora-module/compare/v1.1.391...v1.1.392) (2025-10-17)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.393",
3
+ "version": "1.1.394-dev-2",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -0,0 +1,8 @@
1
+ export default {
2
+ bindingStatus: () => ({ url: 'account-binding/status', method: 'GET' }),
3
+ applyBinding: (data) => ({ url: 'account-binding/bind', method: 'POST', params: data }),
4
+ bindingVerification: (data) => ({ url: 'account-binding/acknowledge', method: 'POST', params: data }),
5
+ bindThirdParty: (data) => ({ url: 'account-binding/bind-third-party', method: 'GET', params: data }),
6
+ bindPassword: (data) => ({ url: 'account-binding/bind-password', method: 'POST', params: data }),
7
+ resetOtp: (data) => ({ url: 'account-binding/reset-otp', method: 'POST', params: data }),
8
+ }
package/src/api/common.js CHANGED
@@ -7,4 +7,9 @@ export default {
7
7
  getNavbar: ({ appSecret } = {}) => ({ url: 'getNavbarSetting', params: { appSecret }, method: 'get', isPublic: true }),
8
8
  getDefaultAffiliateCode: ({ appSecret }) => ({ url: 'getAffiliateCode', params: { appSecret }, method: 'get', isPublic: true }),
9
9
  getSiteInfoConfig: ({ appSecret, config }) => ({ url: 'get-site-config', method: 'get', params: { appSecret, config }, isPublic: true }),
10
+ sendPixel: ({ appSecret, eventId, fbc, fbp, event }) => ({
11
+ url: 'pixel',
12
+ method: 'post',
13
+ params: { appSecret, eventId, fbc, fbp, event },
14
+ }),
10
15
  }
package/src/api/index.js CHANGED
@@ -7,5 +7,6 @@ import payment from './payment.js'
7
7
  import user from './user.js'
8
8
  import form from './form.js'
9
9
  import ranking from './ranking.js'
10
+ import account from './account.js'
10
11
 
11
- export default { activity, auth, common, game, mailbox, payment, user, form, ranking }
12
+ export default { activity, auth, common, game, mailbox, payment, user, form, ranking, account }
@@ -13,6 +13,7 @@ export default function (request, context) {
13
13
  activityNo,
14
14
  activityDetail: null,
15
15
  duration: 0,
16
+ lastCheckedPeriodEndTime: null, // 追蹤已檢查過的週期結束時間
16
17
 
17
18
  // 領獎後得到的資訊
18
19
  awards: [],
@@ -54,17 +55,19 @@ export default function (request, context) {
54
55
  },
55
56
  },
56
57
  after: {
57
- 1000: {
58
- target: 'awardable',
59
- },
58
+ 1000: [{ target: 'loading', cond: 'shouldCheckNewPeriod' }, { target: 'awardable' }],
60
59
  },
61
60
  },
62
61
  awarded: {
62
+ entry: 'setDuration',
63
63
  on: {
64
64
  REFRESH_ACTIVITY: {
65
65
  target: 'loading',
66
66
  },
67
67
  },
68
+ after: {
69
+ 1000: [{ target: 'loading', cond: 'shouldCheckNewPeriod' }, { target: 'awarded' }],
70
+ },
68
71
  },
69
72
  awarding: {
70
73
  invoke: {
@@ -97,7 +100,17 @@ export default function (request, context) {
97
100
  },
98
101
  },
99
102
  },
100
- result: {},
103
+ result: {
104
+ entry: 'setDuration',
105
+ on: {
106
+ REFRESH_ACTIVITY: {
107
+ target: 'loading',
108
+ },
109
+ },
110
+ after: {
111
+ 1000: [{ target: 'loading', cond: 'shouldCheckNewPeriod' }, { target: 'result' }],
112
+ },
113
+ },
101
114
  },
102
115
  on: {
103
116
  START: {
@@ -118,6 +131,8 @@ export default function (request, context) {
118
131
  setActivityDetail: assign((context, event) => {
119
132
  return {
120
133
  activityDetail: event.data,
134
+ // 重置 lastCheckedPeriodEndTime,允許新週期結束時再次檢查
135
+ lastCheckedPeriodEndTime: null,
121
136
  }
122
137
  }),
123
138
  setAward: assign((context, event) => {
@@ -151,6 +166,24 @@ export default function (request, context) {
151
166
  isAutoReceiving: (context, event) => {
152
167
  return context.isAutoReceiving
153
168
  },
169
+ shouldCheckNewPeriod: (context, event) => {
170
+ // 當倒數計時結束時,重新檢查活動狀態
171
+ // 使用 lastCheckedPeriodEndTime 避免同一週期重複呼叫 API
172
+ const periodEndTime = context?.activityDetail?.periodEndTime
173
+
174
+ // 如果 duration 為 0,且這個週期還沒檢查過,則觸發更新
175
+ if (context.duration === 0 && periodEndTime) {
176
+ // 如果是新的週期結束時間,或者還沒檢查過,則允許觸發
177
+ if (context.lastCheckedPeriodEndTime !== periodEndTime) {
178
+ // 更新 lastCheckedPeriodEndTime(在 guard 中直接修改 context 是不好的做法,
179
+ // 但這裡是為了避免重複觸發,是可接受的權衡)
180
+ context.lastCheckedPeriodEndTime = periodEndTime
181
+ return true
182
+ }
183
+ }
184
+
185
+ return false
186
+ },
154
187
  },
155
188
  services: {
156
189
  fetchActivityDetail: async (context, event) => {
@@ -451,7 +451,7 @@ export default function (request) {
451
451
  affiliateCode,
452
452
  nickname,
453
453
  }
454
- sentry.captureMessage(JSON.stringify(messages))
454
+ sentry?.captureMessage(JSON.stringify(messages))
455
455
 
456
456
  const referralObj = {}
457
457
  if (![undefined, 'undefined', null, 'null'].includes(affiliateCode)) {
@@ -481,7 +481,7 @@ export default function (request) {
481
481
  window.location.href = redirectURL
482
482
  },
483
483
  setUserInfo: assign((context, event) => {
484
- sentry.setUser({ id: event.data.uid_site })
484
+ sentry?.setUser({ id: event.data.uid_site })
485
485
  return {
486
486
  userInfo: event.data,
487
487
  }
@@ -1,6 +1,7 @@
1
1
  import { assign, createMachine } from 'xstate'
2
2
  import user from '../api/user.js'
3
3
  import auth from '../api/auth.js'
4
+ import account from '../api/account.js'
4
5
 
5
6
  export default function (request) {
6
7
  return createMachine(
@@ -178,12 +179,16 @@ export default function (request) {
178
179
  }
179
180
  }),
180
181
  setVerificationData: assign((context, event) => {
181
- const { requestId, ttl, target, status } = event.data
182
+ const { request_id, ttl, email, countryCode, phone } = event.data
182
183
  return {
183
- requestId,
184
- ttl: ttl * 1000,
185
- target,
186
- status,
184
+ requestId: request_id,
185
+ ttl: ttl, // 後端傳過來的是毫秒
186
+ target: {
187
+ provider: context.strategy,
188
+ email: email,
189
+ countryCode: countryCode,
190
+ phone: phone,
191
+ },
187
192
  }
188
193
  }),
189
194
  decreaseTtl: assign((context, evnet) => {
@@ -239,24 +244,28 @@ export default function (request) {
239
244
  return await request.send(user.getUserInfo())
240
245
  },
241
246
  verify: async (context, event) => {
242
- return await request.send(user.verifyV2Initiate({ strategy: context.strategy }))
247
+ return await request.send(account.applyBinding({ provider: context.strategy }))
243
248
  },
244
249
  sendPhone: async (context, event) => {
245
250
  const { countryCode, phone } = context
246
- return await request.send(auth.bindPost({ provider: 'phone', countryCode, phone }))
251
+ return await request.send(account.applyBinding({ provider: 'phone', countryCode, phone }))
247
252
  },
248
253
  sendEmail: async (context, event) => {
249
254
  const { email } = context
250
- return await request.send(auth.bindPost({ provider: 'email', email }))
255
+ return await request.send(account.applyBinding({ provider: 'email', email }))
251
256
  },
252
257
  resetOtp: async (context, event) => {
253
258
  const { requestId, target } = context
254
- return await request.send(user.otpReset({ requestId, target }))
259
+ return await request.send(
260
+ account.resetOtp({
261
+ request_id: requestId,
262
+ })
263
+ )
255
264
  },
256
265
  acknowledge: async (context, event) => {
257
266
  const { requestId, target } = context
258
267
  const code = event.data
259
- return await request.send(user.otpAcknowledge({ requestId, target, code }))
268
+ return await request.send(account.bindingVerification({ requestId, code }))
260
269
  },
261
270
  },
262
271
  }
@@ -164,7 +164,6 @@ export default function (request) {
164
164
  pixType: null,
165
165
  firstNameLocale: null,
166
166
  lastNameLocale: null,
167
- holderName: null,
168
167
  }
169
168
  }),
170
169
  },
@@ -55,7 +55,7 @@ export default function (request) {
55
55
  },
56
56
  },
57
57
  fetching: {
58
- entry: ['setUA', 'setAgent', 'setPixel', 'setKPixel'],
58
+ entry: ['setUA', 'setAgent', 'setPixel', 'setKPixel', 'setFbclid'],
59
59
  invoke: {
60
60
  src: 'fetchConfig',
61
61
  onDone: [
@@ -237,6 +237,18 @@ export default function (request) {
237
237
  isMobile: userAgent?.device?.type,
238
238
  }
239
239
  }),
240
+ setFbclid: assign(() => {
241
+ const urlParams = new URLSearchParams(window.location.search)
242
+ const fbclid = urlParams.get('fbclid') || ''
243
+ if (fbclid !== '') {
244
+ const timestamp = Date.now()
245
+ const cookieRecord = 'fb.1.' + timestamp + '.' + fbclid
246
+ document.cookie = `_fbc=${cookieRecord}; path=/; max-age=${60 * 60 * 24 * 7}`
247
+ }
248
+ return {
249
+ fbclid,
250
+ }
251
+ }),
240
252
  setPixel: assign(() => {
241
253
  let urlParams = new URLSearchParams(window.location.search)
242
254
  const pix = urlParams.get('pix') || storage.get('pix') || ''
@@ -66,6 +66,9 @@ export default function (request) {
66
66
  },
67
67
  },
68
68
  },
69
+ resetDebounce: {
70
+ always: 'debouncing',
71
+ },
69
72
  debouncing: {
70
73
  after: {
71
74
  500: {
@@ -135,12 +138,12 @@ export default function (request) {
135
138
  },
136
139
  on: {
137
140
  SET_KEYWORD: {
138
- target: '.debouncing',
141
+ target: '.resetDebounce',
139
142
  actions: ['setKeyword', 'setLang'],
140
143
  cond: 'isInitialized',
141
144
  },
142
145
  CLEAR_KEYWORD: {
143
- target: '.debouncing',
146
+ target: '.resetDebounce',
144
147
  actions: 'clearKeyword',
145
148
  },
146
149
  SET_TAG_ID: [
@@ -140,6 +140,15 @@ const supportVersion2List = [
140
140
  'game/list/v3/gameInfo',
141
141
  'payment/v2/uploadCommonSlip',
142
142
  'game/history/options',
143
+ // 09/30
144
+ 'pixel',
145
+ // 10/09
146
+ 'account-binding/status',
147
+ 'account-binding/bind',
148
+ 'account-binding/acknowledge',
149
+ 'account-binding/bind-third-party',
150
+ 'account-binding/bind-password',
151
+ 'account-binding/reset-otp',
143
152
  ]
144
153
 
145
154
  function isValid(value) {