@jetthai/cuora 1.0.86 → 1.0.88
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/machine/auth.js +7 -6
- package/src/machine/user_sign_up.js +2 -2
- package/src/machine/withdraw_vn.js +4 -17
- package/src/request/config.js +2 -1
- package/src/util/deviceToken.js +9 -2
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.88](https://github.com/jetthai/cuora-module/compare/v1.0.87...v1.0.88) (2022-02-10)
|
|
6
|
+
|
|
7
|
+
### [1.0.87](https://github.com/jetthai/cuora-module/compare/v1.0.86...v1.0.87) (2022-02-09)
|
|
8
|
+
|
|
5
9
|
### [1.0.86](https://github.com/jetthai/cuora-module/compare/v1.0.85...v1.0.86) (2022-02-07)
|
|
6
10
|
|
|
7
11
|
### [1.0.85](https://github.com/jetthai/cuora-module/compare/v1.0.84...v1.0.85) (2022-01-25)
|
package/package.json
CHANGED
package/src/machine/auth.js
CHANGED
|
@@ -10,7 +10,7 @@ import user from '../api/user'
|
|
|
10
10
|
import { getDeviceToken } from '../util/deviceToken'
|
|
11
11
|
|
|
12
12
|
export default function (request) {
|
|
13
|
-
const { clientId, fpToken } = request.config
|
|
13
|
+
const { clientId, fpToken, sentry } = request.config
|
|
14
14
|
const tokenKey = `cuora_${clientId}`
|
|
15
15
|
const userKey = `cuora_tempuser`
|
|
16
16
|
const cookies = new Cookies()
|
|
@@ -54,9 +54,6 @@ export default function (request) {
|
|
|
54
54
|
LOGIN_3PARTY: {
|
|
55
55
|
actions: 'redirectTo3Party',
|
|
56
56
|
},
|
|
57
|
-
LOGIN_TOKEN: {
|
|
58
|
-
actions: 'setToken',
|
|
59
|
-
},
|
|
60
57
|
},
|
|
61
58
|
},
|
|
62
59
|
authentication: {
|
|
@@ -159,6 +156,10 @@ export default function (request) {
|
|
|
159
156
|
},
|
|
160
157
|
},
|
|
161
158
|
on: {
|
|
159
|
+
LOGIN_TOKEN: {
|
|
160
|
+
target: 'idle',
|
|
161
|
+
actions: 'setToken',
|
|
162
|
+
},
|
|
162
163
|
CLEAR: {
|
|
163
164
|
target: '.logout',
|
|
164
165
|
},
|
|
@@ -250,7 +251,7 @@ export default function (request) {
|
|
|
250
251
|
}),
|
|
251
252
|
redirectTo3Party: async (context, event) => {
|
|
252
253
|
const { provider, channel, subchannel } = event.data
|
|
253
|
-
const dt = await getDeviceToken(fpToken)
|
|
254
|
+
const dt = await getDeviceToken({ fpToken, sentry })
|
|
254
255
|
const redirectParams = omitBy(omitBy({ channel, subchannel }, isUndefined), isNull)
|
|
255
256
|
const query = new URLSearchParams(redirectParams).toString()
|
|
256
257
|
const redirectURI = urljoin(`${window.location.protocol}//${window.location.host}`, query ? `?${query}` : '')
|
|
@@ -276,7 +277,7 @@ export default function (request) {
|
|
|
276
277
|
},
|
|
277
278
|
services: {
|
|
278
279
|
authenticate: async (context, event) => {
|
|
279
|
-
const dt = await getDeviceToken(fpToken)
|
|
280
|
+
const dt = await getDeviceToken({ fpToken, sentry })
|
|
280
281
|
const data = { ...context.loginData, dt }
|
|
281
282
|
const { token } = await request.send(auth.login(data))
|
|
282
283
|
return token
|
|
@@ -3,7 +3,7 @@ import auth from '../api/auth'
|
|
|
3
3
|
import { getDeviceToken } from '../util/deviceToken'
|
|
4
4
|
|
|
5
5
|
export default function (request) {
|
|
6
|
-
const { fpToken } = request.config
|
|
6
|
+
const { fpToken, sentry } = request.config
|
|
7
7
|
return createMachine(
|
|
8
8
|
{
|
|
9
9
|
id: 'user_sign_up',
|
|
@@ -91,7 +91,7 @@ export default function (request) {
|
|
|
91
91
|
services: {
|
|
92
92
|
signUp: async (context, event) => {
|
|
93
93
|
const { email, password, channel, subchannel } = context
|
|
94
|
-
const dt = await getDeviceToken(fpToken)
|
|
94
|
+
const dt = await getDeviceToken({ fpToken, sentry })
|
|
95
95
|
return await request.send(auth.register({ provider: 'email', email, password, channel, subchannel, dt }))
|
|
96
96
|
},
|
|
97
97
|
},
|
|
@@ -4,11 +4,6 @@ import payment from '../api/payment'
|
|
|
4
4
|
import common from '../api/common'
|
|
5
5
|
import user from '../api/user'
|
|
6
6
|
|
|
7
|
-
// todo - noBind -> unbound
|
|
8
|
-
// todo - withdrawLimit, targetWithdrawLimit 轉為正數
|
|
9
|
-
// todo - mod -> mode
|
|
10
|
-
// todo - adjust updateWithdrawCondition
|
|
11
|
-
|
|
12
7
|
export default function (request) {
|
|
13
8
|
const { appSecret } = request.config
|
|
14
9
|
return createMachine(
|
|
@@ -44,7 +39,7 @@ export default function (request) {
|
|
|
44
39
|
src: 'fetchInitData',
|
|
45
40
|
onDone: {
|
|
46
41
|
target: 'mode',
|
|
47
|
-
actions: ['
|
|
42
|
+
actions: ['setInitData', 'preset'],
|
|
48
43
|
},
|
|
49
44
|
onError: {
|
|
50
45
|
target: 'fail',
|
|
@@ -185,16 +180,6 @@ export default function (request) {
|
|
|
185
180
|
paymentDetail: event.data.paymentDetail,
|
|
186
181
|
}
|
|
187
182
|
}),
|
|
188
|
-
setUserInfo: assign((context, event) => {
|
|
189
|
-
return {
|
|
190
|
-
userInfo: event.data.userInfo,
|
|
191
|
-
}
|
|
192
|
-
}),
|
|
193
|
-
setSiteConfig: assign((context, event) => {
|
|
194
|
-
return {
|
|
195
|
-
siteConfig: event.data.siteConfig,
|
|
196
|
-
}
|
|
197
|
-
}),
|
|
198
183
|
preset: assign((context, event) => {
|
|
199
184
|
const { userInfo, siteConfig } = event.data
|
|
200
185
|
const { withdraw_limit, target_withdraw_limit } = userInfo || {}
|
|
@@ -205,6 +190,8 @@ export default function (request) {
|
|
|
205
190
|
targetWithdrawLimit: Math.abs(target_withdraw_limit),
|
|
206
191
|
methods,
|
|
207
192
|
balance,
|
|
193
|
+
siteConfig,
|
|
194
|
+
userInfo,
|
|
208
195
|
}
|
|
209
196
|
}),
|
|
210
197
|
updateWithdrawCondition: assign((context, event) => {
|
|
@@ -252,7 +239,7 @@ export default function (request) {
|
|
|
252
239
|
},
|
|
253
240
|
isSubmittable: (context, event) => {
|
|
254
241
|
const { applyerBankCode, applyerAccountNumber, branch, holderName, amount } = event.data
|
|
255
|
-
return applyerBankCode
|
|
242
|
+
return applyerBankCode && applyerAccountNumber && branch && holderName && amount
|
|
256
243
|
},
|
|
257
244
|
isConvertible: (context, event) => {
|
|
258
245
|
const { balance, withdrawLimit } = context
|
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, fpToken }) {
|
|
4
|
+
constructor({ apiURL, apiVersion, clientId, appSecret, platform, version, fpToken, sentry }) {
|
|
5
5
|
this.apiURL = apiURL
|
|
6
6
|
this.apiVersion = apiVersion
|
|
7
7
|
this.clientId = clientId
|
|
@@ -10,6 +10,7 @@ export default class Config {
|
|
|
10
10
|
this.version = version
|
|
11
11
|
this.fullURL = urljoin(this.apiURL, this.apiVersion, this.clientId)
|
|
12
12
|
this.fpToken = fpToken // fingerprintjs token
|
|
13
|
+
this.sentry = sentry
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
setApiURL(url) {
|
package/src/util/deviceToken.js
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import FingerprintJS from '@fingerprintjs/fingerprintjs-pro'
|
|
2
2
|
|
|
3
|
-
const getDeviceToken = async (fpToken) => {
|
|
3
|
+
const getDeviceToken = async ({ fpToken, sentry }) => {
|
|
4
4
|
let dt
|
|
5
5
|
try {
|
|
6
6
|
const fp = await FingerprintJS.load({ token: fpToken })
|
|
7
7
|
const result = await fp.get()
|
|
8
8
|
dt = result.visitorId
|
|
9
|
+
|
|
10
|
+
if (!dt) {
|
|
11
|
+
throw new Error('[Device Token] No token from FingerprintJS.')
|
|
12
|
+
}
|
|
13
|
+
|
|
9
14
|
console.log('[Device Token]', dt)
|
|
10
15
|
} catch (error) {
|
|
16
|
+
sentry?.captureException(error)
|
|
11
17
|
console.log(error)
|
|
18
|
+
} finally {
|
|
19
|
+
return dt
|
|
12
20
|
}
|
|
13
|
-
return dt
|
|
14
21
|
}
|
|
15
22
|
|
|
16
23
|
export { getDeviceToken }
|