@jetthai/cuora 1.0.140-2 → 1.0.141-1

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,7 +2,15 @@
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.140-2](https://github.com/jetthai/cuora-module/compare/v1.0.140...v1.0.140-2) (2022-07-17)
5
+ ### [1.0.141-1](https://github.com/jetthai/cuora-module/compare/v1.0.140-2...v1.0.141-1) (2022-07-17)
6
+
7
+ ### [1.0.141](https://github.com/jetthai/cuora-module/compare/v1.0.140-1...v1.0.141) (2022-07-05)
8
+
9
+ ### [1.0.140-1](https://github.com/jetthai/cuora-module/compare/v1.0.140...v1.0.140-1) (2022-07-04)
10
+
11
+ ### [1.0.141](https://github.com/jetthai/cuora-module/compare/v1.0.140-1...v1.0.141) (2022-07-05)
12
+
13
+ ### [1.0.140-1](https://github.com/jetthai/cuora-module/compare/v1.0.140...v1.0.140-1) (2022-07-04)
6
14
 
7
15
  ### [1.0.140](https://github.com/jetthai/cuora-module/compare/v1.0.139...v1.0.140) (2022-06-27)
8
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.0.140-2",
3
+ "version": "1.0.141-1",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
package/src/api/auth.js CHANGED
@@ -4,17 +4,19 @@ export default {
4
4
  method: 'post',
5
5
  isPublic: true,
6
6
  }),
