@evergis/api 4.1.9 → 4.1.11

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/dist/index.js CHANGED
@@ -790,6 +790,17 @@ class EventEmitter {
790
790
  }
791
791
  }
792
792
 
793
+ const getUserInfo = () => JSON.parse(localStorage.getItem(API_USER_INFO_KEY) || "null") || void 0;
794
+ const updateUserInfo = (newUserInfo) => {
795
+ if (newUserInfo) {
796
+ const oldUserInfo = getUserInfo();
797
+ localStorage.setItem(API_USER_INFO_KEY, JSON.stringify({ ...oldUserInfo, ...newUserInfo }));
798
+ }
799
+ else {
800
+ localStorage.removeItem(API_USER_INFO_KEY);
801
+ }
802
+ };
803
+
793
804
  /* eslint-disable */
794
805
  /* tslint:disable */
795
806
  /*
@@ -1397,19 +1408,24 @@ class AccountService extends Service {
1397
1408
  }
1398
1409
  }
1399
1410
 
1400
- const getUserInfo = () => JSON.parse(localStorage.getItem(API_USER_INFO_KEY) || "null") || void 0;
1401
- const updateUserInfo = (newUserInfo) => {
1402
- if (newUserInfo) {
1403
- const oldUserInfo = getUserInfo();
1404
- localStorage.setItem(API_USER_INFO_KEY, JSON.stringify({ ...oldUserInfo, ...newUserInfo }));
1405
- }
1406
- else {
1407
- localStorage.removeItem(API_USER_INFO_KEY);
1408
- }
1409
- };
1410
-
1411
1411
  class Account extends AccountService {
1412
1412
  userInfo;
1413
+ get username() {
1414
+ return this.userInfo?.username || "";
1415
+ }
1416
+ get isAuth() {
1417
+ return !!this.userInfo?.username && this.userInfo.username !== "public";
1418
+ }
1419
+ get user() {
1420
+ if (this.userInfo) {
1421
+ return this.userInfo;
1422
+ }
1423
+ const userInfo = getUserInfo();
1424
+ if (userInfo) {
1425
+ this.userInfo = userInfo;
1426
+ }
1427
+ return userInfo;
1428
+ }
1413
1429
  async login(params, authParams = {}, useJwt = false) {
1414
1430
  if (params) {
1415
1431
  const response = await super.authenticate(authParams, params);
@@ -1423,9 +1439,6 @@ class Account extends AccountService {
1423
1439
  this.userInfo = await this.getUserInfo();
1424
1440
  return this.userInfo;
1425
1441
  }
1426
- get username() {
1427
- return this.userInfo?.username || "";
1428
- }
1429
1442
  async logout() {
1430
1443
  const token = window.localStorage.getItem(STORAGE_TOKEN_KEY);
1431
1444
  if (token) {
@@ -1446,19 +1459,6 @@ class Account extends AccountService {
1446
1459
  setPassword(password) {
1447
1460
  return this.setUserPassword({ username: this.username, password });
1448
1461
  }
1449
- get isAuth() {
1450
- return !!this.userInfo?.username && this.userInfo.username !== "public";
1451
- }
1452
- get user() {
1453
- if (this.userInfo) {
1454
- return this.userInfo;
1455
- }
1456
- const userInfo = getUserInfo();
1457
- if (userInfo) {
1458
- this.userInfo = userInfo;
1459
- }
1460
- return userInfo;
1461
- }
1462
1462
  }
1463
1463
 
1464
1464
  /* eslint-disable */