@jetthai/cuora 1.0.83 → 1.0.84

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,8 @@
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.84](https://github.com/jetthai/cuora-module/compare/v1.0.83...v1.0.84) (2022-01-20)
6
+
5
7
  ### [1.0.83](https://github.com/jetthai/cuora-module/compare/v1.0.82...v1.0.83) (2022-01-18)
6
8
 
7
9
  ### [1.0.82](https://github.com/jetthai/cuora-module/compare/v1.0.81...v1.0.82) (2022-01-18)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.0.83",
3
+ "version": "1.0.84",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -1,6 +1,9 @@
1
1
  import urljoin from 'url-join'
2
2
  import Cookies from 'universal-cookie'
3
3
  import qs from 'qs'
4
+ import omitBy from 'lodash/omitBy'
5
+ import isNull from 'lodash/isNull'
6
+ import isUndefined from 'lodash/isUndefined'
4
7
  import { assign, createMachine, send } from 'xstate'
5
8
  import auth from '../api/auth'
6
9
  import user from '../api/user'
@@ -246,16 +249,19 @@ export default function (request) {
246
249
  return { token }
247
250
  }),
248
251
  redirectTo3Party: async (context, event) => {
249
- const { provider, channel = 'official', subchannel = 'pwa' } = event.data
252
+ const { provider, channel, subchannel } = event.data
250
253
  const dt = await getDeviceToken(fpToken)
254
+ const redirectParams = omitBy(omitBy({ channel, subchannel }, isUndefined), isNull)
255
+ const query = new URLSearchParams(redirectParams).toString()
256
+ const redirectURI = urljoin(`${window.location.protocol}//${window.location.host}`, query ? `?${query}` : '')
251
257
  const redirectURL = urljoin(
252
258
  request.config.fullURL,
253
259
  'login?' +
254
260
  qs.stringify({
255
261
  provider,
256
- redirectURI: `${window.location.protocol}//${window.location.host}`,
257
- channel,
258
- subchannel,
262
+ redirectURI,
263
+ channel: channel || 'official',
264
+ subchannel: subchannel || 'pwa',
259
265
  dt,
260
266
  platform: 'pwa',
261
267
  })