@jetthai/cuora 1.1.394-dev-1 → 1.1.394-dev-3
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 +8 -0
- package/package.json +1 -1
- package/src/api/index.js +2 -1
- package/src/api/otp.js +5 -0
- package/src/machine/activity/fafafa_activity.js +37 -4
- package/src/machine/auth_otp_v3.js +29 -7
- package/src/request/request.js +4 -0
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.394-dev-3](https://github.com/jetthai/cuora-module/compare/v1.1.394-dev-2...v1.1.394-dev-3) (2025-11-10)
|
|
6
|
+
|
|
7
|
+
### [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)
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
- 新增活動週期自動更新檢查機制 ([d80ff18](https://github.com/jetthai/cuora-module/commit/d80ff188b25fb1576fd25edc8ed985ae1f1b6af6))
|
|
12
|
+
|
|
5
13
|
### [1.1.394-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.394...v1.1.394-dev-1) (2025-11-10)
|
|
6
14
|
|
|
7
15
|
### [1.1.394](https://github.com/jetthai/cuora-module/compare/v1.1.393...v1.1.394) (2025-11-04)
|
package/package.json
CHANGED
package/src/api/index.js
CHANGED
|
@@ -8,5 +8,6 @@ import user from './user.js'
|
|
|
8
8
|
import form from './form.js'
|
|
9
9
|
import ranking from './ranking.js'
|
|
10
10
|
import account from './account.js'
|
|
11
|
+
import otp from './otp.js'
|
|
11
12
|
|
|
12
|
-
export default { activity, auth, common, game, mailbox, payment, user, form, ranking, account }
|
|
13
|
+
export default { activity, auth, common, game, mailbox, payment, user, form, ranking, account, otp }
|
package/src/api/otp.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
verification: (data) => ({ url: 'otp-verification-point/verify', method: 'POST', params: data }),
|
|
3
|
+
acknowledge: (data) => ({ url: 'otp-verification-point/acknowledge', method: 'POST', params: data }),
|
|
4
|
+
reset: (data) => ({ url: 'otp-verification-point/reset-otp', method: 'POST', params: data }),
|
|
5
|
+
}
|
|
@@ -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) => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import user from '../api/user.js'
|
|
3
|
-
import
|
|
4
|
-
import account from '../api/account.js'
|
|
3
|
+
import otp from '../api/otp.js'
|
|
5
4
|
|
|
6
5
|
export default function (request) {
|
|
7
6
|
return createMachine(
|
|
@@ -244,20 +243,38 @@ export default function (request) {
|
|
|
244
243
|
return await request.send(user.getUserInfo())
|
|
245
244
|
},
|
|
246
245
|
verify: async (context, event) => {
|
|
247
|
-
return await request.send(
|
|
246
|
+
return await request.send(
|
|
247
|
+
otp.verification({
|
|
248
|
+
strategy: context.strategy,
|
|
249
|
+
email: event.data.email,
|
|
250
|
+
countryCode: event.data.country_code,
|
|
251
|
+
phone: event.data.tel,
|
|
252
|
+
})
|
|
253
|
+
)
|
|
248
254
|
},
|
|
249
255
|
sendPhone: async (context, event) => {
|
|
250
256
|
const { countryCode, phone } = context
|
|
251
|
-
return await request.send(
|
|
257
|
+
return await request.send(
|
|
258
|
+
otp.verification({
|
|
259
|
+
strategy: 'phone',
|
|
260
|
+
countryCode,
|
|
261
|
+
phone,
|
|
262
|
+
})
|
|
263
|
+
)
|
|
252
264
|
},
|
|
253
265
|
sendEmail: async (context, event) => {
|
|
254
266
|
const { email } = context
|
|
255
|
-
return await request.send(
|
|
267
|
+
return await request.send(
|
|
268
|
+
otp.verification({
|
|
269
|
+
strategy: 'email',
|
|
270
|
+
email,
|
|
271
|
+
})
|
|
272
|
+
)
|
|
256
273
|
},
|
|
257
274
|
resetOtp: async (context, event) => {
|
|
258
275
|
const { requestId, target } = context
|
|
259
276
|
return await request.send(
|
|
260
|
-
|
|
277
|
+
otp.reset({
|
|
261
278
|
request_id: requestId,
|
|
262
279
|
})
|
|
263
280
|
)
|
|
@@ -265,7 +282,12 @@ export default function (request) {
|
|
|
265
282
|
acknowledge: async (context, event) => {
|
|
266
283
|
const { requestId, target } = context
|
|
267
284
|
const code = event.data
|
|
268
|
-
return await request.send(
|
|
285
|
+
return await request.send(
|
|
286
|
+
otp.acknowledge({
|
|
287
|
+
request_id: requestId,
|
|
288
|
+
code,
|
|
289
|
+
})
|
|
290
|
+
)
|
|
269
291
|
},
|
|
270
292
|
},
|
|
271
293
|
}
|
package/src/request/request.js
CHANGED
|
@@ -149,6 +149,10 @@ const supportVersion2List = [
|
|
|
149
149
|
'account-binding/bind-third-party',
|
|
150
150
|
'account-binding/bind-password',
|
|
151
151
|
'account-binding/reset-otp',
|
|
152
|
+
// 11/10
|
|
153
|
+
'otp-verification-point/verify',
|
|
154
|
+
'otp-verification-point/acknowledge',
|
|
155
|
+
'otp-verification-point/reset-otp',
|
|
152
156
|
]
|
|
153
157
|
|
|
154
158
|
function isValid(value) {
|