@emilgroup/public-api-sdk-node 1.6.0-dev.0 → 1.7.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/base.ts +4 -4
- package/dist/base.d.ts +1 -1
- package/dist/base.js +4 -4
- 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/public-api-sdk-node@1.
|
|
20
|
+
npm install @emilgroup/public-api-sdk-node@1.7.0 --save
|
|
21
21
|
```
|
|
22
22
|
or
|
|
23
23
|
```
|
|
24
|
-
yarn add @emilgroup/public-api-sdk-node@1.
|
|
24
|
+
yarn add @emilgroup/public-api-sdk-node@1.7.0
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
And then you can import `PublicApi`.
|
package/base.ts
CHANGED
|
@@ -21,7 +21,7 @@ import * as fs from 'fs';
|
|
|
21
21
|
import * as path from 'path';
|
|
22
22
|
import * as os from 'os';
|
|
23
23
|
|
|
24
|
-
export const BASE_PATH = "
|
|
24
|
+
export const BASE_PATH = "http://localhost".replace(/\/+$/, "");
|
|
25
25
|
const CONFIG_DIRECTORY = '.emil';
|
|
26
26
|
const CONFIG_FILENAME = 'credentials';
|
|
27
27
|
const KEY_USERNAME = 'emil_username';
|
|
@@ -170,7 +170,7 @@ export class BaseAPI {
|
|
|
170
170
|
this.configuration.refreshToken = refreshToken;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
async
|
|
173
|
+
async refreshTokenInternal(): Promise<string> {
|
|
174
174
|
const { username, refreshToken } = this.configuration;
|
|
175
175
|
|
|
176
176
|
|
|
@@ -220,7 +220,7 @@ export class BaseAPI {
|
|
|
220
220
|
if (err.response.status === 401 && !originalConfig._retry) {
|
|
221
221
|
originalConfig._retry = true;
|
|
222
222
|
try {
|
|
223
|
-
const tokenString = await this.
|
|
223
|
+
const tokenString = await this.refreshTokenInternal();
|
|
224
224
|
const accessToken = `Bearer ${tokenString}`;
|
|
225
225
|
|
|
226
226
|
originalConfig.headers['Authorization'] = `Bearer ${accessToken}`
|
|
@@ -245,7 +245,7 @@ export class BaseAPI {
|
|
|
245
245
|
){
|
|
246
246
|
_retry_count++;
|
|
247
247
|
try {
|
|
248
|
-
const tokenString = await this.
|
|
248
|
+
const tokenString = await this.refreshTokenInternal();
|
|
249
249
|
const accessToken = `Bearer ${tokenString}`;
|
|
250
250
|
|
|
251
251
|
_retry = true;
|
package/dist/base.d.ts
CHANGED
|
@@ -59,7 +59,7 @@ export declare class BaseAPI {
|
|
|
59
59
|
private readEnvVariables;
|
|
60
60
|
selectEnvironment(env: Environment): void;
|
|
61
61
|
authorize(username: string, password: string): Promise<void>;
|
|
62
|
-
|
|
62
|
+
refreshTokenInternal(): Promise<string>;
|
|
63
63
|
private extractRefreshToken;
|
|
64
64
|
getConfiguration(): Configuration;
|
|
65
65
|
private attachInterceptor;
|
package/dist/base.js
CHANGED
|
@@ -109,7 +109,7 @@ var axios_1 = __importDefault(require("axios"));
|
|
|
109
109
|
var fs = __importStar(require("fs"));
|
|
110
110
|
var path = __importStar(require("path"));
|
|
111
111
|
var os = __importStar(require("os"));
|
|
112
|
-
exports.BASE_PATH = "
|
|
112
|
+
exports.BASE_PATH = "http://localhost".replace(/\/+$/, "");
|
|
113
113
|
var CONFIG_DIRECTORY = '.emil';
|
|
114
114
|
var CONFIG_FILENAME = 'credentials';
|
|
115
115
|
var KEY_USERNAME = 'emil_username';
|
|
@@ -270,7 +270,7 @@ var BaseAPI = /** @class */ (function () {
|
|
|
270
270
|
});
|
|
271
271
|
});
|
|
272
272
|
};
|
|
273
|
-
BaseAPI.prototype.
|
|
273
|
+
BaseAPI.prototype.refreshTokenInternal = function () {
|
|
274
274
|
return __awaiter(this, void 0, void 0, function () {
|
|
275
275
|
var _a, username, refreshToken, options, accessToken;
|
|
276
276
|
return __generator(this, function (_b) {
|
|
@@ -324,7 +324,7 @@ var BaseAPI = /** @class */ (function () {
|
|
|
324
324
|
_a.label = 1;
|
|
325
325
|
case 1:
|
|
326
326
|
_a.trys.push([1, 3, , 4]);
|
|
327
|
-
return [4 /*yield*/, this.
|
|
327
|
+
return [4 /*yield*/, this.refreshTokenInternal()];
|
|
328
328
|
case 2:
|
|
329
329
|
tokenString = _a.sent();
|
|
330
330
|
accessToken = "Bearer ".concat(tokenString);
|
|
@@ -351,7 +351,7 @@ var BaseAPI = /** @class */ (function () {
|
|
|
351
351
|
_a.label = 6;
|
|
352
352
|
case 6:
|
|
353
353
|
_a.trys.push([6, 8, , 9]);
|
|
354
|
-
return [4 /*yield*/, this.
|
|
354
|
+
return [4 /*yield*/, this.refreshTokenInternal()];
|
|
355
355
|
case 7:
|
|
356
356
|
tokenString = _a.sent();
|
|
357
357
|
accessToken = "Bearer ".concat(tokenString);
|