@jetthai/cuora 1.0.90 → 1.0.92

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 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.92](https://github.com/jetthai/cuora-module/compare/v1.0.91...v1.0.92) (2022-02-17)
6
+
7
+ ### [1.0.91](https://github.com/jetthai/cuora-module/compare/v1.0.90...v1.0.91) (2022-02-14)
8
+
5
9
  ### [1.0.90](https://github.com/jetthai/cuora-module/compare/v1.0.89...v1.0.90) (2022-02-14)
6
10
 
7
11
  ### [1.0.89](https://github.com/jetthai/cuora-module/compare/v1.0.88...v1.0.89) (2022-02-14)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.0.90",
3
+ "version": "1.0.92",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -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 endpoint = request.config.apiURL.replace('fnapi', 'fp')
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 endpoint = request.config.apiURL.replace('fnapi', 'fp')
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
@@ -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 endpoint = request.config.apiURL.replace('fnapi', 'fp')
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
  },
@@ -1,8 +1,11 @@
1
1
  import FingerprintJS from '@fingerprintjs/fingerprintjs-pro'
2
+ const reg = /fnapi\d*/
3
+ // const reg = /(?<=https:\/\/)\w+(?=(\.\w+\.\w+))/
2
4
 
3
- const getDeviceToken = async ({ fpToken, sentry, endpoint }) => {
4
- let dt
5
+ const getDeviceToken = async ({ fpToken, sentry, apiURL }) => {
6
+ let dt, endpoint
5
7
  try {
8
+ endpoint = apiURL.replace(reg, 'fp')
6
9
  const fp = await FingerprintJS.load({ token: fpToken, endpoint })
7
10
  const result = await fp.get()
8
11
  dt = result.visitorId