@evergis/api 4.1.52 → 4.1.54

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Everpoint
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Everpoint
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
- # @evergis/api
2
-
3
- Библиотека API.
4
-
5
- ### Генерирование API
6
-
7
- ```shell
8
- $ yarn generate
9
- ```
10
-
11
- ***ВАЖНО!!!***: Никогда и ни при каких обстоятельствах нельзя вручную править файлы,
12
- размещенные в директории `src/__generated__`!
1
+ # @evergis/api
2
+
3
+ Библиотека API.
4
+
5
+ ### Генерирование API
6
+
7
+ ```shell
8
+ $ yarn generate
9
+ ```
10
+
11
+ ***ВАЖНО!!!***: Никогда и ни при каких обстоятельствах нельзя вручную править файлы,
12
+ размещенные в директории `src/__generated__`!
package/dist/Api.d.ts CHANGED
@@ -57,6 +57,7 @@ export declare class Api extends EventEmitter {
57
57
  protected readonly http: HttpClient;
58
58
  private readonly wsUrl;
59
59
  private readonly urlPath;
60
+ private refreshingToken;
60
61
  constructor({ url, wsUrl, wsKeepAlive, snappingHubUrl, http, urlPath, httpOptions, }: ApiParams);
61
62
  get isShared(): boolean;
62
63
  get isPresentation(): boolean;
package/dist/api.esm.js CHANGED
@@ -746,7 +746,7 @@ class Account extends AccountService {
746
746
  }
747
747
  return userInfo;
748
748
  }
749
- async login(params, authParams = {}, useJwt = false) {
749
+ async login(params, authParams = {}, useJwt = true) {
750
750
  if (params) {
751
751
  const response = await super.authenticate(authParams, params);
752
752
  if (response && useJwt) {
@@ -2783,6 +2783,7 @@ class Api extends EventEmitter {
2783
2783
  http;
2784
2784
  wsUrl;
2785
2785
  urlPath;
2786
+ refreshingToken = false;
2786
2787
  constructor({ url, wsUrl, wsKeepAlive, snappingHubUrl, http, urlPath, httpOptions, }) {
2787
2788
  super();
2788
2789
  const { hooks } = httpOptions || {};
@@ -2814,6 +2815,12 @@ class Api extends EventEmitter {
2814
2815
  retryCount === 1) {
2815
2816
  switch (error.response.status) {
2816
2817
  case 401:
2818
+ if (this.refreshingToken) {
2819
+ const currentToken = window.localStorage.getItem(STORAGE_TOKEN_KEY);
2820
+ request.headers?.set("Authorization", `Bearer ${currentToken || ""}`);
2821
+ return;
2822
+ }
2823
+ this.refreshingToken = true;
2817
2824
  try {
2818
2825
  const refreshToken = window.localStorage.getItem(STORAGE_REFRESH_TOKEN_KEY);
2819
2826
  if (refreshToken) {
@@ -2826,10 +2833,16 @@ class Api extends EventEmitter {
2826
2833
  }
2827
2834
  request.headers?.set("Authorization", `Bearer ${refreshTokenResponse.token || ""}`);
2828
2835
  }
2836
+ else {
2837
+ await this.logout();
2838
+ }
2829
2839
  }
2830
2840
  catch (error) {
2831
2841
  await this.logout();
2832
2842
  }
2843
+ finally {
2844
+ this.refreshingToken = false;
2845
+ }
2833
2846
  break;
2834
2847
  }
2835
2848
  }