@jetthai/cuora 1.0.99 → 1.0.101
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 +4 -0
- package/package.json +1 -1
- package/src/api/user.js +14 -0
- package/src/machine/auth_otp_v2.js +167 -0
- package/src/machine/deposit/manual_vn.js +1 -0
- package/src/machine/index.js +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
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.0.101](https://github.com/jetthai/cuora-module/compare/v1.0.100...v1.0.101) (2022-03-17)
|
|
6
|
+
|
|
7
|
+
### [1.0.100](https://github.com/jetthai/cuora-module/compare/v1.0.99...v1.0.100) (2022-03-10)
|
|
8
|
+
|
|
5
9
|
### [1.0.99](https://github.com/jetthai/cuora-module/compare/v1.0.98...v1.0.99) (2022-03-10)
|
|
6
10
|
|
|
7
11
|
### [1.0.98](https://github.com/jetthai/cuora-module/compare/v1.0.97...v1.0.98) (2022-03-09)
|
package/package.json
CHANGED
package/src/api/user.js
CHANGED
|
@@ -34,4 +34,18 @@ export default {
|
|
|
34
34
|
params: { requestId, target, newPassword },
|
|
35
35
|
isPublic: true,
|
|
36
36
|
}),
|
|
37
|
+
// /verify/v2/* 為已登入時的otp驗證
|
|
38
|
+
verifyV2Initiate: ({ strategy }) => ({
|
|
39
|
+
// strategy: 'phone' | 'email'
|
|
40
|
+
url: '/verify/v2/initiate',
|
|
41
|
+
method: 'post',
|
|
42
|
+
params: { strategy },
|
|
43
|
+
}),
|
|
44
|
+
verifyV2Acknowledge: ({ requestId, target, code }) => ({
|
|
45
|
+
url: '/verify/v2/acknowledge',
|
|
46
|
+
method: 'post',
|
|
47
|
+
params: { requestId, target, code },
|
|
48
|
+
isPublic: true,
|
|
49
|
+
}),
|
|
50
|
+
verifyV2Reset: ({ requestId, target }) => ({ url: '/verify/v2/reset', method: 'post', params: { requestId, target }, isPublic: true }),
|
|
37
51
|
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { createMachine, assign } from 'xstate'
|
|
2
|
+
import user from '../api/user'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
return createMachine(
|
|
6
|
+
{
|
|
7
|
+
id: 'auth_otp_v2',
|
|
8
|
+
initial: 'idle',
|
|
9
|
+
context: {
|
|
10
|
+
strategy: null,
|
|
11
|
+
requestId: null,
|
|
12
|
+
ttl: null,
|
|
13
|
+
target: {},
|
|
14
|
+
acknowledgeTtl: null,
|
|
15
|
+
newPassword: null,
|
|
16
|
+
},
|
|
17
|
+
states: {
|
|
18
|
+
idle: {
|
|
19
|
+
on: {
|
|
20
|
+
SEND_OTP_EMAIL: {
|
|
21
|
+
target: 'otpFetching',
|
|
22
|
+
actions: 'setStrategyEmail',
|
|
23
|
+
},
|
|
24
|
+
SEND_OTP_PHONE: {
|
|
25
|
+
target: 'otpFetching',
|
|
26
|
+
actions: 'setStrategyPhone',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
otpFetching: {
|
|
31
|
+
invoke: {
|
|
32
|
+
src: 'sendOtp',
|
|
33
|
+
onDone: {
|
|
34
|
+
target: 'otp',
|
|
35
|
+
actions: 'setOtpResult',
|
|
36
|
+
},
|
|
37
|
+
onError: {
|
|
38
|
+
target: 'idle',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
otp: {
|
|
43
|
+
after: {
|
|
44
|
+
1000: [
|
|
45
|
+
{
|
|
46
|
+
target: 'otp',
|
|
47
|
+
actions: 'decreaseTtl',
|
|
48
|
+
cond: (context) => context.ttl > 0,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
target: 'idle',
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
on: {
|
|
56
|
+
ACKNOWLEDGE: {
|
|
57
|
+
target: 'acknowledging',
|
|
58
|
+
},
|
|
59
|
+
BACK: {
|
|
60
|
+
target: 'idle',
|
|
61
|
+
},
|
|
62
|
+
RESET_OTP: {
|
|
63
|
+
target: 'otpResetting',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
otpResetting: {
|
|
68
|
+
invoke: {
|
|
69
|
+
src: 'resetOtp',
|
|
70
|
+
onDone: {
|
|
71
|
+
target: 'otp',
|
|
72
|
+
actions: 'setOtpResult',
|
|
73
|
+
},
|
|
74
|
+
onError: {
|
|
75
|
+
target: 'otp',
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
acknowledging: {
|
|
80
|
+
invoke: {
|
|
81
|
+
src: 'acknowledge',
|
|
82
|
+
onDone: {
|
|
83
|
+
target: 'acknowledged',
|
|
84
|
+
actions: 'setAcknowledgeResult',
|
|
85
|
+
},
|
|
86
|
+
onError: [
|
|
87
|
+
{
|
|
88
|
+
target: 'idle',
|
|
89
|
+
cond: (context, event) => event.data.code === 'ERR_A108',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
target: 'otp',
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
acknowledged: {
|
|
98
|
+
// after: {
|
|
99
|
+
// 1000: [
|
|
100
|
+
// {
|
|
101
|
+
// target: 'acknowledged',
|
|
102
|
+
// actions: 'decreaseAcknowledgeTtl',
|
|
103
|
+
// cond: (context) => context.acknowledgeTtl > 0,
|
|
104
|
+
// },
|
|
105
|
+
// {
|
|
106
|
+
// target: 'idle',
|
|
107
|
+
// },
|
|
108
|
+
// ],
|
|
109
|
+
// },
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
actions: {
|
|
115
|
+
setStrategyPhone: assign((context, event) => {
|
|
116
|
+
return {
|
|
117
|
+
strategy: 'phone',
|
|
118
|
+
}
|
|
119
|
+
}),
|
|
120
|
+
setStrategyEmail: assign((context, event) => {
|
|
121
|
+
return {
|
|
122
|
+
strategy: 'email',
|
|
123
|
+
}
|
|
124
|
+
}),
|
|
125
|
+
setOtpResult: assign((context, event) => {
|
|
126
|
+
const { requestId, ttl, target } = event.data
|
|
127
|
+
return {
|
|
128
|
+
requestId,
|
|
129
|
+
ttl,
|
|
130
|
+
target,
|
|
131
|
+
}
|
|
132
|
+
}),
|
|
133
|
+
decreaseTtl: assign((context, event) => {
|
|
134
|
+
return {
|
|
135
|
+
ttl: Math.max(context.ttl - 1, 0),
|
|
136
|
+
}
|
|
137
|
+
}),
|
|
138
|
+
setAcknowledgeResult: assign((context, event) => {
|
|
139
|
+
const { requestId, ttl, target } = event.data
|
|
140
|
+
return {
|
|
141
|
+
acknowledgeTtl: ttl,
|
|
142
|
+
}
|
|
143
|
+
}),
|
|
144
|
+
decreaseAcknowledgeTtl: assign((context, event) => {
|
|
145
|
+
return {
|
|
146
|
+
acknowledgeTtl: Math.max(context.acknowledgeTtl - 1, 0),
|
|
147
|
+
}
|
|
148
|
+
}),
|
|
149
|
+
},
|
|
150
|
+
services: {
|
|
151
|
+
sendOtp: async (context, event) => {
|
|
152
|
+
const { strategy } = context
|
|
153
|
+
return await request.send(user.verifyV2Initiate({ strategy }))
|
|
154
|
+
},
|
|
155
|
+
resetOtp: async (context, event) => {
|
|
156
|
+
const { requestId, target } = context
|
|
157
|
+
return await request.send(user.verifyV2Reset({ requestId, target }))
|
|
158
|
+
},
|
|
159
|
+
acknowledge: async (context, event) => {
|
|
160
|
+
const { requestId, target } = context
|
|
161
|
+
const code = event.data
|
|
162
|
+
return await request.send(user.verifyV2Acknowledge({ requestId, target, code }))
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
}
|
|
166
|
+
)
|
|
167
|
+
}
|
|
@@ -198,6 +198,7 @@ export default function (request) {
|
|
|
198
198
|
|
|
199
199
|
const formattedPlayerBanks = playerBanks.map((bank) => {
|
|
200
200
|
bank.shortName = `${bank.bankCode} ${bank.accountNumber.slice(-5)}`
|
|
201
|
+
bank.imageUrl = event.data.find((item) => item.bankCode === bank.bankCode)?.imageUrl
|
|
201
202
|
return bank
|
|
202
203
|
})
|
|
203
204
|
|
package/src/machine/index.js
CHANGED
|
@@ -24,6 +24,7 @@ import withdraw_vn from './withdraw_vn'
|
|
|
24
24
|
import deposit from './deposit'
|
|
25
25
|
import bonus from './bonus'
|
|
26
26
|
import leaderboard from './leaderboard'
|
|
27
|
+
import auth_otp_v2 from './auth_otp_v2'
|
|
27
28
|
|
|
28
29
|
export default {
|
|
29
30
|
...activity,
|
|
@@ -53,4 +54,5 @@ export default {
|
|
|
53
54
|
...deposit,
|
|
54
55
|
bonus,
|
|
55
56
|
leaderboard,
|
|
57
|
+
auth_otp_v2,
|
|
56
58
|
}
|