@jetthai/cuora 1.0.80 → 1.0.82
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 +2 -1
- package/src/machine/auth.js +6 -2
- package/src/machine/deposit/deposit_fc.js +9 -10
- package/src/machine/index.js +2 -2
- package/src/machine/user_sign_up.js +4 -1
- package/src/machine/{withdraw.js → withdraw_fc.js} +1 -0
- package/src/request/config.js +2 -1
- package/src/util/deviceToken.js +16 -0
- package/src/machine/activity/diamond_shop_activity_single_exchange.js +0 -168
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.82](https://github.com/jetthai/cuora-module/compare/v1.0.81...v1.0.82) (2022-01-18)
|
|
6
|
+
|
|
7
|
+
### [1.0.81](https://github.com/jetthai/cuora-module/compare/v1.0.80...v1.0.81) (2022-01-18)
|
|
8
|
+
|
|
5
9
|
### [1.0.80](https://github.com/jetthai/cuora-module/compare/v1.0.79...v1.0.80) (2022-01-17)
|
|
6
10
|
|
|
7
11
|
### [1.0.79](https://github.com/jetthai/cuora-module/compare/v1.0.78...v1.0.79) (2022-01-14)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jetthai/cuora",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.82",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"webpack-cli": "^4.9.0"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
+
"@fingerprintjs/fingerprintjs-pro": "^3.5.5",
|
|
26
27
|
"lodash": "^4.17.21",
|
|
27
28
|
"qs": "^6.10.1",
|
|
28
29
|
"ua-parser-js": "^0.7.28",
|
package/src/machine/auth.js
CHANGED
|
@@ -4,9 +4,10 @@ import qs from 'qs'
|
|
|
4
4
|
import { assign, createMachine, send } from 'xstate'
|
|
5
5
|
import auth from '../api/auth'
|
|
6
6
|
import user from '../api/user'
|
|
7
|
+
import { getDeviceToken } from '../util/deviceToken'
|
|
7
8
|
|
|
8
9
|
export default function (request) {
|
|
9
|
-
const { clientId } = request.config
|
|
10
|
+
const { clientId, fpToken } = request.config
|
|
10
11
|
const tokenKey = `cuora_${clientId}`
|
|
11
12
|
const userKey = `cuora_tempuser`
|
|
12
13
|
const cookies = new Cookies()
|
|
@@ -244,8 +245,9 @@ export default function (request) {
|
|
|
244
245
|
})
|
|
245
246
|
return { token }
|
|
246
247
|
}),
|
|
247
|
-
redirectTo3Party: (context, event) => {
|
|
248
|
+
redirectTo3Party: async (context, event) => {
|
|
248
249
|
const { provider, channel = 'official', subchannel = 'pwa' } = event.data
|
|
250
|
+
const dt = await getDeviceToken(fpToken)
|
|
249
251
|
const redirectURL = urljoin(
|
|
250
252
|
request.config.fullURL,
|
|
251
253
|
'login?' +
|
|
@@ -254,6 +256,8 @@ export default function (request) {
|
|
|
254
256
|
redirectURI: `${window.location.protocol}//${window.location.host}`,
|
|
255
257
|
channel,
|
|
256
258
|
subchannel,
|
|
259
|
+
dt,
|
|
260
|
+
platform: 'pwa',
|
|
257
261
|
})
|
|
258
262
|
)
|
|
259
263
|
window.location.href = redirectURL
|
|
@@ -127,17 +127,18 @@ export default function (request) {
|
|
|
127
127
|
actions: {
|
|
128
128
|
setCryptos: assign((context, event) => {
|
|
129
129
|
return {
|
|
130
|
-
cryptos: event.data.map((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.channel })),
|
|
130
|
+
cryptos: event.data.map((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })),
|
|
131
131
|
}
|
|
132
132
|
}),
|
|
133
133
|
setCrypto: assign((context, event) => {
|
|
134
134
|
const { cryptos, currentNetwork } = context
|
|
135
|
-
const method = cryptos.find((crypto) => crypto.
|
|
135
|
+
const method = cryptos.find((crypto) => crypto.method === event.data.value)
|
|
136
136
|
const networks =
|
|
137
137
|
method?.optional.map((value, i) => {
|
|
138
138
|
return {
|
|
139
139
|
label: method?.originalItem?.[i],
|
|
140
140
|
value,
|
|
141
|
+
icon: value,
|
|
141
142
|
}
|
|
142
143
|
}) || []
|
|
143
144
|
|
|
@@ -215,24 +216,22 @@ export default function (request) {
|
|
|
215
216
|
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
216
217
|
},
|
|
217
218
|
fetchCalculation: async (context, event) => {
|
|
218
|
-
const {
|
|
219
|
-
const method = cryptos.find((crypto) => crypto.channel === currentCrypto.value)?.method
|
|
219
|
+
const { currentCrypto, currentAmount } = context
|
|
220
220
|
return await request.send(
|
|
221
221
|
payment.getDepositExpectedResult({
|
|
222
|
-
method,
|
|
222
|
+
method: currentCrypto.method,
|
|
223
223
|
amount: currentAmount,
|
|
224
|
-
cryptoCurrency: currentCrypto.
|
|
224
|
+
cryptoCurrency: currentCrypto.channel,
|
|
225
225
|
})
|
|
226
226
|
)
|
|
227
227
|
},
|
|
228
228
|
submitDeposit: async (context, event) => {
|
|
229
|
-
const {
|
|
230
|
-
const method = cryptos.find((crypto) => crypto.channel === currentCrypto.value)?.method
|
|
229
|
+
const { currentCrypto, currentNetwork, calculatedResult } = context
|
|
231
230
|
return await request.send(
|
|
232
231
|
payment.submitDepositTransaction({
|
|
233
|
-
method,
|
|
232
|
+
method: currentCrypto.method,
|
|
234
233
|
amount: calculatedResult.actualAmount,
|
|
235
|
-
cryptoCurrency: currentCrypto.
|
|
234
|
+
cryptoCurrency: currentCrypto.channel,
|
|
236
235
|
cryptoNetwork: currentNetwork.value,
|
|
237
236
|
})
|
|
238
237
|
)
|
package/src/machine/index.js
CHANGED
|
@@ -15,11 +15,11 @@ import reward from './reward'
|
|
|
15
15
|
import setting from './setting'
|
|
16
16
|
import side from './side'
|
|
17
17
|
import side_v2 from './side_v2'
|
|
18
|
-
import withdraw from './withdraw'
|
|
19
18
|
import user_info from './user_info'
|
|
20
19
|
import user_sign_up from './user_sign_up'
|
|
21
20
|
import user_reset_password from './user_reset_password'
|
|
22
21
|
import bank_binding from './bank_binding'
|
|
22
|
+
import withdraw_fc from './withdraw_fc'
|
|
23
23
|
import withdraw_vn from './withdraw_vn'
|
|
24
24
|
import deposit from './deposit'
|
|
25
25
|
import bonus from './bonus'
|
|
@@ -43,11 +43,11 @@ export default {
|
|
|
43
43
|
setting,
|
|
44
44
|
side,
|
|
45
45
|
side_v2,
|
|
46
|
-
withdraw,
|
|
47
46
|
user_info,
|
|
48
47
|
user_sign_up,
|
|
49
48
|
user_reset_password,
|
|
50
49
|
bank_binding,
|
|
50
|
+
withdraw_fc,
|
|
51
51
|
withdraw_vn,
|
|
52
52
|
...deposit,
|
|
53
53
|
bonus,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { createMachine, assign } from 'xstate'
|
|
2
2
|
import auth from '../api/auth'
|
|
3
|
+
import { getDeviceToken } from '../util/deviceToken'
|
|
3
4
|
|
|
4
5
|
export default function (request) {
|
|
6
|
+
const { fpToken } = request.config
|
|
5
7
|
return createMachine(
|
|
6
8
|
{
|
|
7
9
|
id: 'user_sign_up',
|
|
@@ -89,7 +91,8 @@ export default function (request) {
|
|
|
89
91
|
services: {
|
|
90
92
|
signUp: async (context, event) => {
|
|
91
93
|
const { email, password, channel, subchannel } = context
|
|
92
|
-
|
|
94
|
+
const dt = await getDeviceToken(fpToken)
|
|
95
|
+
return await request.send(auth.register({ provider: 'email', email, password, channel, subchannel, dt }))
|
|
93
96
|
},
|
|
94
97
|
},
|
|
95
98
|
}
|
package/src/request/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import urljoin from 'url-join'
|
|
2
2
|
|
|
3
3
|
export default class Config {
|
|
4
|
-
constructor({ apiURL, apiVersion, clientId, appSecret, platform, version }) {
|
|
4
|
+
constructor({ apiURL, apiVersion, clientId, appSecret, platform, version, fpToken }) {
|
|
5
5
|
this.apiURL = apiURL
|
|
6
6
|
this.apiVersion = apiVersion
|
|
7
7
|
this.clientId = clientId
|
|
@@ -9,6 +9,7 @@ export default class Config {
|
|
|
9
9
|
this.platform = platform
|
|
10
10
|
this.version = version
|
|
11
11
|
this.fullURL = urljoin(this.apiURL, this.apiVersion, this.clientId)
|
|
12
|
+
this.fpToken = fpToken // fingerprintjs token
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
setApiURL(url) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import FingerprintJS from '@fingerprintjs/fingerprintjs-pro'
|
|
2
|
+
|
|
3
|
+
const getDeviceToken = async (fpToken) => {
|
|
4
|
+
let dt
|
|
5
|
+
try {
|
|
6
|
+
const fp = await FingerprintJS.load({ token: fpToken })
|
|
7
|
+
const result = await fp.get()
|
|
8
|
+
dt = result.visitorId
|
|
9
|
+
console.log('[Device Token]', dt)
|
|
10
|
+
} catch (error) {
|
|
11
|
+
console.log(error)
|
|
12
|
+
}
|
|
13
|
+
return dt
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { getDeviceToken }
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { createMachine, assign } from 'xstate'
|
|
2
|
-
import api from '../../api/activity'
|
|
3
|
-
|
|
4
|
-
export default function (request) {
|
|
5
|
-
const { appSecret } = request.config
|
|
6
|
-
return createMachine(
|
|
7
|
-
{
|
|
8
|
-
id: 'diamond_shop_activity',
|
|
9
|
-
context: {
|
|
10
|
-
activityNo: null,
|
|
11
|
-
activityDetail: null,
|
|
12
|
-
awards: [],
|
|
13
|
-
exchangeList: [],
|
|
14
|
-
exchangeAward: 0,
|
|
15
|
-
exchangePoint: 0,
|
|
16
|
-
},
|
|
17
|
-
initial: 'idle',
|
|
18
|
-
states: {
|
|
19
|
-
idle: {
|
|
20
|
-
on: {
|
|
21
|
-
SET_ACTIVITY_NO: {
|
|
22
|
-
target: 'loading',
|
|
23
|
-
actions: 'setActivityNo',
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
loading: {
|
|
28
|
-
invoke: {
|
|
29
|
-
src: 'fetchActivityDetail',
|
|
30
|
-
onDone: {
|
|
31
|
-
target: 'loaded',
|
|
32
|
-
actions: ['setActivityDetail', 'setAwardList'],
|
|
33
|
-
},
|
|
34
|
-
onError: {
|
|
35
|
-
target: 'idle',
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
loaded: {
|
|
40
|
-
on: {
|
|
41
|
-
EXCHANGE: {
|
|
42
|
-
target: 'exchanging',
|
|
43
|
-
cond: 'isExchangeable',
|
|
44
|
-
},
|
|
45
|
-
ADD_TO_CART: {
|
|
46
|
-
actions: ['addProduct', 'count'],
|
|
47
|
-
},
|
|
48
|
-
CLEAR_CART: {
|
|
49
|
-
actions: ['clearCart', 'count'],
|
|
50
|
-
},
|
|
51
|
-
COLLECT: {
|
|
52
|
-
target: 'collecting',
|
|
53
|
-
cond: 'hasUnclaimedReward',
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
exchanging: {
|
|
58
|
-
invoke: {
|
|
59
|
-
src: 'exchange',
|
|
60
|
-
onDone: {
|
|
61
|
-
target: 'collecting',
|
|
62
|
-
actions: ['clearCart', 'count'],
|
|
63
|
-
},
|
|
64
|
-
onError: {
|
|
65
|
-
target: 'loaded',
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
collecting: {
|
|
70
|
-
invoke: {
|
|
71
|
-
src: 'collect',
|
|
72
|
-
onDone: {
|
|
73
|
-
target: 'collected',
|
|
74
|
-
},
|
|
75
|
-
onError: {
|
|
76
|
-
target: 'collected',
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
collected: {
|
|
81
|
-
after: {
|
|
82
|
-
0: {
|
|
83
|
-
target: 'loaded',
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
actions: {
|
|
91
|
-
setActivityNo: assign((context, event) => {
|
|
92
|
-
return {
|
|
93
|
-
activityNo: event.data,
|
|
94
|
-
}
|
|
95
|
-
}),
|
|
96
|
-
setActivityDetail: assign((context, event) => {
|
|
97
|
-
return {
|
|
98
|
-
activityDetail: event.data,
|
|
99
|
-
}
|
|
100
|
-
}),
|
|
101
|
-
setAwardList: assign((context, event) => {
|
|
102
|
-
return {
|
|
103
|
-
awardList: event.data?.awards || [],
|
|
104
|
-
}
|
|
105
|
-
}),
|
|
106
|
-
addProduct: assign((context, event) => {
|
|
107
|
-
return {
|
|
108
|
-
exchangeList: [...context.exchangeList, event.data],
|
|
109
|
-
}
|
|
110
|
-
}),
|
|
111
|
-
clearCart: assign((context, event) => {
|
|
112
|
-
return {
|
|
113
|
-
exchangeList: [],
|
|
114
|
-
}
|
|
115
|
-
}),
|
|
116
|
-
count: assign((context, event) => {
|
|
117
|
-
const { exchangeList } = context
|
|
118
|
-
const { exchangeAward, exchangePoint } = exchangeList.reduce(
|
|
119
|
-
({ exchangeAward, exchangePoint }, item) => {
|
|
120
|
-
return {
|
|
121
|
-
exchangeAward: exchangeAward + item.award,
|
|
122
|
-
exchangePoint: exchangePoint + item.points,
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
{ exchangeAward: 0, exchangePoint: 0 }
|
|
126
|
-
)
|
|
127
|
-
return {
|
|
128
|
-
exchangeAward,
|
|
129
|
-
exchangePoint,
|
|
130
|
-
}
|
|
131
|
-
}),
|
|
132
|
-
},
|
|
133
|
-
guards: {
|
|
134
|
-
hasUnclaimedReward: (context, event) => {
|
|
135
|
-
return context.activityDetail?.unclaimedReward?.length > 0
|
|
136
|
-
},
|
|
137
|
-
isExchangeable: (context, event) => {
|
|
138
|
-
const { exchangeList } = context
|
|
139
|
-
return exchangeList.length > 0
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
services: {
|
|
143
|
-
fetchActivityDetail: async (context, event) => {
|
|
144
|
-
const { activityNo } = context
|
|
145
|
-
const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }))
|
|
146
|
-
return data
|
|
147
|
-
},
|
|
148
|
-
exchange: async (context, event) => {
|
|
149
|
-
const { activityNo, exchangeList } = context
|
|
150
|
-
return await Promise.all(
|
|
151
|
-
exchangeList.map((item) =>
|
|
152
|
-
request.send(
|
|
153
|
-
api.exchange({
|
|
154
|
-
exchangeType: 1,
|
|
155
|
-
activityNo,
|
|
156
|
-
exchangeAward: item.award,
|
|
157
|
-
})
|
|
158
|
-
)
|
|
159
|
-
)
|
|
160
|
-
)
|
|
161
|
-
},
|
|
162
|
-
collect: async (context, event) => {
|
|
163
|
-
return await request.send(api.collect({ appSecret }))
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
|
-
}
|
|
167
|
-
)
|
|
168
|
-
}
|