@emilgroup/accounting-sdk 1.11.0 → 1.12.0
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/README.md +2 -2
- package/api/vbas-api.ts +4 -4
- package/base.ts +20 -7
- package/dist/api/vbas-api.d.ts +4 -4
- package/dist/api/vbas-api.js +3 -3
- package/dist/base.d.ts +0 -1
- package/dist/base.js +18 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,11 +17,11 @@ Although this package can be used in both TypeScript and JavaScript, it is inten
|
|
|
17
17
|
Navigate to the folder of your consuming project and run one of the following commands:
|
|
18
18
|
|
|
19
19
|
```
|
|
20
|
-
npm install @emilgroup/accounting-sdk@1.
|
|
20
|
+
npm install @emilgroup/accounting-sdk@1.12.0 --save
|
|
21
21
|
```
|
|
22
22
|
or
|
|
23
23
|
```
|
|
24
|
-
yarn add @emilgroup/accounting-sdk@1.
|
|
24
|
+
yarn add @emilgroup/accounting-sdk@1.12.0
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
And then you can import `FinancialAccountsApi`.
|
package/api/vbas-api.ts
CHANGED
|
@@ -139,7 +139,7 @@ export const VbasApiAxiosParamCreator = function (configuration?: Configuration)
|
|
|
139
139
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
140
140
|
* @param {any} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 50. Default: 10.
|
|
141
141
|
* @param {any} [pageToken] A cursor for use in pagination. pageToken is an ID that defines your place in the list. For instance, if you make a list request and receive 100 objects and pageToken=1, your subsequent call can include pageToken=2 in order to fetch the next page of the list.
|
|
142
|
-
* @param {any} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.<br/> <br/> <i>Allowed values: id, code, leadNumber, policyNumber, policyCode, customerName, status, expiryDate, createdAt</i> <br/> <i>policyCode</i> is required, other filters are optional.
|
|
142
|
+
* @param {any} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.<br/> <br/> <i>Allowed values: id, code, leadNumber, vbNumber, policyNumber, policyCode, customerName, status, expiryDate, createdAt</i> <br/> <i>policyCode</i> is required, other filters are optional.
|
|
143
143
|
* @param {any} [search] To search the list by any field, pass search=xxx to fetch the result.
|
|
144
144
|
* @param {any} [order] Order allowing you to specify the desired order of entities retrieved from the server.<br/> <br/> <i>Allowed values: id, code, expiryDate, createdAt, updatedAt, status</i>
|
|
145
145
|
* @param {any} [expand] No expanding supported
|
|
@@ -301,7 +301,7 @@ export const VbasApiFp = function(configuration?: Configuration) {
|
|
|
301
301
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
302
302
|
* @param {any} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 50. Default: 10.
|
|
303
303
|
* @param {any} [pageToken] A cursor for use in pagination. pageToken is an ID that defines your place in the list. For instance, if you make a list request and receive 100 objects and pageToken=1, your subsequent call can include pageToken=2 in order to fetch the next page of the list.
|
|
304
|
-
* @param {any} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.<br/> <br/> <i>Allowed values: id, code, leadNumber, policyNumber, policyCode, customerName, status, expiryDate, createdAt</i> <br/> <i>policyCode</i> is required, other filters are optional.
|
|
304
|
+
* @param {any} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.<br/> <br/> <i>Allowed values: id, code, leadNumber, vbNumber, policyNumber, policyCode, customerName, status, expiryDate, createdAt</i> <br/> <i>policyCode</i> is required, other filters are optional.
|
|
305
305
|
* @param {any} [search] To search the list by any field, pass search=xxx to fetch the result.
|
|
306
306
|
* @param {any} [order] Order allowing you to specify the desired order of entities retrieved from the server.<br/> <br/> <i>Allowed values: id, code, expiryDate, createdAt, updatedAt, status</i>
|
|
307
307
|
* @param {any} [expand] No expanding supported
|
|
@@ -365,7 +365,7 @@ export const VbasApiFactory = function (configuration?: Configuration, basePath?
|
|
|
365
365
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
366
366
|
* @param {any} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 50. Default: 10.
|
|
367
367
|
* @param {any} [pageToken] A cursor for use in pagination. pageToken is an ID that defines your place in the list. For instance, if you make a list request and receive 100 objects and pageToken=1, your subsequent call can include pageToken=2 in order to fetch the next page of the list.
|
|
368
|
-
* @param {any} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.<br/> <br/> <i>Allowed values: id, code, leadNumber, policyNumber, policyCode, customerName, status, expiryDate, createdAt</i> <br/> <i>policyCode</i> is required, other filters are optional.
|
|
368
|
+
* @param {any} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.<br/> <br/> <i>Allowed values: id, code, leadNumber, vbNumber, policyNumber, policyCode, customerName, status, expiryDate, createdAt</i> <br/> <i>policyCode</i> is required, other filters are optional.
|
|
369
369
|
* @param {any} [search] To search the list by any field, pass search=xxx to fetch the result.
|
|
370
370
|
* @param {any} [order] Order allowing you to specify the desired order of entities retrieved from the server.<br/> <br/> <i>Allowed values: id, code, expiryDate, createdAt, updatedAt, status</i>
|
|
371
371
|
* @param {any} [expand] No expanding supported
|
|
@@ -468,7 +468,7 @@ export interface VbasApiListVbasRequest {
|
|
|
468
468
|
readonly pageToken?: any
|
|
469
469
|
|
|
470
470
|
/**
|
|
471
|
-
* Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.<br/> <br/> <i>Allowed values: id, code, leadNumber, policyNumber, policyCode, customerName, status, expiryDate, createdAt</i> <br/> <i>policyCode</i> is required, other filters are optional.
|
|
471
|
+
* Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.<br/> <br/> <i>Allowed values: id, code, leadNumber, vbNumber, policyNumber, policyCode, customerName, status, expiryDate, createdAt</i> <br/> <i>policyCode</i> is required, other filters are optional.
|
|
472
472
|
* @type {any}
|
|
473
473
|
* @memberof VbasApiListVbas
|
|
474
474
|
*/
|
package/base.ts
CHANGED
|
@@ -64,6 +64,7 @@ export interface RequestArgs {
|
|
|
64
64
|
interface TokenData {
|
|
65
65
|
accessToken?: string;
|
|
66
66
|
username?: string;
|
|
67
|
+
permissions?: string;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
const NETWORK_ERROR_MESSAGE = "Network Error";
|
|
@@ -77,7 +78,6 @@ const TOKEN_DATA = 'APP_TOKEN';
|
|
|
77
78
|
export class BaseAPI {
|
|
78
79
|
protected configuration: Configuration | undefined;
|
|
79
80
|
private tokenData?: TokenData;
|
|
80
|
-
private permissions?: string;
|
|
81
81
|
|
|
82
82
|
constructor(configuration?: Configuration,
|
|
83
83
|
protected basePath: string = BASE_PATH,
|
|
@@ -111,7 +111,11 @@ export class BaseAPI {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
getPermissions(): Array<string> {
|
|
114
|
-
|
|
114
|
+
if (!this.tokenData?.permissions) {
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return this.tokenData.permissions.split(',');
|
|
115
119
|
}
|
|
116
120
|
|
|
117
121
|
async authorize(username: string, password: string): Promise<void> {
|
|
@@ -134,7 +138,7 @@ export class BaseAPI {
|
|
|
134
138
|
this.configuration.accessToken = `Bearer ${accessToken}`;
|
|
135
139
|
this.tokenData.username = username;
|
|
136
140
|
this.tokenData.accessToken = accessToken;
|
|
137
|
-
this.permissions = permissions;
|
|
141
|
+
this.tokenData.permissions = permissions;
|
|
138
142
|
|
|
139
143
|
this.storeTokenData({
|
|
140
144
|
...this.tokenData
|
|
@@ -148,6 +152,16 @@ export class BaseAPI {
|
|
|
148
152
|
throw new Error('Failed to refresh token.');
|
|
149
153
|
}
|
|
150
154
|
|
|
155
|
+
const refreshTokenAxios = globalAxios.create()
|
|
156
|
+
refreshTokenAxios.interceptors.response.use(response => {
|
|
157
|
+
const { permissions } = response.data;
|
|
158
|
+
|
|
159
|
+
this.tokenData.permissions = permissions;
|
|
160
|
+
this.storeTokenData(this.tokenData);
|
|
161
|
+
|
|
162
|
+
return response;
|
|
163
|
+
})
|
|
164
|
+
|
|
151
165
|
const options: AxiosRequestConfig = {
|
|
152
166
|
method: 'POST',
|
|
153
167
|
url: `${this.configuration.basePath}/authservice/v1/refresh-token`,
|
|
@@ -158,8 +172,7 @@ export class BaseAPI {
|
|
|
158
172
|
withCredentials: true,
|
|
159
173
|
};
|
|
160
174
|
|
|
161
|
-
const response = await
|
|
162
|
-
|
|
175
|
+
const response = await refreshTokenAxios.request<LoginClass>(options);
|
|
163
176
|
return response.data;
|
|
164
177
|
}
|
|
165
178
|
|
|
@@ -196,7 +209,7 @@ export class BaseAPI {
|
|
|
196
209
|
try {
|
|
197
210
|
const { accessToken: tokenString, permissions } = await this.refreshTokenInternal();
|
|
198
211
|
const accessToken = `Bearer ${tokenString}`;
|
|
199
|
-
this.permissions = permissions;
|
|
212
|
+
this.tokenData.permissions = permissions;
|
|
200
213
|
|
|
201
214
|
delete originalConfig.headers['Authorization']
|
|
202
215
|
|
|
@@ -223,7 +236,7 @@ export class BaseAPI {
|
|
|
223
236
|
try {
|
|
224
237
|
const { accessToken: tokenString, permissions } = await this.refreshTokenInternal();
|
|
225
238
|
const accessToken = `Bearer ${tokenString}`;
|
|
226
|
-
this.permissions = permissions;
|
|
239
|
+
this.tokenData.permissions = permissions;
|
|
227
240
|
|
|
228
241
|
_retry = true;
|
|
229
242
|
originalConfig.headers['Authorization'] = accessToken;
|
package/dist/api/vbas-api.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ export declare const VbasApiAxiosParamCreator: (configuration?: Configuration) =
|
|
|
47
47
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
48
48
|
* @param {any} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 50. Default: 10.
|
|
49
49
|
* @param {any} [pageToken] A cursor for use in pagination. pageToken is an ID that defines your place in the list. For instance, if you make a list request and receive 100 objects and pageToken=1, your subsequent call can include pageToken=2 in order to fetch the next page of the list.
|
|
50
|
-
* @param {any} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.<br/> <br/> <i>Allowed values: id, code, leadNumber, policyNumber, policyCode, customerName, status, expiryDate, createdAt</i> <br/> <i>policyCode</i> is required, other filters are optional.
|
|
50
|
+
* @param {any} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.<br/> <br/> <i>Allowed values: id, code, leadNumber, vbNumber, policyNumber, policyCode, customerName, status, expiryDate, createdAt</i> <br/> <i>policyCode</i> is required, other filters are optional.
|
|
51
51
|
* @param {any} [search] To search the list by any field, pass search=xxx to fetch the result.
|
|
52
52
|
* @param {any} [order] Order allowing you to specify the desired order of entities retrieved from the server.<br/> <br/> <i>Allowed values: id, code, expiryDate, createdAt, updatedAt, status</i>
|
|
53
53
|
* @param {any} [expand] No expanding supported
|
|
@@ -97,7 +97,7 @@ export declare const VbasApiFp: (configuration?: Configuration) => {
|
|
|
97
97
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
98
98
|
* @param {any} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 50. Default: 10.
|
|
99
99
|
* @param {any} [pageToken] A cursor for use in pagination. pageToken is an ID that defines your place in the list. For instance, if you make a list request and receive 100 objects and pageToken=1, your subsequent call can include pageToken=2 in order to fetch the next page of the list.
|
|
100
|
-
* @param {any} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.<br/> <br/> <i>Allowed values: id, code, leadNumber, policyNumber, policyCode, customerName, status, expiryDate, createdAt</i> <br/> <i>policyCode</i> is required, other filters are optional.
|
|
100
|
+
* @param {any} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.<br/> <br/> <i>Allowed values: id, code, leadNumber, vbNumber, policyNumber, policyCode, customerName, status, expiryDate, createdAt</i> <br/> <i>policyCode</i> is required, other filters are optional.
|
|
101
101
|
* @param {any} [search] To search the list by any field, pass search=xxx to fetch the result.
|
|
102
102
|
* @param {any} [order] Order allowing you to specify the desired order of entities retrieved from the server.<br/> <br/> <i>Allowed values: id, code, expiryDate, createdAt, updatedAt, status</i>
|
|
103
103
|
* @param {any} [expand] No expanding supported
|
|
@@ -147,7 +147,7 @@ export declare const VbasApiFactory: (configuration?: Configuration, basePath?:
|
|
|
147
147
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
148
148
|
* @param {any} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 50. Default: 10.
|
|
149
149
|
* @param {any} [pageToken] A cursor for use in pagination. pageToken is an ID that defines your place in the list. For instance, if you make a list request and receive 100 objects and pageToken=1, your subsequent call can include pageToken=2 in order to fetch the next page of the list.
|
|
150
|
-
* @param {any} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.<br/> <br/> <i>Allowed values: id, code, leadNumber, policyNumber, policyCode, customerName, status, expiryDate, createdAt</i> <br/> <i>policyCode</i> is required, other filters are optional.
|
|
150
|
+
* @param {any} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.<br/> <br/> <i>Allowed values: id, code, leadNumber, vbNumber, policyNumber, policyCode, customerName, status, expiryDate, createdAt</i> <br/> <i>policyCode</i> is required, other filters are optional.
|
|
151
151
|
* @param {any} [search] To search the list by any field, pass search=xxx to fetch the result.
|
|
152
152
|
* @param {any} [order] Order allowing you to specify the desired order of entities retrieved from the server.<br/> <br/> <i>Allowed values: id, code, expiryDate, createdAt, updatedAt, status</i>
|
|
153
153
|
* @param {any} [expand] No expanding supported
|
|
@@ -236,7 +236,7 @@ export interface VbasApiListVbasRequest {
|
|
|
236
236
|
*/
|
|
237
237
|
readonly pageToken?: any;
|
|
238
238
|
/**
|
|
239
|
-
* Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.<br/> <br/> <i>Allowed values: id, code, leadNumber, policyNumber, policyCode, customerName, status, expiryDate, createdAt</i> <br/> <i>policyCode</i> is required, other filters are optional.
|
|
239
|
+
* Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.<br/> <br/> <i>Allowed values: id, code, leadNumber, vbNumber, policyNumber, policyCode, customerName, status, expiryDate, createdAt</i> <br/> <i>policyCode</i> is required, other filters are optional.
|
|
240
240
|
* @type {any}
|
|
241
241
|
* @memberof VbasApiListVbas
|
|
242
242
|
*/
|
package/dist/api/vbas-api.js
CHANGED
|
@@ -199,7 +199,7 @@ var VbasApiAxiosParamCreator = function (configuration) {
|
|
|
199
199
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
200
200
|
* @param {any} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 50. Default: 10.
|
|
201
201
|
* @param {any} [pageToken] A cursor for use in pagination. pageToken is an ID that defines your place in the list. For instance, if you make a list request and receive 100 objects and pageToken=1, your subsequent call can include pageToken=2 in order to fetch the next page of the list.
|
|
202
|
-
* @param {any} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.<br/> <br/> <i>Allowed values: id, code, leadNumber, policyNumber, policyCode, customerName, status, expiryDate, createdAt</i> <br/> <i>policyCode</i> is required, other filters are optional.
|
|
202
|
+
* @param {any} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.<br/> <br/> <i>Allowed values: id, code, leadNumber, vbNumber, policyNumber, policyCode, customerName, status, expiryDate, createdAt</i> <br/> <i>policyCode</i> is required, other filters are optional.
|
|
203
203
|
* @param {any} [search] To search the list by any field, pass search=xxx to fetch the result.
|
|
204
204
|
* @param {any} [order] Order allowing you to specify the desired order of entities retrieved from the server.<br/> <br/> <i>Allowed values: id, code, expiryDate, createdAt, updatedAt, status</i>
|
|
205
205
|
* @param {any} [expand] No expanding supported
|
|
@@ -377,7 +377,7 @@ var VbasApiFp = function (configuration) {
|
|
|
377
377
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
378
378
|
* @param {any} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 50. Default: 10.
|
|
379
379
|
* @param {any} [pageToken] A cursor for use in pagination. pageToken is an ID that defines your place in the list. For instance, if you make a list request and receive 100 objects and pageToken=1, your subsequent call can include pageToken=2 in order to fetch the next page of the list.
|
|
380
|
-
* @param {any} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.<br/> <br/> <i>Allowed values: id, code, leadNumber, policyNumber, policyCode, customerName, status, expiryDate, createdAt</i> <br/> <i>policyCode</i> is required, other filters are optional.
|
|
380
|
+
* @param {any} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.<br/> <br/> <i>Allowed values: id, code, leadNumber, vbNumber, policyNumber, policyCode, customerName, status, expiryDate, createdAt</i> <br/> <i>policyCode</i> is required, other filters are optional.
|
|
381
381
|
* @param {any} [search] To search the list by any field, pass search=xxx to fetch the result.
|
|
382
382
|
* @param {any} [order] Order allowing you to specify the desired order of entities retrieved from the server.<br/> <br/> <i>Allowed values: id, code, expiryDate, createdAt, updatedAt, status</i>
|
|
383
383
|
* @param {any} [expand] No expanding supported
|
|
@@ -459,7 +459,7 @@ var VbasApiFactory = function (configuration, basePath, axios) {
|
|
|
459
459
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
460
460
|
* @param {any} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 50. Default: 10.
|
|
461
461
|
* @param {any} [pageToken] A cursor for use in pagination. pageToken is an ID that defines your place in the list. For instance, if you make a list request and receive 100 objects and pageToken=1, your subsequent call can include pageToken=2 in order to fetch the next page of the list.
|
|
462
|
-
* @param {any} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.<br/> <br/> <i>Allowed values: id, code, leadNumber, policyNumber, policyCode, customerName, status, expiryDate, createdAt</i> <br/> <i>policyCode</i> is required, other filters are optional.
|
|
462
|
+
* @param {any} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.<br/> <br/> <i>Allowed values: id, code, leadNumber, vbNumber, policyNumber, policyCode, customerName, status, expiryDate, createdAt</i> <br/> <i>policyCode</i> is required, other filters are optional.
|
|
463
463
|
* @param {any} [search] To search the list by any field, pass search=xxx to fetch the result.
|
|
464
464
|
* @param {any} [order] Order allowing you to specify the desired order of entities retrieved from the server.<br/> <br/> <i>Allowed values: id, code, expiryDate, createdAt, updatedAt, status</i>
|
|
465
465
|
* @param {any} [expand] No expanding supported
|
package/dist/base.d.ts
CHANGED
|
@@ -52,7 +52,6 @@ export declare class BaseAPI {
|
|
|
52
52
|
protected axios: AxiosInstance;
|
|
53
53
|
protected configuration: Configuration | undefined;
|
|
54
54
|
private tokenData?;
|
|
55
|
-
private permissions?;
|
|
56
55
|
constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance);
|
|
57
56
|
selectEnvironment(env: Environment): void;
|
|
58
57
|
selectBasePath(path: string): void;
|
package/dist/base.js
CHANGED
|
@@ -144,7 +144,11 @@ var BaseAPI = /** @class */ (function () {
|
|
|
144
144
|
this.configuration.basePath = path;
|
|
145
145
|
};
|
|
146
146
|
BaseAPI.prototype.getPermissions = function () {
|
|
147
|
-
|
|
147
|
+
var _a;
|
|
148
|
+
if (!((_a = this.tokenData) === null || _a === void 0 ? void 0 : _a.permissions)) {
|
|
149
|
+
return [];
|
|
150
|
+
}
|
|
151
|
+
return this.tokenData.permissions.split(',');
|
|
148
152
|
};
|
|
149
153
|
BaseAPI.prototype.authorize = function (username, password) {
|
|
150
154
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -170,7 +174,7 @@ var BaseAPI = /** @class */ (function () {
|
|
|
170
174
|
this.configuration.accessToken = "Bearer ".concat(accessToken);
|
|
171
175
|
this.tokenData.username = username;
|
|
172
176
|
this.tokenData.accessToken = accessToken;
|
|
173
|
-
this.permissions = permissions;
|
|
177
|
+
this.tokenData.permissions = permissions;
|
|
174
178
|
this.storeTokenData(__assign({}, this.tokenData));
|
|
175
179
|
return [2 /*return*/];
|
|
176
180
|
}
|
|
@@ -179,7 +183,8 @@ var BaseAPI = /** @class */ (function () {
|
|
|
179
183
|
};
|
|
180
184
|
BaseAPI.prototype.refreshTokenInternal = function () {
|
|
181
185
|
return __awaiter(this, void 0, void 0, function () {
|
|
182
|
-
var username, options, response;
|
|
186
|
+
var username, refreshTokenAxios, options, response;
|
|
187
|
+
var _this = this;
|
|
183
188
|
return __generator(this, function (_a) {
|
|
184
189
|
switch (_a.label) {
|
|
185
190
|
case 0:
|
|
@@ -187,6 +192,13 @@ var BaseAPI = /** @class */ (function () {
|
|
|
187
192
|
if (!username) {
|
|
188
193
|
throw new Error('Failed to refresh token.');
|
|
189
194
|
}
|
|
195
|
+
refreshTokenAxios = axios_1.default.create();
|
|
196
|
+
refreshTokenAxios.interceptors.response.use(function (response) {
|
|
197
|
+
var permissions = response.data.permissions;
|
|
198
|
+
_this.tokenData.permissions = permissions;
|
|
199
|
+
_this.storeTokenData(_this.tokenData);
|
|
200
|
+
return response;
|
|
201
|
+
});
|
|
190
202
|
options = {
|
|
191
203
|
method: 'POST',
|
|
192
204
|
url: "".concat(this.configuration.basePath, "/authservice/v1/refresh-token"),
|
|
@@ -196,7 +208,7 @@ var BaseAPI = /** @class */ (function () {
|
|
|
196
208
|
data: { username: username },
|
|
197
209
|
withCredentials: true,
|
|
198
210
|
};
|
|
199
|
-
return [4 /*yield*/,
|
|
211
|
+
return [4 /*yield*/, refreshTokenAxios.request(options)];
|
|
200
212
|
case 1:
|
|
201
213
|
response = _a.sent();
|
|
202
214
|
return [2 /*return*/, response.data];
|
|
@@ -241,7 +253,7 @@ var BaseAPI = /** @class */ (function () {
|
|
|
241
253
|
case 2:
|
|
242
254
|
_a = _c.sent(), tokenString = _a.accessToken, permissions = _a.permissions;
|
|
243
255
|
accessToken = "Bearer ".concat(tokenString);
|
|
244
|
-
this.permissions = permissions;
|
|
256
|
+
this.tokenData.permissions = permissions;
|
|
245
257
|
delete originalConfig.headers['Authorization'];
|
|
246
258
|
originalConfig.headers['Authorization'] = accessToken;
|
|
247
259
|
this.configuration.accessToken = accessToken;
|
|
@@ -267,7 +279,7 @@ var BaseAPI = /** @class */ (function () {
|
|
|
267
279
|
case 7:
|
|
268
280
|
_b = _c.sent(), tokenString = _b.accessToken, permissions = _b.permissions;
|
|
269
281
|
accessToken = "Bearer ".concat(tokenString);
|
|
270
|
-
this.permissions = permissions;
|
|
282
|
+
this.tokenData.permissions = permissions;
|
|
271
283
|
_retry = true;
|
|
272
284
|
originalConfig.headers['Authorization'] = accessToken;
|
|
273
285
|
this.configuration.accessToken = accessToken;
|