@jetthai/cuora 1.0.89 → 1.0.91
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 +3 -5
- package/src/machine/user_sign_up.js +2 -3
- package/src/util/deviceToken.js +4 -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.91](https://github.com/jetthai/cuora-module/compare/v1.0.90...v1.0.91) (2022-02-14)
|
|
6
|
+
|
|
7
|
+
### [1.0.90](https://github.com/jetthai/cuora-module/compare/v1.0.89...v1.0.90) (2022-02-14)
|
|
8
|
+
|
|
5
9
|
### [1.0.89](https://github.com/jetthai/cuora-module/compare/v1.0.88...v1.0.89) (2022-02-14)
|
|
6
10
|
|
|
7
11
|
### [1.0.88](https://github.com/jetthai/cuora-module/compare/v1.0.87...v1.0.88) (2022-02-10)
|
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 {
|
|
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()
|
|
@@ -251,8 +251,7 @@ export default function (request) {
|
|
|
251
251
|
}),
|
|
252
252
|
redirectTo3Party: async (context, event) => {
|
|
253
253
|
const { provider, channel, subchannel } = event.data
|
|
254
|
-
const
|
|
255
|
-
const dt = await getDeviceToken({ fpToken, sentry, endpoint })
|
|
254
|
+
const dt = await getDeviceToken({ fpToken, sentry, apiURL: request.config.apiURL })
|
|
256
255
|
const redirectParams = omitBy(omitBy({ channel, subchannel }, isUndefined), isNull)
|
|
257
256
|
const query = new URLSearchParams(redirectParams).toString()
|
|
258
257
|
const redirectURI = urljoin(`${window.location.protocol}//${window.location.host}`, query ? `?${query}` : '')
|
|
@@ -278,8 +277,7 @@ export default function (request) {
|
|
|
278
277
|
},
|
|
279
278
|
services: {
|
|
280
279
|
authenticate: async (context, event) => {
|
|
281
|
-
const
|
|
282
|
-
const dt = await getDeviceToken({ fpToken, sentry, endpoint })
|
|
280
|
+
const dt = await getDeviceToken({ fpToken, sentry, apiURL: request.config.apiURL })
|
|
283
281
|
const data = { ...context.loginData, dt }
|
|
284
282
|
const { token } = await request.send(auth.login(data))
|
|
285
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 {
|
|
6
|
+
const { fpToken, sentry } = request.config
|
|
7
7
|
return createMachine(
|
|
8
8
|
{
|
|
9
9
|
id: 'user_sign_up',
|
|
@@ -91,8 +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
|
|
95
|
-
const dt = await getDeviceToken({ fpToken, sentry, endpoint })
|
|
94
|
+
const dt = await getDeviceToken({ fpToken, sentry, apiURL: request.config.apiURL })
|
|
96
95
|
return await request.send(auth.register({ provider: 'email', email, password, channel, subchannel, dt }))
|
|
97
96
|
},
|
|
98
97
|
},
|
package/src/util/deviceToken.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import FingerprintJS from '@fingerprintjs/fingerprintjs-pro'
|
|
2
|
+
const reg = /(?<=https:\/\/)\w+(?=(\.\w+\.\w+))/
|
|
2
3
|
|
|
3
|
-
const getDeviceToken = async ({ fpToken, sentry,
|
|
4
|
-
let dt
|
|
4
|
+
const getDeviceToken = async ({ fpToken, sentry, apiURL }) => {
|
|
5
|
+
let dt, endpoint
|
|
5
6
|
try {
|
|
7
|
+
endpoint = apiURL.replace(reg, 'fp')
|
|
6
8
|
const fp = await FingerprintJS.load({ token: fpToken, endpoint })
|
|
7
9
|
const result = await fp.get()
|
|
8
10
|
dt = result.visitorId
|