@jetthai/cuora 1.1.107 → 1.1.108
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 +2 -0
- package/package.json +1 -1
- package/src/machine/auth.js +28 -6
- package/src/machine/user_sign_up.js +13 -2
- package/src/util/deviceToken.js +6 -4
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.1.108](https://github.com/jetthai/cuora-module/compare/v1.1.107...v1.1.108) (2023-05-30)
|
|
6
|
+
|
|
5
7
|
### [1.1.107](https://github.com/jetthai/cuora-module/compare/v1.1.106...v1.1.107) (2023-05-30)
|
|
6
8
|
|
|
7
9
|
### [1.1.106](https://github.com/jetthai/cuora-module/compare/v1.1.105...v1.1.106) (2023-05-29)
|
package/package.json
CHANGED
package/src/machine/auth.js
CHANGED
|
@@ -5,8 +5,6 @@ import user from '../api/user.js'
|
|
|
5
5
|
import storage from '../util/storage.js'
|
|
6
6
|
import { getDeviceToken } from '../util/deviceToken.js'
|
|
7
7
|
|
|
8
|
-
// const urljoin = require('url-join')
|
|
9
|
-
|
|
10
8
|
export default function (request) {
|
|
11
9
|
const { clientId, fpToken, sentry, defaultChannel, defaultSubchannel } = request.config
|
|
12
10
|
const tokenKey = `cuora_${clientId}`
|
|
@@ -37,6 +35,7 @@ export default function (request) {
|
|
|
37
35
|
redirectURL: null,
|
|
38
36
|
reCaptchaToken: null,
|
|
39
37
|
fc: null,
|
|
38
|
+
deviceTokenEnable: true,
|
|
40
39
|
},
|
|
41
40
|
states: {
|
|
42
41
|
idle: {
|
|
@@ -120,8 +119,12 @@ export default function (request) {
|
|
|
120
119
|
},
|
|
121
120
|
},
|
|
122
121
|
inlineFinish: {
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
invoke: {
|
|
123
|
+
src: 'checkDeviceToken',
|
|
124
|
+
onDone: {
|
|
125
|
+
target: 'login',
|
|
126
|
+
},
|
|
127
|
+
onError: {
|
|
125
128
|
target: 'login',
|
|
126
129
|
},
|
|
127
130
|
},
|
|
@@ -207,6 +210,9 @@ export default function (request) {
|
|
|
207
210
|
SET_PLAY: {
|
|
208
211
|
actions: 'setPlay',
|
|
209
212
|
},
|
|
213
|
+
SET_DEVICE_TOKEN_ENABLE: {
|
|
214
|
+
actions: 'setDeviceTokenEnable',
|
|
215
|
+
},
|
|
210
216
|
},
|
|
211
217
|
},
|
|
212
218
|
{
|
|
@@ -322,11 +328,13 @@ export default function (request) {
|
|
|
322
328
|
}),
|
|
323
329
|
redirectTo3Party: async (context, event) => {
|
|
324
330
|
const { provider, channel, subchannel, fc } = event.data
|
|
331
|
+
const { deviceTokenEnable } = context
|
|
325
332
|
|
|
326
|
-
|
|
333
|
+
await getDeviceToken({
|
|
327
334
|
fpToken,
|
|
328
335
|
sentry,
|
|
329
336
|
hosts: request.hosts,
|
|
337
|
+
enable: deviceTokenEnable,
|
|
330
338
|
})
|
|
331
339
|
|
|
332
340
|
const affiliateCode = storage.get('ac')
|
|
@@ -356,7 +364,6 @@ export default function (request) {
|
|
|
356
364
|
provider,
|
|
357
365
|
redirectURI: `${window.location.protocol}//${window.location.host}${context.base}`,
|
|
358
366
|
...referralObj,
|
|
359
|
-
// dt,
|
|
360
367
|
platform: 'pwa',
|
|
361
368
|
fc,
|
|
362
369
|
}).toString()
|
|
@@ -375,6 +382,11 @@ export default function (request) {
|
|
|
375
382
|
isPlaying: event.data,
|
|
376
383
|
}
|
|
377
384
|
}),
|
|
385
|
+
setDeviceTokenEnable: assign((context, event) => {
|
|
386
|
+
return {
|
|
387
|
+
deviceTokenEnable: event.data,
|
|
388
|
+
}
|
|
389
|
+
}),
|
|
378
390
|
},
|
|
379
391
|
services: {
|
|
380
392
|
authenticateApp: async (context, event) => {
|
|
@@ -396,6 +408,16 @@ export default function (request) {
|
|
|
396
408
|
fetchUserInfo: async (context, event) => {
|
|
397
409
|
return await request.send(user.getUserInfo())
|
|
398
410
|
},
|
|
411
|
+
checkDeviceToken: async (context, event) => {
|
|
412
|
+
const { deviceTokenEnable } = context
|
|
413
|
+
if (deviceTokenEnable) {
|
|
414
|
+
const { exist } = await request.send(user.checkDt())
|
|
415
|
+
if (!exist) {
|
|
416
|
+
const dt = await getDeviceToken({ fpToken, sentry, hosts: request.hosts, enable: deviceTokenEnable })
|
|
417
|
+
await request.send(user.updateDt({ dt }))
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
},
|
|
399
421
|
},
|
|
400
422
|
}
|
|
401
423
|
)
|
|
@@ -23,6 +23,7 @@ export default function (request) {
|
|
|
23
23
|
strategy: null,
|
|
24
24
|
uid: null,
|
|
25
25
|
},
|
|
26
|
+
deviceTokenEnable: true,
|
|
26
27
|
},
|
|
27
28
|
states: {
|
|
28
29
|
idle: {
|
|
@@ -51,6 +52,11 @@ export default function (request) {
|
|
|
51
52
|
},
|
|
52
53
|
authenticated: {},
|
|
53
54
|
},
|
|
55
|
+
on: {
|
|
56
|
+
SET_DEVICE_TOKEN_ENABLE: {
|
|
57
|
+
actions: 'setDeviceTokenEnable',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
54
60
|
},
|
|
55
61
|
{
|
|
56
62
|
actions: {
|
|
@@ -105,11 +111,16 @@ export default function (request) {
|
|
|
105
111
|
},
|
|
106
112
|
}
|
|
107
113
|
}),
|
|
114
|
+
setDeviceTokenEnable: assign((context, event) => {
|
|
115
|
+
return {
|
|
116
|
+
deviceTokenEnable: event.data,
|
|
117
|
+
}
|
|
118
|
+
}),
|
|
108
119
|
},
|
|
109
120
|
services: {
|
|
110
121
|
authenticate: async (context, event) => {
|
|
111
|
-
const { channel, subchannel, signUpData } = context
|
|
112
|
-
const dt = await getDeviceToken({ fpToken, sentry, hosts: request.hosts })
|
|
122
|
+
const { channel, subchannel, signUpData, deviceTokenEnable } = context
|
|
123
|
+
const dt = await getDeviceToken({ fpToken, sentry, hosts: request.hosts, enable: deviceTokenEnable })
|
|
113
124
|
|
|
114
125
|
const affiliateCode = storage.get('ac')
|
|
115
126
|
const messages = {
|
package/src/util/deviceToken.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
// import FingerprintJS from '@fingerprintjs/fingerprintjs-pro'
|
|
2
1
|
import uniqBy from 'lodash/uniqBy'
|
|
3
2
|
import { load } from '../lib/fingerprint.js'
|
|
4
3
|
|
|
5
4
|
const reg = /fnapi\d*/
|
|
6
|
-
// const reg = /(?<=https:\/\/)\w+(?=(\.\w+\.\w+))/
|
|
7
5
|
|
|
8
|
-
const getDeviceToken = async ({ fpToken, sentry, hosts }) => {
|
|
6
|
+
const getDeviceToken = async ({ fpToken, sentry, hosts, enable = true }) => {
|
|
7
|
+
if (!enable) {
|
|
8
|
+
return
|
|
9
|
+
}
|
|
10
|
+
|
|
9
11
|
let dt, endpoints
|
|
10
12
|
try {
|
|
11
13
|
endpoints = uniqBy(
|
|
12
14
|
hosts.map((host) => host.replace(reg, 'fp')),
|
|
13
15
|
(url) => url
|
|
14
16
|
)
|
|
15
|
-
|
|
17
|
+
|
|
16
18
|
const fp = await load({ endpoint: endpoints })
|
|
17
19
|
const result = await fp.get({ timeout: 30000 })
|
|
18
20
|
dt = result.visitorId
|