@emilgroup/auth-sdk-node 1.12.1-beta.1 → 1.12.1

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 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/auth-sdk-node@1.12.1-beta.1 --save
20
+ npm install @emilgroup/auth-sdk-node@1.12.1 --save
21
21
  ```
22
22
  or
23
23
  ```
24
- yarn add @emilgroup/auth-sdk-node@1.12.1-beta.1
24
+ yarn add @emilgroup/auth-sdk-node@1.12.1
25
25
  ```
26
26
 
27
27
  And then you can import ``.
@@ -168,37 +168,6 @@ export const AuthserviceApiAxiosParamCreator = function (configuration?: Configu
168
168
  options: localVarRequestOptions,
169
169
  };
170
170
  },
171
- /**
172
- *
173
- * @param {*} [options] Override http request option.
174
- * @throws {RequiredError}
175
- */
176
- generateReadmeToken: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
177
- const localVarPath = `/authservice/v1/readme-token`;
178
- // use dummy base URL string because the URL constructor only accepts absolute URLs.
179
- const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
180
- let baseOptions;
181
- let baseAccessToken;
182
- if (configuration) {
183
- baseOptions = configuration.baseOptions;
184
- baseAccessToken = configuration.accessToken;
185
- }
186
-
187
- const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
188
- const localVarHeaderParameter = {} as any;
189
- const localVarQueryParameter = {} as any;
190
-
191
-
192
-
193
- setSearchParams(localVarUrlObj, localVarQueryParameter);
194
- let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
195
- localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
196
-
197
- return {
198
- url: toPathString(localVarUrlObj),
199
- options: localVarRequestOptions,
200
- };
201
- },
202
171
  /**
203
172
  * Get SAML login link configured for the tenant in cognito as well as tenant settings
204
173
  * @summary Get SAML login link for tenant
@@ -593,15 +562,6 @@ export const AuthserviceApiFp = function(configuration?: Configuration) {
593
562
  const localVarAxiosArgs = await localVarAxiosParamCreator.forgotPassword(forgotPasswordRequestDto, options);
594
563
  return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
595
564
  },
596
- /**
597
- *
598
- * @param {*} [options] Override http request option.
599
- * @throws {RequiredError}
600
- */
601
- async generateReadmeToken(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
602
- const localVarAxiosArgs = await localVarAxiosParamCreator.generateReadmeToken(options);
603
- return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
604
- },
605
565
  /**
606
566
  * Get SAML login link configured for the tenant in cognito as well as tenant settings
607
567
  * @summary Get SAML login link for tenant
@@ -742,14 +702,6 @@ export const AuthserviceApiFactory = function (configuration?: Configuration, ba
742
702
  forgotPassword(forgotPasswordRequestDto: ForgotPasswordRequestDto, options?: any): AxiosPromise<void> {
743
703
  return localVarFp.forgotPassword(forgotPasswordRequestDto, options).then((request) => request(axios, basePath));
744
704
  },
745
- /**
746
- *
747
- * @param {*} [options] Override http request option.
748
- * @throws {RequiredError}
749
- */
750
- generateReadmeToken(options?: any): AxiosPromise<void> {
751
- return localVarFp.generateReadmeToken(options).then((request) => request(axios, basePath));
752
- },
753
705
  /**
754
706
  * Get SAML login link configured for the tenant in cognito as well as tenant settings
755
707
  * @summary Get SAML login link for tenant
@@ -1062,16 +1014,6 @@ export class AuthserviceApi extends BaseAPI {
1062
1014
  return AuthserviceApiFp(this.configuration).forgotPassword(requestParameters.forgotPasswordRequestDto, options).then((request) => request(this.axios, this.basePath));
1063
1015
  }
1064
1016
 
1065
- /**
1066
- *
1067
- * @param {*} [options] Override http request option.
1068
- * @throws {RequiredError}
1069
- * @memberof AuthserviceApi
1070
- */
1071
- public generateReadmeToken(options?: AxiosRequestConfig) {
1072
- return AuthserviceApiFp(this.configuration).generateReadmeToken(options).then((request) => request(this.axios, this.basePath));
1073
- }
1074
-
1075
1017
  /**
1076
1018
  * Get SAML login link configured for the tenant in cognito as well as tenant settings
1077
1019
  * @summary Get SAML login link for tenant
package/base.ts CHANGED
@@ -79,7 +79,6 @@ export class BaseAPI {
79
79
  protected configuration: Configuration;
80
80
  private username?: string;
81
81
  private password?: string;
82
- private permissions?: string;
83
82
 
84
83
  constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
85
84
  if (configuration) {
@@ -150,10 +149,6 @@ export class BaseAPI {
150
149
  this.configuration.basePath = env;
151
150
  }
152
151
 
153
- getPermissions(): Array<string> {
154
- return this.permissions.split(',');
155
- }
156
-
157
152
  async authorize(username: string, password: string): Promise<void> {
158
153
  const options: AxiosRequestConfig = {
159
154
  method: 'POST',
@@ -168,21 +163,20 @@ export class BaseAPI {
168
163
 
169
164
  const response = await globalAxios.request<LoginClass>(options);
170
165
 
171
- const { data: { accessToken, permissions } } = response;
166
+ const { data: { accessToken } } = response;
172
167
  this.configuration.username = username;
173
168
  this.configuration.accessToken = `Bearer ${accessToken}`;
174
- this.permissions = permissions;
175
169
 
176
170
  const refreshToken = this.extractRefreshToken(response)
177
171
  this.configuration.refreshToken = refreshToken;
178
172
  }
179
173
 
180
- async refreshTokenInternal(): Promise<LoginClass> {
174
+ async refreshTokenInternal(): Promise<string> {
181
175
  const { username, refreshToken } = this.configuration;
182
176
 
183
177
 
184
178
  if (!username || !refreshToken) {
185
- throw new Error('Failed to refresh token.');
179
+ return '';
186
180
  }
187
181
 
188
182
  const options: AxiosRequestConfig = {
@@ -196,9 +190,9 @@ export class BaseAPI {
196
190
  withCredentials: true,
197
191
  };
198
192
 
199
- const response = await globalAxios.request<LoginClass>(options);
193
+ const { data: { accessToken } } = await globalAxios.request<LoginClass>(options);
200
194
 
201
- return response.data;
195
+ return accessToken;
202
196
  }
203
197
 
204
198
  private extractRefreshToken(response: AxiosResponse): string {
@@ -227,9 +221,8 @@ export class BaseAPI {
227
221
  if (err.response.status === 401 && !originalConfig._retry) {
228
222
  originalConfig._retry = true;
229
223
  try {
230
- const { accessToken: tokenString, permissions } = await this.refreshTokenInternal();
224
+ const tokenString = await this.refreshTokenInternal();
231
225
  const accessToken = `Bearer ${tokenString}`;
232
- this.permissions = permissions;
233
226
 
234
227
  originalConfig.headers['Authorization'] = `Bearer ${accessToken}`
235
228
 
@@ -253,9 +246,8 @@ export class BaseAPI {
253
246
  ){
254
247
  _retry_count++;
255
248
  try {
256
- const { accessToken: tokenString, permissions } = await this.refreshTokenInternal();
249
+ const tokenString = await this.refreshTokenInternal();
257
250
  const accessToken = `Bearer ${tokenString}`;
258
- this.permissions = permissions;
259
251
 
260
252
  _retry = true;
261
253
  originalConfig.headers['Authorization'] = accessToken;
@@ -53,12 +53,6 @@ export declare const AuthserviceApiAxiosParamCreator: (configuration?: Configura
53
53
  * @throws {RequiredError}
54
54
  */
55
55
  forgotPassword: (forgotPasswordRequestDto: ForgotPasswordRequestDto, options?: AxiosRequestConfig) => Promise<RequestArgs>;
56
- /**
57
- *
58
- * @param {*} [options] Override http request option.
59
- * @throws {RequiredError}
60
- */
61
- generateReadmeToken: (options?: AxiosRequestConfig) => Promise<RequestArgs>;
62
56
  /**
63
57
  * Get SAML login link configured for the tenant in cognito as well as tenant settings
64
58
  * @summary Get SAML login link for tenant
@@ -162,12 +156,6 @@ export declare const AuthserviceApiFp: (configuration?: Configuration) => {
162
156
  * @throws {RequiredError}
163
157
  */
164
158
  forgotPassword(forgotPasswordRequestDto: ForgotPasswordRequestDto, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>>;
165
- /**
166
- *
167
- * @param {*} [options] Override http request option.
168
- * @throws {RequiredError}
169
- */
170
- generateReadmeToken(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>>;
171
159
  /**
172
160
  * Get SAML login link configured for the tenant in cognito as well as tenant settings
173
161
  * @summary Get SAML login link for tenant
@@ -271,12 +259,6 @@ export declare const AuthserviceApiFactory: (configuration?: Configuration, base
271
259
  * @throws {RequiredError}
272
260
  */
273
261
  forgotPassword(forgotPasswordRequestDto: ForgotPasswordRequestDto, options?: any): AxiosPromise<void>;
274
- /**
275
- *
276
- * @param {*} [options] Override http request option.
277
- * @throws {RequiredError}
278
- */
279
- generateReadmeToken(options?: any): AxiosPromise<void>;
280
262
  /**
281
263
  * Get SAML login link configured for the tenant in cognito as well as tenant settings
282
264
  * @summary Get SAML login link for tenant
@@ -547,13 +529,6 @@ export declare class AuthserviceApi extends BaseAPI {
547
529
  * @memberof AuthserviceApi
548
530
  */
549
531
  forgotPassword(requestParameters: AuthserviceApiForgotPasswordRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<void, any>>;
550
- /**
551
- *
552
- * @param {*} [options] Override http request option.
553
- * @throws {RequiredError}
554
- * @memberof AuthserviceApi
555
- */
556
- generateReadmeToken(options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<void, any>>;
557
532
  /**
558
533
  * Get SAML login link configured for the tenant in cognito as well as tenant settings
559
534
  * @summary Get SAML login link for tenant
@@ -201,35 +201,6 @@ var AuthserviceApiAxiosParamCreator = function (configuration) {
201
201
  });
202
202
  });
203
203
  },
204
- /**
205
- *
206
- * @param {*} [options] Override http request option.
207
- * @throws {RequiredError}
208
- */
209
- generateReadmeToken: function (options) {
210
- if (options === void 0) { options = {}; }
211
- return __awaiter(_this, void 0, void 0, function () {
212
- var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, headersFromBaseOptions;
213
- return __generator(this, function (_a) {
214
- localVarPath = "/authservice/v1/readme-token";
215
- localVarUrlObj = new url_1.URL(localVarPath, common_1.DUMMY_BASE_URL);
216
- if (configuration) {
217
- baseOptions = configuration.baseOptions;
218
- baseAccessToken = configuration.accessToken;
219
- }
220
- localVarRequestOptions = __assign(__assign({ method: 'POST' }, baseOptions), options);
221
- localVarHeaderParameter = {};
222
- localVarQueryParameter = {};
223
- (0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
224
- headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
225
- localVarRequestOptions.headers = __assign(__assign(__assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
226
- return [2 /*return*/, {
227
- url: (0, common_1.toPathString)(localVarUrlObj),
228
- options: localVarRequestOptions,
229
- }];
230
- });
231
- });
232
- },
233
204
  /**
234
205
  * Get SAML login link configured for the tenant in cognito as well as tenant settings
235
206
  * @summary Get SAML login link for tenant
@@ -623,24 +594,6 @@ var AuthserviceApiFp = function (configuration) {
623
594
  });
624
595
  });
625
596
  },
626
- /**
627
- *
628
- * @param {*} [options] Override http request option.
629
- * @throws {RequiredError}
630
- */
631
- generateReadmeToken: function (options) {
632
- return __awaiter(this, void 0, void 0, function () {
633
- var localVarAxiosArgs;
634
- return __generator(this, function (_a) {
635
- switch (_a.label) {
636
- case 0: return [4 /*yield*/, localVarAxiosParamCreator.generateReadmeToken(options)];
637
- case 1:
638
- localVarAxiosArgs = _a.sent();
639
- return [2 /*return*/, (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)];
640
- }
641
- });
642
- });
643
- },
644
597
  /**
645
598
  * Get SAML login link configured for the tenant in cognito as well as tenant settings
646
599
  * @summary Get SAML login link for tenant
@@ -862,14 +815,6 @@ var AuthserviceApiFactory = function (configuration, basePath, axios) {
862
815
  forgotPassword: function (forgotPasswordRequestDto, options) {
863
816
  return localVarFp.forgotPassword(forgotPasswordRequestDto, options).then(function (request) { return request(axios, basePath); });
864
817
  },
865
- /**
866
- *
867
- * @param {*} [options] Override http request option.
868
- * @throws {RequiredError}
869
- */
870
- generateReadmeToken: function (options) {
871
- return localVarFp.generateReadmeToken(options).then(function (request) { return request(axios, basePath); });
872
- },
873
818
  /**
874
819
  * Get SAML login link configured for the tenant in cognito as well as tenant settings
875
820
  * @summary Get SAML login link for tenant
@@ -1011,16 +956,6 @@ var AuthserviceApi = /** @class */ (function (_super) {
1011
956
  var _this = this;
1012
957
  return (0, exports.AuthserviceApiFp)(this.configuration).forgotPassword(requestParameters.forgotPasswordRequestDto, options).then(function (request) { return request(_this.axios, _this.basePath); });
1013
958
  };
1014
- /**
1015
- *
1016
- * @param {*} [options] Override http request option.
1017
- * @throws {RequiredError}
1018
- * @memberof AuthserviceApi
1019
- */
1020
- AuthserviceApi.prototype.generateReadmeToken = function (options) {
1021
- var _this = this;
1022
- return (0, exports.AuthserviceApiFp)(this.configuration).generateReadmeToken(options).then(function (request) { return request(_this.axios, _this.basePath); });
1023
- };
1024
959
  /**
1025
960
  * Get SAML login link configured for the tenant in cognito as well as tenant settings
1026
961
  * @summary Get SAML login link for tenant
package/dist/base.d.ts CHANGED
@@ -53,16 +53,14 @@ export declare class BaseAPI {
53
53
  protected configuration: Configuration;
54
54
  private username?;
55
55
  private password?;
56
- private permissions?;
57
56
  constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance);
58
57
  initialize(env?: Environment): Promise<void>;
59
58
  private loadCredentials;
60
59
  private readConfigFile;
61
60
  private readEnvVariables;
62
61
  selectEnvironment(env: Environment): void;
63
- getPermissions(): Array<string>;
64
62
  authorize(username: string, password: string): Promise<void>;
65
- refreshTokenInternal(): Promise<LoginClass>;
63
+ refreshTokenInternal(): Promise<string>;
66
64
  private extractRefreshToken;
67
65
  getConfiguration(): Configuration;
68
66
  private attachInterceptor;
package/dist/base.js CHANGED
@@ -242,14 +242,11 @@ var BaseAPI = /** @class */ (function () {
242
242
  BaseAPI.prototype.selectEnvironment = function (env) {
243
243
  this.configuration.basePath = env;
244
244
  };
245
- BaseAPI.prototype.getPermissions = function () {
246
- return this.permissions.split(',');
247
- };
248
245
  BaseAPI.prototype.authorize = function (username, password) {
249
246
  return __awaiter(this, void 0, void 0, function () {
250
- var options, response, _a, accessToken, permissions, refreshToken;
251
- return __generator(this, function (_b) {
252
- switch (_b.label) {
247
+ var options, response, accessToken, refreshToken;
248
+ return __generator(this, function (_a) {
249
+ switch (_a.label) {
253
250
  case 0:
254
251
  options = {
255
252
  method: 'POST',
@@ -263,11 +260,10 @@ var BaseAPI = /** @class */ (function () {
263
260
  };
264
261
  return [4 /*yield*/, axios_1.default.request(options)];
265
262
  case 1:
266
- response = _b.sent();
267
- _a = response.data, accessToken = _a.accessToken, permissions = _a.permissions;
263
+ response = _a.sent();
264
+ accessToken = response.data.accessToken;
268
265
  this.configuration.username = username;
269
266
  this.configuration.accessToken = "Bearer ".concat(accessToken);
270
- this.permissions = permissions;
271
267
  refreshToken = this.extractRefreshToken(response);
272
268
  this.configuration.refreshToken = refreshToken;
273
269
  return [2 /*return*/];
@@ -277,13 +273,13 @@ var BaseAPI = /** @class */ (function () {
277
273
  };
278
274
  BaseAPI.prototype.refreshTokenInternal = function () {
279
275
  return __awaiter(this, void 0, void 0, function () {
280
- var _a, username, refreshToken, options, response;
276
+ var _a, username, refreshToken, options, accessToken;
281
277
  return __generator(this, function (_b) {
282
278
  switch (_b.label) {
283
279
  case 0:
284
280
  _a = this.configuration, username = _a.username, refreshToken = _a.refreshToken;
285
281
  if (!username || !refreshToken) {
286
- throw new Error('Failed to refresh token.');
282
+ return [2 /*return*/, ''];
287
283
  }
288
284
  options = {
289
285
  method: 'POST',
@@ -297,8 +293,8 @@ var BaseAPI = /** @class */ (function () {
297
293
  };
298
294
  return [4 /*yield*/, axios_1.default.request(options)];
299
295
  case 1:
300
- response = _b.sent();
301
- return [2 /*return*/, response.data];
296
+ accessToken = (_b.sent()).data.accessToken;
297
+ return [2 /*return*/, accessToken];
302
298
  }
303
299
  });
304
300
  });
@@ -318,27 +314,26 @@ var BaseAPI = /** @class */ (function () {
318
314
  axios.interceptors.response.use(function (res) {
319
315
  return res;
320
316
  }, function (err) { return __awaiter(_this, void 0, void 0, function () {
321
- var originalConfig, _a, tokenString, permissions, accessToken, _error_1, _b, tokenString, permissions, accessToken, _error_2;
322
- return __generator(this, function (_c) {
323
- switch (_c.label) {
317
+ var originalConfig, tokenString, accessToken, _error_1, tokenString, accessToken, _error_2;
318
+ return __generator(this, function (_a) {
319
+ switch (_a.label) {
324
320
  case 0:
325
321
  originalConfig = err.config;
326
322
  if (!err.response) return [3 /*break*/, 5];
327
323
  if (!(err.response.status === 401 && !originalConfig._retry)) return [3 /*break*/, 4];
328
324
  originalConfig._retry = true;
329
- _c.label = 1;
325
+ _a.label = 1;
330
326
  case 1:
331
- _c.trys.push([1, 3, , 4]);
327
+ _a.trys.push([1, 3, , 4]);
332
328
  return [4 /*yield*/, this.refreshTokenInternal()];
333
329
  case 2:
334
- _a = _c.sent(), tokenString = _a.accessToken, permissions = _a.permissions;
330
+ tokenString = _a.sent();
335
331
  accessToken = "Bearer ".concat(tokenString);
336
- this.permissions = permissions;
337
332
  originalConfig.headers['Authorization'] = "Bearer ".concat(accessToken);
338
333
  this.configuration.accessToken = accessToken;
339
334
  return [2 /*return*/, axios.request(originalConfig)];
340
335
  case 3:
341
- _error_1 = _c.sent();
336
+ _error_1 = _a.sent();
342
337
  if (_error_1.response && _error_1.response.data) {
343
338
  return [2 /*return*/, Promise.reject(_error_1.response.data)];
344
339
  }
@@ -354,20 +349,19 @@ var BaseAPI = /** @class */ (function () {
354
349
  && originalConfig.headers.hasOwnProperty('Authorization')
355
350
  && _retry_count < 4)) return [3 /*break*/, 9];
356
351
  _retry_count++;
357
- _c.label = 6;
352
+ _a.label = 6;
358
353
  case 6:
359
- _c.trys.push([6, 8, , 9]);
354
+ _a.trys.push([6, 8, , 9]);
360
355
  return [4 /*yield*/, this.refreshTokenInternal()];
361
356
  case 7:
362
- _b = _c.sent(), tokenString = _b.accessToken, permissions = _b.permissions;
357
+ tokenString = _a.sent();
363
358
  accessToken = "Bearer ".concat(tokenString);
364
- this.permissions = permissions;
365
359
  _retry = true;
366
360
  originalConfig.headers['Authorization'] = accessToken;
367
361
  this.configuration.accessToken = accessToken;
368
362
  return [2 /*return*/, axios.request(__assign({}, originalConfig))];
369
363
  case 8:
370
- _error_2 = _c.sent();
364
+ _error_2 = _a.sent();
371
365
  if (_error_2.response && _error_2.response.data) {
372
366
  return [2 /*return*/, Promise.reject(_error_2.response.data)];
373
367
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emilgroup/auth-sdk-node",
3
- "version": "1.12.1-beta.1",
3
+ "version": "1.12.1",
4
4
  "description": "OpenAPI client for @emilgroup/auth-sdk-node",
5
5
  "author": "OpenAPI-Generator Contributors",
6
6
  "keywords": [