@jetthai/cuora 1.1.320 → 1.1.321-tg

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.1.321-tg](https://github.com/jetthai/cuora-module/compare/v1.1.321...v1.1.321-tg) (2024-12-02)
6
+
7
+ ### [1.1.321](https://github.com/jetthai/cuora-module/compare/v1.1.320...v1.1.321) (2024-12-02)
8
+
5
9
  ### [1.1.320](https://github.com/jetthai/cuora-module/compare/v1.1.319...v1.1.320) (2024-11-26)
6
10
 
7
11
  ### [1.1.319](https://github.com/jetthai/cuora-module/compare/v1.1.318...v1.1.319) (2024-11-26)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.320",
3
+ "version": "1.1.321-tg",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
package/src/api/auth.js CHANGED
@@ -5,10 +5,10 @@ export default {
5
5
  method: 'post',
6
6
  isPublic: true,
7
7
  }),
8
- login: ({ username, password, provider, countryCode, phone, email, dt, reCaptchaToken }) => ({
8
+ login: ({ username, password, provider, countryCode, phone, email, dt, reCaptchaToken, additionalUserInfo, loginType, isSignature }) => ({
9
9
  url: 'login',
10
10
  method: 'post',
11
- params: { username, password, provider, countryCode, phone, email, dt },
11
+ params: { username, password, provider, countryCode, phone, email, dt, additionalUserInfo, loginType, isSignature },
12
12
  isPublic: true,
13
13
  headers: { 'x-access-captcha': reCaptchaToken },
14
14
  }),
package/src/api/common.js CHANGED
@@ -5,4 +5,5 @@ export default {
5
5
  broadcast: () => ({ url: 'broadcast', method: 'get', isPublic: true }),
6
6
  getAnnouncements: ({ appSecret }) => ({ url: 'getAnnouncements', params: { appSecret }, method: 'get', isPublic: true }),
7
7
  getNavbar: ({ appSecret } = {}) => ({ url: 'getNavbarSetting', params: { appSecret }, method: 'get', isPublic: true }),
8
+ getDefaultAffiliateCode: ({ appSecret }) => ({ url: 'getAffiliateCode', params: { appSecret }, method: 'get', isPublic: true }),
8
9
  }
@@ -33,6 +33,7 @@ export default function (request) {
33
33
  email: null,
34
34
  username: null,
35
35
  password: null,
36
+ additionalUserInfo: null,
36
37
  },
37
38
  countryAbbr: null,
38
39
  userInfo: {},
@@ -271,6 +272,10 @@ export default function (request) {
271
272
  LOGIN_APP: {
272
273
  target: '.authenticationApp',
273
274
  },
275
+ LOGIN_TELEGRAM: {
276
+ target: '.authentication',
277
+ actions: 'setLoginTelegram',
278
+ },
274
279
  SET_PLAY: {
275
280
  actions: 'setPlay',
276
281
  },
@@ -353,6 +358,17 @@ export default function (request) {
353
358
  },
354
359
  }
355
360
  }),
361
+ setLoginTelegram: assign((context, event) => {
362
+ const { loginType, additionalUserInfo, isSignature } = event.data
363
+ return {
364
+ loginData: {
365
+ provider: 'telegram',
366
+ loginType,
367
+ additionalUserInfo,
368
+ isSignature,
369
+ },
370
+ }
371
+ }),
356
372
  fetchToken: assign((context, event) => {
357
373
  const token = storage.get(tokenKey)
358
374
  return {
@@ -4,9 +4,6 @@ import pickBy from 'lodash/pickBy.js'
4
4
  import api from '../api/common.js'
5
5
  import storage from '../util/storage.js'
6
6
 
7
- // const pickBy = require('lodash/pickBy')
8
- // const UAParser = require('ua-parser-js')
9
-
10
7
  export default function (request) {
11
8
  const { appSecret, defaultChannel, defaultSubchannel } = request.config
12
9
  return createMachine(
@@ -41,6 +38,7 @@ export default function (request) {
41
38
  channel: null,
42
39
  subchannel: null,
43
40
  affiliateCode: null,
41
+ defaultAffiliateCode: null,
44
42
  friendCode: null,
45
43
  },
46
44
  states: {
@@ -58,9 +56,28 @@ export default function (request) {
58
56
  entry: ['setUA', 'setAgent', 'setPixel', 'setKPixel'],
59
57
  invoke: {
60
58
  src: 'fetchConfig',
59
+ onDone: [
60
+ {
61
+ target: 'getDefaultAffiliateCode',
62
+ actions: 'setConfig',
63
+ cond: 'isAffiliateCodeInstructionsEnable',
64
+ },
65
+ {
66
+ target: 'idle',
67
+ actions: 'setConfig',
68
+ },
69
+ ],
70
+ onError: {
71
+ target: 'idle',
72
+ },
73
+ },
74
+ },
75
+ getDefaultAffiliateCode: {
76
+ invoke: {
77
+ src: 'fetchDefaultAffiliateCode',
61
78
  onDone: {
62
79
  target: 'idle',
63
- actions: 'setConfig',
80
+ actions: 'setDefaultAffiliateCode',
64
81
  },
65
82
  onError: {
66
83
  target: 'idle',
@@ -183,6 +200,12 @@ export default function (request) {
183
200
  layoutConfig: layoutConfigDecoded,
184
201
  }
185
202
  }),
203
+ setDefaultAffiliateCode: assign((context, event) => {
204
+ const { affiliateCode } = event.data
205
+ return {
206
+ defaultAffiliateCode: affiliateCode,
207
+ }
208
+ }),
186
209
  setUA: assign((context, event) => {
187
210
  const parser = new UAParser()
188
211
  const userAgent = parser.getResult()
@@ -283,6 +306,12 @@ export default function (request) {
283
306
  }
284
307
  }),
285
308
  },
309
+ guards: {
310
+ isAffiliateCodeInstructionsEnable: (context, event) => {
311
+ const { siteConfig } = event.data
312
+ return siteConfig?.registerBindingAffiliateCodeInstructionsEnable
313
+ },
314
+ },
286
315
  services: {
287
316
  fetchConfig: async (context, event) => {
288
317
  const [site, layout] = await Promise.all([request.send(api.getConfig({ appSecret })), request.send(api.getLayoutConfig({ appSecret }))])
@@ -299,6 +328,9 @@ export default function (request) {
299
328
  )
300
329
  return { siteConfig: JSON.parse(decodeResult), layoutConfig: layout.config }
301
330
  },
331
+ fetchDefaultAffiliateCode: async (context, event) => {
332
+ return await request.send(api.getDefaultAffiliateCode({ appSecret }))
333
+ },
302
334
  fetchFeeds: async (context, event) => {
303
335
  return await request.send(api.feeds({ appSecret }))
304
336
  },
@@ -110,7 +110,6 @@ export default class Request {
110
110
 
111
111
  _checkToken(req) {
112
112
  if (!req.isPublic && !this.getToken()) {
113
- console.error(req)
114
113
  throw { code: 'ERR_A103', url: req.url }
115
114
  }
116
115
  }
@@ -23,7 +23,6 @@ const getDeviceToken = async ({ fpToken, sentry, hosts, enable = true }) => {
23
23
  throw new Error('[Device Token] No token from FingerprintJS.')
24
24
  }
25
25
 
26
- console.log('[Device Token]', `${dt} from ${endpoints}`)
27
26
  sentry?.setTag('dt', dt)
28
27
  } catch (error) {
29
28
  console.error('[Device Token]', `${dt} from ${endpoints}`, error)