7
- login: ({ username, password, provider, countryCode, phone, email, dt }) => ({
7
+ login: ({ username, password, provider, countryCode, phone, email, dt, reCaptchaToken }) => ({
8
8
  url: 'login',
9
9
  method: 'post',
10
10
  params: { username, password, provider, countryCode, phone, email, dt },
11
11
  isPublic: true,
12
+ headers: { 'x-access-captcha': reCaptchaToken },
12
13
  }),
13
- register: ({ channel = 'official', subchannel = 'pwa', ...rest }) => ({
14
+ register: ({ channel = 'official', subchannel = 'pwa', reCaptchaToken, ...rest }) => ({
14
15
  url: `register?channel=${channel}&subchannel=${subchannel}`,
15
16
  method: 'post',
16
17
  params: rest,
17
18
  isPublic: true,
19
+ headers: { 'x-access-captcha': reCaptchaToken },
18
20
  }),
19
21
  logout: () => ({ url: 'logout', method: 'post' }),
20
22
  }
@@ -4,10 +4,9 @@ import qs from 'qs'
4
4
  import { assign, createMachine } from 'xstate'
5
5
  import auth from '../api/auth'
6
6
  import user from '../api/user'
7
- import { getDeviceToken } from '../util/deviceToken'
8
7
 
9
8
  export default function (request) {
10
- const { clientId, fpToken, sentry } = request.config
9
+ const { clientId, sentry } = request.config
11
10
  const tokenKey = `cuora_${clientId}`
12
11
  const userKey = `cuora_tempuser`
13
12
  const accountPhoneKey = 'account_phone'
@@ -32,6 +31,7 @@ export default function (request) {
32
31
  },
33
32
  userInfo: {},
34
33
  redirectURL: null,
34
+ reCaptchaToken: null,
35
35
  },
36
36
  states: {
37
37
  idle: {
@@ -43,11 +43,11 @@ export default function (request) {
43
43
  },
44
44
  LOGIN_PHONE: {
45
45
  target: 'authentication',
46
- actions: 'setLoginPhone',
46
+ actions: ['setReCaptchaToken', 'setLoginPhone'],
47
47
  },
48
48
  LOGIN_EMAIL: {
49
49
  target: 'authentication',
50
- actions: 'setLoginEmail',
50
+ actions: ['setReCaptchaToken', 'setLoginEmail'],
51
51
  },
52
52
  LOGIN_LOCAL: {
53
53
  target: 'authentication',
@@ -199,6 +199,12 @@ export default function (request) {
199
199
  },
200
200
  },
201
201
  actions: {
202
+ setReCaptchaToken: assign((context, event) => {
203
+ const { reCaptchaToken } = event.data
204
+ return {
205
+ reCaptchaToken,
206
+ }
207
+ }),
202
208
  setLoginPhone: assign((context, event) => {
203
209
  const { countryCode, phone, password } = event.data
204
210
  return {
@@ -279,7 +285,6 @@ export default function (request) {
279
285
  }),
280
286
  redirectTo3Party: async (context, event) => {
281
287
  const { provider, channel, subchannel } = event.data
282
- // const dt = await getDeviceToken({ fpToken, sentry, apiURL: request.config.apiURL })
283
288
  const redirectURL = urljoin(
284
289
  request.config.fullURL,
285
290
  'login?' +
@@ -303,13 +308,11 @@ export default function (request) {
303
308
  },
304
309
  services: {
305
310
  authenticate: async (context, event) => {
306
- // const dt = await getDeviceToken({ fpToken, sentry, apiURL: request.config.apiURL })
307
- const data = { ...context.loginData }
311
+ const data = { ...context.loginData, reCaptchaToken: context.reCaptchaToken }
308
312
  const { token } = await request.send(auth.login(data))
309
313
  return token
310
314
  },
311
315
  authenticateGuest: async (context, event) => {
312
- // const dt = await getDeviceToken({ fpToken, sentry, apiURL: request.config.apiURL })
313
316
  const { token } = await request.send(auth.guestLogin())
314
317
  return token
315
318
  },
@@ -4,15 +4,15 @@ import api from '../api/game'
4
4
  export default function (request) {
5
5
  return createMachine(
6
6
  {
7
- id: 'side_v2',
8
- initial: 'loading',
7
+ id: 'side',
8
+ initial: 'preparing',
9
9
  context: {
10
10
  menu: {},
11
11
  room: null,
12
12
  roomHistory: [],
13
13
  },
14
14
  states: {
15
- loading: {
15
+ preparing: {
16
16
  invoke: {
17
17
  src: 'getRoomItems',
18
18
  onDone: {
@@ -25,32 +25,31 @@ export default function (request) {
25
25
  },
26
26
  },
27
27
  room: {
28
- entry: 'resetRoomHistory',
29
28
  initial: 'home',
30
29
  states: {
31
30
  home: {
32
- entry: assign({ room: (context, event) => context.menu['home'] }),
31
+ entry: createSideAction('home'),
33
32
  },
34
33
  favorite: {
35
- entry: assign({ room: (context, event) => context.menu['favorite'] }),
34
+ entry: createSideAction('favorite'),
36
35
  },
37
36
  hot: {
38
- entry: assign({ room: (context, event) => context.menu['hot'] }),
37
+ entry: createSideAction('hot'),
39
38
  },
40
39
  new: {
41
- entry: assign({ room: (context, event) => context.menu['new'] }),
40
+ entry: createSideAction('new'),
42
41
  },
43
42
  slot: {
44
- entry: assign({ room: (context, event) => context.menu['slot'] }),
43
+ entry: createSideAction('slot'),
45
44
  },
46
45
  fish: {
47
- entry: assign({ room: (context, event) => context.menu['fish'] }),
46
+ entry: createSideAction('fish'),
48
47
  },
49
48
  arcade: {
50
- entry: assign({ room: (context, event) => context.menu['arcade'] }),
49
+ entry: createSideAction('arcade'),
51
50
  },
52
51
  table: {
53
- entry: assign({ room: (context, event) => context.menu['table'] }),
52
+ entry: createSideAction('table'),
54
53
  },
55
54
  search: {},
56
55
  history: {
@@ -98,6 +97,7 @@ export default function (request) {
98
97
  fish: 'SYSTEM_BIG_CATEGORY_FISHING',
99
98
  arcade: 'SYSTEM_BIG_CATEGORY_ARCADE',
100
99
  table: 'SYSTEM_BIG_CATEGORY_TABLECARD',
100
+ limit: 'SYSTEM_ACTIVITY_LIMIT_GAME',
101
101
  }
102
102
  const menu = {}
103
103
  Object.keys(map).forEach((key) => {
@@ -119,16 +119,17 @@ export default function (request) {
119
119
  return { menu }
120
120
  }),
121
121
  forwardRoom: assign((context, event) => {
122
+ const currentRoom = event.data
122
123
  return {
123
- room: event.data,
124
- roomHistory: [...context.roomHistory, context.room],
124
+ room: currentRoom,
125
+ roomHistory: [...context.roomHistory, currentRoom],
125
126
  }
126
127
  }),
127
128
  backwardRoom: assign((context, event) => {
128
- const { roomHistory } = context
129
+ const newRoomHistory = context.roomHistory.slice(0, -1)
129
130
  return {
130
- room: roomHistory.slice(-1)[0],
131
- roomHistory: roomHistory.slice(0, -1),
131
+ room: newRoomHistory.slice(-1)[0],
132
+ roomHistory: newRoomHistory,
132
133
  }
133
134
  }),
134
135
  resetRoomHistory: assign((context, event) => {
@@ -145,3 +146,14 @@ export default function (request) {
145
146
  }
146
147
  )
147
148
  }
149
+
150
+ function createSideAction(name) {
151
+ return assign((context, event) => {
152
+ const { roomHistory } = context
153
+ if (roomHistory.some((history) => history.id === context.menu[name].id)) {
154
+ return { room: roomHistory.slice(-1)[0] }
155
+ } else {
156
+ return { room: context.menu[name], roomHistory: [context.menu[name]] }
157
+ }
158
+ })
159
+ }
@@ -15,17 +15,18 @@ export default function (request) {
15
15
  channel: null,
16
16
  subchannel: null,
17
17
  signUpData: {},
18
+ reCaptchaToken: null,
18
19
  },
19
20
  states: {
20
21
  idle: {
21
22
  on: {
22
23
  SIGN_UP_PHONE: {
23
24
  target: 'authentication',
24
- actions: 'setSignUpPhone',
25
+ actions: ['setReCaptchaToken', 'setSignUpPhone'],
25
26
  },
26
27
  SIGN_UP_EMAIL: {
27
28
  target: 'authentication',
28
- actions: 'setSignUpEmail',
29
+ actions: ['setReCaptchaToken', 'setSignUpEmail'],
29
30
  },
30
31
  },
31
32
  },
@@ -45,6 +46,12 @@ export default function (request) {
45
46
  },
46
47
  {
47
48
  actions: {
49
+ setReCaptchaToken: assign((context, event) => {
50
+ const { reCaptchaToken } = event.data
51
+ return {
52
+ reCaptchaToken,
53
+ }
54
+ }),
48
55
  setSignUpPhone: assign((context, event) => {
49
56
  const { countryCode, phone, password, channel, subchannel } = event.data
50
57
  return {
@@ -82,6 +89,7 @@ export default function (request) {
82
89
  channel: cookies.get('channel') || channel,
83
90
  subchannel: cookies.get('subchannel') || subchannel,
84
91
  dt,
92
+ reCaptchaToken: context.reCaptchaToken,
85
93
  })
86
94
  )
87
95
  },
@@ -70,7 +70,7 @@ export default class Request {
70
70
  }
71
71
 
72
72
  _createConfig(req, cancelToken) {
73
- const { method, url, params, isPublic, isFormData } = req
73
+ const { method, url, params, isPublic, isFormData, headers } = req
74
74
  if (isFormData) {
75
75
  return {
76
76
  baseURL: this.config.fullURL,
@@ -88,6 +88,7 @@ export default class Request {
88
88
  url,
89
89
  cancelToken,
90
90
  isPublic,
91
+ headers,
91
92
  [method.toUpperCase() === 'GET' ? 'params' : 'data']: pickBy(params, isValid),
92
93
  }
93
94
  }