@evergis/api 3.0.200 → 3.0.201
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/__generated__/LayersService.d.ts +2 -2
- package/dist/__generated__/ProjectsService.d.ts +2 -2
- package/dist/__generated__/StatisticService.d.ts +2 -2
- package/dist/__generated__/TablesService.d.ts +2 -2
- package/dist/__generated__/WmsServerService.d.ts +2 -2
- package/dist/__generated__/data-contracts.d.ts +5 -5
- package/dist/api.cjs.development.js +32 -34
- package/dist/api.cjs.development.js.map +1 -1
- package/dist/api.cjs.production.min.js +1 -1
- package/dist/api.cjs.production.min.js.map +1 -1
- package/dist/api.esm.js +32 -34
- package/dist/api.esm.js.map +1 -1
- package/dist/services/Statistic.d.ts +2 -2
- package/dist/services/constants.d.ts +1 -1
- package/package.json +2 -2
package/dist/api.esm.js
CHANGED
|
@@ -176,14 +176,7 @@ function _get(target, property, receiver) {
|
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
const STORAGE_TOKEN_KEY = "evergis-jwt-token";
|
|
179
|
-
const STORAGE_REFRESH_TOKEN_KEY = "evergis-
|
|
180
|
-
|
|
181
|
-
const parseJwt = token => {
|
|
182
|
-
const base64Url = token.split(".")[1];
|
|
183
|
-
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
|
184
|
-
const jsonPayload = decodeURIComponent(atob(base64).split("").map(c => "%" + "00".concat(c.charCodeAt(0).toString(16)).slice(-2)).join(""));
|
|
185
|
-
return JSON.parse(jsonPayload);
|
|
186
|
-
};
|
|
179
|
+
const STORAGE_REFRESH_TOKEN_KEY = "evergis-refresh-token";
|
|
187
180
|
|
|
188
181
|
let HttpClient = /*#__PURE__*/function () {
|
|
189
182
|
function HttpClient(options) {
|
|
@@ -204,30 +197,7 @@ let HttpClient = /*#__PURE__*/function () {
|
|
|
204
197
|
value: function extend(options) {
|
|
205
198
|
var _options$prefixUrl2;
|
|
206
199
|
|
|
207
|
-
this.ky = ky.extend(
|
|
208
|
-
hooks: {
|
|
209
|
-
beforeRequest: [async request => {
|
|
210
|
-
const token = window.localStorage.getItem(STORAGE_TOKEN_KEY);
|
|
211
|
-
const refreshToken = window.localStorage.getItem(STORAGE_REFRESH_TOKEN_KEY);
|
|
212
|
-
|
|
213
|
-
if (token) {
|
|
214
|
-
var _request$headers;
|
|
215
|
-
|
|
216
|
-
const {
|
|
217
|
-
exp
|
|
218
|
-
} = parseJwt(token) || {};
|
|
219
|
-
|
|
220
|
-
if (typeof exp === 'number' && exp - new Date().getTime() < 60 * 1000) {
|
|
221
|
-
await this.post("/account/refresh-token", {
|
|
222
|
-
refreshToken
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
(_request$headers = request.headers) == null ? void 0 : _request$headers.set('Authorization', "Bearer " + (token || ''));
|
|
227
|
-
}
|
|
228
|
-
}]
|
|
229
|
-
}
|
|
230
|
-
}));
|
|
200
|
+
this.ky = ky.extend(options);
|
|
231
201
|
this.prefixUrl = ((_options$prefixUrl2 = options.prefixUrl) == null ? void 0 : _options$prefixUrl2.toString()) || '';
|
|
232
202
|
}
|
|
233
203
|
}, {
|
|
@@ -7519,6 +7489,13 @@ let VectorTiles = /*#__PURE__*/function (_VectorTileService) {
|
|
|
7519
7489
|
return VectorTiles;
|
|
7520
7490
|
}(VectorTileService);
|
|
7521
7491
|
|
|
7492
|
+
const parseJwt = token => {
|
|
7493
|
+
const base64Url = token.split(".")[1];
|
|
7494
|
+
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
|
7495
|
+
const jsonPayload = decodeURIComponent(atob(base64).split("").map(c => "%" + "00".concat(c.charCodeAt(0).toString(16)).slice(-2)).join(""));
|
|
7496
|
+
return JSON.parse(jsonPayload);
|
|
7497
|
+
};
|
|
7498
|
+
|
|
7522
7499
|
var UrlPath;
|
|
7523
7500
|
|
|
7524
7501
|
(function (UrlPath) {
|
|
@@ -7538,6 +7515,8 @@ let Api = /*#__PURE__*/function (_EventEmitter) {
|
|
|
7538
7515
|
var _super = /*#__PURE__*/_createSuper(Api);
|
|
7539
7516
|
|
|
7540
7517
|
function Api(_ref) {
|
|
7518
|
+
var _hooks$beforeRequest;
|
|
7519
|
+
|
|
7541
7520
|
var _this;
|
|
7542
7521
|
|
|
7543
7522
|
let {
|
|
@@ -7561,7 +7540,26 @@ let Api = /*#__PURE__*/function (_EventEmitter) {
|
|
|
7561
7540
|
timeout: false
|
|
7562
7541
|
}, httpOptions || {}, {
|
|
7563
7542
|
hooks: _extends({}, hooks || {}, {
|
|
7564
|
-
beforeRequest: [
|
|
7543
|
+
beforeRequest: [async request => {
|
|
7544
|
+
const token = window.localStorage.getItem(STORAGE_TOKEN_KEY);
|
|
7545
|
+
const refreshToken = window.localStorage.getItem(STORAGE_REFRESH_TOKEN_KEY);
|
|
7546
|
+
|
|
7547
|
+
if (token && refreshToken) {
|
|
7548
|
+
var _request$headers;
|
|
7549
|
+
|
|
7550
|
+
const {
|
|
7551
|
+
exp
|
|
7552
|
+
} = parseJwt(token) || {};
|
|
7553
|
+
|
|
7554
|
+
if (typeof exp === 'number' && exp - new Date().getTime() < 60 * 1000) {
|
|
7555
|
+
await _this.account.refreshToken({
|
|
7556
|
+
refreshToken
|
|
7557
|
+
});
|
|
7558
|
+
}
|
|
7559
|
+
|
|
7560
|
+
(_request$headers = request.headers) == null ? void 0 : _request$headers.set('Authorization', "Bearer " + (token || ''));
|
|
7561
|
+
}
|
|
7562
|
+
}, ...((_hooks$beforeRequest = hooks == null ? void 0 : hooks.beforeRequest) != null ? _hooks$beforeRequest : [])],
|
|
7565
7563
|
afterResponse: [response => {
|
|
7566
7564
|
const apiEvent = apiEventsByResponseStatus[response.status];
|
|
7567
7565
|
|
|
@@ -7570,7 +7568,7 @@ let Api = /*#__PURE__*/function (_EventEmitter) {
|
|
|
7570
7568
|
}
|
|
7571
7569
|
|
|
7572
7570
|
return response;
|
|
7573
|
-
}, ...(hooks
|
|
7571
|
+
}, ...((hooks == null ? void 0 : hooks.afterResponse) || [])]
|
|
7574
7572
|
})
|
|
7575
7573
|
}));
|
|
7576
7574
|
_this.url = url;
|