@jetthai/cuora 1.1.109 → 1.1.110
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 +43 -20
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.110](https://github.com/jetthai/cuora-module/compare/v1.1.109...v1.1.110) (2023-05-30)
|
|
6
|
+
|
|
5
7
|
### [1.1.109](https://github.com/jetthai/cuora-module/compare/v1.1.108...v1.1.109) (2023-05-30)
|
|
6
8
|
|
|
7
9
|
### [1.1.108](https://github.com/jetthai/cuora-module/compare/v1.1.107...v1.1.108) (2023-05-30)
|
package/package.json
CHANGED
package/src/machine/auth.js
CHANGED
|
@@ -4,9 +4,11 @@ import auth from '../api/auth.js'
|
|
|
4
4
|
import user from '../api/user.js'
|
|
5
5
|
import storage from '../util/storage.js'
|
|
6
6
|
import { getDeviceToken } from '../util/deviceToken.js'
|
|
7
|
+
import common from '../api/common.js'
|
|
8
|
+
import pickBy from 'lodash/pickBy.js'
|
|
7
9
|
|
|
8
10
|
export default function (request) {
|
|
9
|
-
const { clientId, fpToken, sentry, defaultChannel, defaultSubchannel } = request.config
|
|
11
|
+
const { appSecret, clientId, fpToken, sentry, defaultChannel, defaultSubchannel } = request.config
|
|
10
12
|
const tokenKey = `cuora_${clientId}`
|
|
11
13
|
const userKey = `cuora_tempuser`
|
|
12
14
|
const phoneCountryCode = 'phone_countrycode'
|
|
@@ -16,11 +18,12 @@ export default function (request) {
|
|
|
16
18
|
return createMachine(
|
|
17
19
|
{
|
|
18
20
|
id: 'auth',
|
|
19
|
-
initial: '
|
|
21
|
+
initial: 'fetchingConfig',
|
|
20
22
|
context: {
|
|
21
23
|
base: '',
|
|
22
24
|
token: null,
|
|
23
25
|
tick: 2000,
|
|
26
|
+
siteConfig: {},
|
|
24
27
|
isPlaying: false,
|
|
25
28
|
loginData: {
|
|
26
29
|
provider: '',
|
|
@@ -35,9 +38,20 @@ export default function (request) {
|
|
|
35
38
|
redirectURL: null,
|
|
36
39
|
reCaptchaToken: null,
|
|
37
40
|
fc: null,
|
|
38
|
-
deviceTokenEnable: true,
|
|
39
41
|
},
|
|
40
42
|
states: {
|
|
43
|
+
fetchingConfig: {
|
|
44
|
+
invoke: {
|
|
45
|
+
src: 'fetchSiteConfig',
|
|
46
|
+
onDone: {
|
|
47
|
+
target: 'idle',
|
|
48
|
+
actions: 'setSiteConfig',
|
|
49
|
+
},
|
|
50
|
+
onError: {
|
|
51
|
+
target: 'idle',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
41
55
|
idle: {
|
|
42
56
|
entry: 'fetchToken',
|
|
43
57
|
always: [{ target: 'authenticated', cond: 'hasToken' }],
|
|
@@ -119,19 +133,26 @@ export default function (request) {
|
|
|
119
133
|
},
|
|
120
134
|
},
|
|
121
135
|
inlineFinish: {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
onDone: {
|
|
125
|
-
target: 'login',
|
|
126
|
-
},
|
|
127
|
-
onError: {
|
|
136
|
+
after: {
|
|
137
|
+
0: {
|
|
128
138
|
target: 'login',
|
|
129
139
|
},
|
|
130
140
|
},
|
|
131
141
|
},
|
|
132
142
|
login: {
|
|
133
|
-
initial: '
|
|
143
|
+
initial: 'deviceTokenChecking',
|
|
134
144
|
states: {
|
|
145
|
+
deviceTokenChecking: {
|
|
146
|
+
invoke: {
|
|
147
|
+
src: 'checkDeviceToken',
|
|
148
|
+
onDone: {
|
|
149
|
+
target: 'fetching',
|
|
150
|
+
},
|
|
151
|
+
onError: {
|
|
152
|
+
target: 'fetching',
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
},
|
|
135
156
|
fetching: {
|
|
136
157
|
invoke: {
|
|
137
158
|
src: 'fetchUserInfo',
|
|
@@ -210,9 +231,6 @@ export default function (request) {
|
|
|
210
231
|
SET_PLAY: {
|
|
211
232
|
actions: 'setPlay',
|
|
212
233
|
},
|
|
213
|
-
SET_DEVICE_TOKEN_ENABLE: {
|
|
214
|
-
actions: 'setDeviceTokenEnable',
|
|
215
|
-
},
|
|
216
234
|
},
|
|
217
235
|
},
|
|
218
236
|
{
|
|
@@ -234,6 +252,12 @@ export default function (request) {
|
|
|
234
252
|
},
|
|
235
253
|
},
|
|
236
254
|
actions: {
|
|
255
|
+
setSiteConfig: assign((context, event) => {
|
|
256
|
+
const { loginMethods = {}, registerMethods = {} } = event.data
|
|
257
|
+
return {
|
|
258
|
+
siteConfig: { ...event.data, loginMethods: pickBy(loginMethods), registerMethods: pickBy(registerMethods) },
|
|
259
|
+
}
|
|
260
|
+
}),
|
|
237
261
|
setReCaptchaToken: assign((context, event) => {
|
|
238
262
|
const { reCaptchaToken } = event.data
|
|
239
263
|
return {
|
|
@@ -328,7 +352,7 @@ export default function (request) {
|
|
|
328
352
|
}),
|
|
329
353
|
redirectTo3Party: async (context, event) => {
|
|
330
354
|
const { provider, channel, subchannel, fc } = event.data
|
|
331
|
-
const
|
|
355
|
+
const deviceTokenEnable = context.siteConfig?.dtVerify === '1'
|
|
332
356
|
|
|
333
357
|
await getDeviceToken({
|
|
334
358
|
fpToken,
|
|
@@ -382,11 +406,6 @@ export default function (request) {
|
|
|
382
406
|
isPlaying: event.data,
|
|
383
407
|
}
|
|
384
408
|
}),
|
|
385
|
-
setDeviceTokenEnable: assign((context, event) => {
|
|
386
|
-
return {
|
|
387
|
-
deviceTokenEnable: event.data,
|
|
388
|
-
}
|
|
389
|
-
}),
|
|
390
409
|
},
|
|
391
410
|
services: {
|
|
392
411
|
authenticateApp: async (context, event) => {
|
|
@@ -409,7 +428,7 @@ export default function (request) {
|
|
|
409
428
|
return await request.send(user.getUserInfo())
|
|
410
429
|
},
|
|
411
430
|
checkDeviceToken: async (context, event) => {
|
|
412
|
-
const
|
|
431
|
+
const deviceTokenEnable = context.siteConfig?.dtVerify === '1'
|
|
413
432
|
if (deviceTokenEnable) {
|
|
414
433
|
const { exist } = await request.send(user.checkDt())
|
|
415
434
|
if (!exist) {
|
|
@@ -418,6 +437,10 @@ export default function (request) {
|
|
|
418
437
|
}
|
|
419
438
|
}
|
|
420
439
|
},
|
|
440
|
+
fetchSiteConfig: async (context, event) => {
|
|
441
|
+
const { config } = await request.send(common.getConfig({ appSecret }))
|
|
442
|
+
return JSON.parse(window.atob(config))
|
|
443
|
+
},
|
|
421
444
|
},
|
|
422
445
|
}
|
|
423
446
|
)
|