@evergis/api 3.0.198 → 3.0.200

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.
@@ -36,9 +36,6 @@ function _defineProperties(target, props) {
36
36
  function _createClass(Constructor, protoProps, staticProps) {
37
37
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
38
38
  if (staticProps) _defineProperties(Constructor, staticProps);
39
- Object.defineProperty(Constructor, "prototype", {
40
- writable: false
41
- });
42
39
  return Constructor;
43
40
  }
44
41
 
@@ -72,9 +69,6 @@ function _inherits(subClass, superClass) {
72
69
  configurable: true
73
70
  }
74
71
  });
75
- Object.defineProperty(subClass, "prototype", {
76
- writable: false
77
- });
78
72
  if (superClass) _setPrototypeOf(subClass, superClass);
79
73
  }
80
74
 
@@ -133,8 +127,6 @@ function _assertThisInitialized(self) {
133
127
  function _possibleConstructorReturn(self, call) {
134
128
  if (call && (typeof call === "object" || typeof call === "function")) {
135
129
  return call;
136
- } else if (call !== void 0) {
137
- throw new TypeError("Derived constructors may only return object or undefined");
138
130
  }
139
131
 
140
132
  return _assertThisInitialized(self);
@@ -168,7 +160,7 @@ function _superPropBase(object, property) {
168
160
  return object;
169
161
  }
170
162
 
171
- function _get() {
163
+ function _get(target, property, receiver) {
172
164
  if (typeof Reflect !== "undefined" && Reflect.get) {
173
165
  _get = Reflect.get;
174
166
  } else {
@@ -179,16 +171,26 @@ function _get() {
179
171
  var desc = Object.getOwnPropertyDescriptor(base, property);
180
172
 
181
173
  if (desc.get) {
182
- return desc.get.call(arguments.length < 3 ? target : receiver);
174
+ return desc.get.call(receiver);
183
175
  }
184
176
 
185
177
  return desc.value;
186
178
  };
187
179
  }
188
180
 
189
- return _get.apply(this, arguments);
181
+ return _get(target, property, receiver || target);
190
182
  }
191
183
 
184
+ const STORAGE_TOKEN_KEY = "evergis-jwt-token";
185
+ const STORAGE_REFRESH_TOKEN_KEY = "evergis-jwt-token";
186
+
187
+ const parseJwt = token => {
188
+ const base64Url = token.split(".")[1];
189
+ const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
190
+ const jsonPayload = decodeURIComponent(atob(base64).split("").map(c => "%" + "00".concat(c.charCodeAt(0).toString(16)).slice(-2)).join(""));
191
+ return JSON.parse(jsonPayload);
192
+ };
193
+
192
194
  let HttpClient = /*#__PURE__*/function () {
193
195
  function HttpClient(options) {
194
196
  var _options$prefixUrl;
@@ -208,7 +210,30 @@ let HttpClient = /*#__PURE__*/function () {
208
210
  value: function extend(options) {
209
211
  var _options$prefixUrl2;
210
212
 
211
- this.ky = ky__default.extend(options);
213
+ this.ky = ky__default.extend(_extends({}, options, {
214
+ hooks: {
215
+ beforeRequest: [async request => {
216
+ const token = window.localStorage.getItem(STORAGE_TOKEN_KEY);
217
+ const refreshToken = window.localStorage.getItem(STORAGE_REFRESH_TOKEN_KEY);
218
+
219
+ if (token) {
220
+ var _request$headers;
221
+
222
+ const {
223
+ exp
224
+ } = parseJwt(token) || {};
225
+
226
+ if (typeof exp === 'number' && exp - new Date().getTime() < 60 * 1000) {
227
+ await this.post("/account/refresh-token", {
228
+ refreshToken
229
+ });
230
+ }
231
+
232
+ (_request$headers = request.headers) == null ? void 0 : _request$headers.set('Authorization', "Bearer " + (token || ''));
233
+ }
234
+ }]
235
+ }
236
+ }));
212
237
  this.prefixUrl = ((_options$prefixUrl2 = options.prefixUrl) == null ? void 0 : _options$prefixUrl2.toString()) || '';
213
238
  }
214
239
  }, {
@@ -1171,7 +1196,7 @@ let AccountService = /*#__PURE__*/function (_Service) {
1171
1196
  }, {
1172
1197
  key: "authenticate",
1173
1198
  value: function authenticate(query, data) {
1174
- return this.http.post("/account/login", data, query).text();
1199
+ return this.http.post("/account/login", data, query).json();
1175
1200
  }
1176
1201
  /**
1177
1202
  * No description
@@ -1186,8 +1211,8 @@ let AccountService = /*#__PURE__*/function (_Service) {
1186
1211
 
1187
1212
  }, {
1188
1213
  key: "refreshToken",
1189
- value: function refreshToken() {
1190
- return this.http.post("/account/refresh-token", null).text();
1214
+ value: function refreshToken(data) {
1215
+ return this.http.post("/account/refresh-token", data).text();
1191
1216
  }
1192
1217
  /**
1193
1218
  * No description
@@ -1219,7 +1244,7 @@ let AccountService = /*#__PURE__*/function (_Service) {
1219
1244
  }, {
1220
1245
  key: "ldapLogin",
1221
1246
  value: function ldapLogin(data) {
1222
- return this.http.post("/account/external/login/ldap", data).then(() => {});
1247
+ return this.http.post("/account/external/login/ldap", data).json();
1223
1248
  }
1224
1249
  /**
1225
1250
  * No description
@@ -1443,13 +1468,18 @@ let Account = /*#__PURE__*/function (_AccountService) {
1443
1468
 
1444
1469
  _createClass(Account, [{
1445
1470
  key: "login",
1446
- value: async function login(params, authParams) {
1471
+ value: function login(params, authParams) {
1447
1472
  if (authParams === void 0) {
1448
1473
  authParams = {};
1449
1474
  }
1450
1475
 
1451
1476
  if (params) {
1452
- await _get(_getPrototypeOf(Account.prototype), "authenticate", this).call(this, authParams, params);
1477
+ _get(_getPrototypeOf(Account.prototype), "authenticate", this).call(this, authParams, params).then(resonse => {
1478
+ if (resonse) {
1479
+ window.localStorage.setItem(STORAGE_TOKEN_KEY, resonse.token);
1480
+ window.localStorage.setItem(STORAGE_REFRESH_TOKEN_KEY, resonse.refreshToken);
1481
+ }
1482
+ });
1453
1483
  }
1454
1484
  }
1455
1485
  }, {
@@ -1468,8 +1498,10 @@ let Account = /*#__PURE__*/function (_AccountService) {
1468
1498
  }, {
1469
1499
  key: "logout",
1470
1500
  value: async function logout() {
1501
+ window.localStorage.removeItem(STORAGE_TOKEN_KEY);
1502
+ window.localStorage.removeItem(STORAGE_REFRESH_TOKEN_KEY);
1471
1503
  await this.revokeToken();
1472
- updateUserInfo(void 0);
1504
+ updateUserInfo(undefined);
1473
1505
  this.userInfo = {};
1474
1506
  }
1475
1507
  }, {
@@ -5053,8 +5085,8 @@ let Notification = /*#__PURE__*/function (_NotificationService) {
5053
5085
  || event.code === 4002
5054
5086
  /* InvalidSession */
5055
5087
  ) {
5056
- _this.connectStatus = exports.ConnectionStatus.SessionClosed;
5057
- } else if (_this.reconnectTries < _this.MAX_WS_RECONNECT_TRIES) {
5088
+ _this.connectStatus = exports.ConnectionStatus.SessionClosed;
5089
+ } else if (_this.reconnectTries < _this.MAX_WS_RECONNECT_TRIES) {
5058
5090
  _this.connectStatus = exports.ConnectionStatus.Break;
5059
5091
  _this.reconnectTries++;
5060
5092
 
@@ -5886,12 +5918,12 @@ let Resources = /*#__PURE__*/function () {
5886
5918
  }, {
5887
5919
  key: "getDependentNames",
5888
5920
  value: function getDependentNames(deps, depType) {
5889
- return deps.filter(_ref => {
5921
+ return deps.filter((_ref) => {
5890
5922
  let {
5891
5923
  type
5892
5924
  } = _ref;
5893
5925
  return type === depType;
5894
- }).map(_ref2 => {
5926
+ }).map((_ref2) => {
5895
5927
  let {
5896
5928
  name
5897
5929
  } = _ref2;
@@ -6347,7 +6379,7 @@ let Scheduler = /*#__PURE__*/function (_SchedulerService) {
6347
6379
  const taskProgress = await this.getTaskProgress(id);
6348
6380
  this.resolveTaskStatus(taskProgress, resolve, reject);
6349
6381
 
6350
- const taskResultCallback = async _ref => {
6382
+ const taskResultCallback = async (_ref) => {
6351
6383
  let {
6352
6384
  data
6353
6385
  } = _ref;
@@ -7596,7 +7628,7 @@ let Api = /*#__PURE__*/function (_EventEmitter) {
7596
7628
  } = _ref2;
7597
7629
 
7598
7630
  try {
7599
- await this.account.login(authParams, authQueryParams);
7631
+ this.account.login(authParams, authQueryParams);
7600
7632
 
7601
7633
  if (fetchUser) {
7602
7634
  await this.account.fetchCurrentUser();
@@ -8276,11 +8308,11 @@ function isFeatureLayer(layer) {
8276
8308
  Operation["SymDifference"] = "symDifference";
8277
8309
  })(exports.Operation || (exports.Operation = {}));
8278
8310
 
8279
- (function (OwnerFilterDc) {
8280
- OwnerFilterDc["My"] = "My";
8281
- OwnerFilterDc["Shared"] = "Shared";
8282
- OwnerFilterDc["Public"] = "Public";
8283
- })(exports.OwnerFilterDc || (exports.OwnerFilterDc = {}));
8311
+ (function (OwnerFilter) {
8312
+ OwnerFilter["My"] = "My";
8313
+ OwnerFilter["Shared"] = "Shared";
8314
+ OwnerFilter["Public"] = "Public";
8315
+ })(exports.OwnerFilter || (exports.OwnerFilter = {}));
8284
8316
 
8285
8317
  (function (PbfSchema) {
8286
8318
  PbfSchema["XYZ"] = "xyz";