@emilgroup/payment-sdk 1.13.1-beta.125 → 1.13.1-beta.126

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/payment-sdk@1.13.1-beta.125 --save
20
+ npm install @emilgroup/payment-sdk@1.13.1-beta.126 --save
21
21
  ```
22
22
  or
23
23
  ```
24
- yarn add @emilgroup/payment-sdk@1.13.1-beta.125
24
+ yarn add @emilgroup/payment-sdk@1.13.1-beta.126
25
25
  ```
26
26
 
27
27
  And then you can import `PaymentsApi`.
package/base.ts CHANGED
@@ -34,23 +34,12 @@ export const COLLECTION_FORMATS = {
34
34
 
35
35
  export interface LoginClass {
36
36
  accessToken: string;
37
- permissions: string;
38
- }
39
-
40
- export interface SwitchWorkspaceRequest {
41
- username: string;
42
- targetWorkspace: string;
43
- }
44
-
45
- export interface SwitchWorkspaceResponseClass {
46
- accessToken: string;
47
- permissions: string;
37
+ permissions: Array<string>;
48
38
  }
49
39
 
50
40
  export enum Environment {
51
41
  Production = 'https://apiv2.emil.de',
52
42
  Test = 'https://apiv2-test.emil.de',
53
- Staging = 'https://apiv2-staging.emil.de',
54
43
  Development = 'https://apiv2-dev.emil.de',
55
44
  ProductionZurich = 'https://eu-central-2.apiv2.emil.de',
56
45
  }
@@ -75,7 +64,6 @@ export interface RequestArgs {
75
64
  interface TokenData {
76
65
  accessToken?: string;
77
66
  username?: string;
78
- permissions?: string;
79
67
  }
80
68
 
81
69
  const NETWORK_ERROR_MESSAGE = "Network Error";
@@ -97,14 +85,9 @@ export class BaseAPI {
97
85
  this.loadTokenData();
98
86
 
99
87
  if (configuration) {
100
- const { accessToken } = this.tokenData;
101
88
  this.configuration = configuration;
102
89
  this.basePath = configuration.basePath || this.basePath;
103
-
104
- // Use config token if provided, otherwise use tokenData token
105
- const configToken = this.configuration.accessToken;
106
- const storedToken = accessToken ? `Bearer ${accessToken}` : '';
107
- this.configuration.accessToken = configToken || storedToken;
90
+ this.configuration.accessToken = this.tokenData.accessToken ? `Bearer ${this.tokenData.accessToken}` : '';
108
91
  } else {
109
92
  const { accessToken, username } = this.tokenData;
110
93
 
@@ -126,15 +109,7 @@ export class BaseAPI {
126
109
  this.configuration.basePath = path;
127
110
  }
128
111
 
129
- getPermissions(): Array<string> {
130
- if (!this.tokenData?.permissions) {
131
- return [];
132
- }
133
-
134
- return this.tokenData.permissions.split(',');
135
- }
136
-
137
- async authorize(username: string, password: string, targetWorkspace?: string): Promise<void> {
112
+ async authorize(username: string, password: string): Promise<void> {
138
113
  const options: AxiosRequestConfig = {
139
114
  method: 'POST',
140
115
  url: `${this.configuration.basePath}/authservice/v1/login`,
@@ -148,70 +123,25 @@ export class BaseAPI {
148
123
 
149
124
  const response = await globalAxios.request<LoginClass>(options);
150
125
 
151
- const { data: { accessToken, permissions } } = response;
126
+ const { data: { accessToken } } = response;
152
127
 
153
128
  this.configuration.username = username;
154
129
  this.configuration.accessToken = `Bearer ${accessToken}`;
155
130
  this.tokenData.username = username;
156
131
  this.tokenData.accessToken = accessToken;
157
- this.tokenData.permissions = permissions;
158
-
159
- // Switch workspace if provided
160
- if (targetWorkspace) {
161
- await this.switchWorkspace(targetWorkspace);
162
- } else {
163
- // Only store if no workspace switch (since switchWorkspace will store after switching)
164
- this.storeTokenData({
165
- ...this.tokenData
166
- });
167
- }
168
- }
169
-
170
- async switchWorkspace(targetWorkspace: string): Promise<void> {
171
- const options: AxiosRequestConfig = {
172
- method: 'POST',
173
- url: `${this.configuration.basePath}/authservice/v1/workspaces/switch`,
174
- headers: {
175
- 'Content-Type': 'application/json',
176
- 'Authorization': `Bearer ${this.configuration.accessToken}`,
177
- },
178
- data: {
179
- username: this.configuration.username,
180
- targetWorkspace,
181
- } as SwitchWorkspaceRequest,
182
- withCredentials: true,
183
- };
184
-
185
- const response = await globalAxios.request<SwitchWorkspaceResponseClass>(options);
186
-
187
- const { data: { accessToken, permissions } } = response;
188
-
189
- this.configuration.accessToken = `Bearer ${accessToken}`;
190
- this.tokenData.accessToken = accessToken;
191
- this.tokenData.permissions = permissions;
192
132
 
193
133
  this.storeTokenData({
194
134
  ...this.tokenData
195
135
  });
196
136
  }
197
137
 
198
- async refreshTokenInternal(): Promise<LoginClass> {
138
+ async refreshTokenInternal(): Promise<string> {
199
139
  const { username } = this.configuration;
200
140
 
201
141
  if (!username) {
202
- throw new Error('Failed to refresh token.');
142
+ return '';
203
143
  }
204
144
 
205
- const refreshTokenAxios = globalAxios.create()
206
- refreshTokenAxios.interceptors.response.use(response => {
207
- const { permissions } = response.data;
208
-
209
- this.tokenData.permissions = permissions;
210
- this.storeTokenData(this.tokenData);
211
-
212
- return response;
213
- })
214
-
215
145
  const options: AxiosRequestConfig = {
216
146
  method: 'POST',
217
147
  url: `${this.configuration.basePath}/authservice/v1/refresh-token`,
@@ -222,8 +152,9 @@ export class BaseAPI {
222
152
  withCredentials: true,
223
153
  };
224
154
 
225
- const response = await refreshTokenAxios.request<LoginClass>(options);
226
- return response.data;
155
+ const { data: { accessToken } } = await globalAxios.request<LoginClass>(options);
156
+
157
+ return accessToken;
227
158
  }
228
159
 
229
160
  private storeTokenData(tokenData?: TokenData) {
@@ -257,9 +188,8 @@ export class BaseAPI {
257
188
  && !originalConfig._retry) {
258
189
  originalConfig._retry = true;
259
190
  try {
260
- const { accessToken: tokenString, permissions } = await this.refreshTokenInternal();
191
+ let tokenString = await this.refreshTokenInternal();
261
192
  const accessToken = `Bearer ${tokenString}`;
262
- this.tokenData.permissions = permissions;
263
193
 
264
194
  delete originalConfig.headers['Authorization']
265
195
 
@@ -284,9 +214,8 @@ export class BaseAPI {
284
214
  ) {
285
215
  _retry_count++;
286
216
  try {
287
- const { accessToken: tokenString, permissions } = await this.refreshTokenInternal();
217
+ let tokenString = await this.refreshTokenInternal();
288
218
  const accessToken = `Bearer ${tokenString}`;
289
- this.tokenData.permissions = permissions;
290
219
 
291
220
  _retry = true;
292
221
  originalConfig.headers['Authorization'] = accessToken;
@@ -319,7 +248,7 @@ export class BaseAPI {
319
248
  * @extends {Error}
320
249
  */
321
250
  export class RequiredError extends Error {
322
- override name: "RequiredError" = "RequiredError";
251
+ name: "RequiredError" = "RequiredError";
323
252
  constructor(public field: string, msg?: string) {
324
253
  super(msg);
325
254
  }
package/common.ts CHANGED
@@ -65,7 +65,7 @@ export const setBearerAuthToObject = async function (object: any, configuration?
65
65
  const accessToken = typeof configuration.accessToken === 'function'
66
66
  ? await configuration.accessToken()
67
67
  : await configuration.accessToken;
68
- object["Authorization"] = configuration.getBearerToken(accessToken);
68
+ object["Authorization"] = "Bearer " + accessToken;
69
69
  }
70
70
  }
71
71
 
@@ -78,7 +78,7 @@ export const setOAuthToObject = async function (object: any, name: string, scope
78
78
  const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
79
79
  ? await configuration.accessToken(name, scopes)
80
80
  : await configuration.accessToken;
81
- object["Authorization"] = configuration.getBearerToken(localVarAccessTokenValue);
81
+ object["Authorization"] = "Bearer " + localVarAccessTokenValue;
82
82
  }
83
83
  }
84
84
 
package/configuration.ts CHANGED
@@ -98,13 +98,4 @@ export class Configuration {
98
98
  const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
99
99
  return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
100
100
  }
101
-
102
- /**
103
- * Returns "Bearer" token.
104
- * @param token - access token.
105
- * @return Bearer token.
106
- */
107
- public getBearerToken(token?: string): string {
108
- return ('' + token).startsWith("Bearer") ? token : "Bearer " + token;
109
- }
110
101
  }
package/dist/base.d.ts CHANGED
@@ -24,20 +24,11 @@ export declare const COLLECTION_FORMATS: {
24
24
  };
25
25
  export interface LoginClass {
26
26
  accessToken: string;
27
- permissions: string;
28
- }
29
- export interface SwitchWorkspaceRequest {
30
- username: string;
31
- targetWorkspace: string;
32
- }
33
- export interface SwitchWorkspaceResponseClass {
34
- accessToken: string;
35
- permissions: string;
27
+ permissions: Array<string>;
36
28
  }
37
29
  export declare enum Environment {
38
30
  Production = "https://apiv2.emil.de",
39
31
  Test = "https://apiv2-test.emil.de",
40
- Staging = "https://apiv2-staging.emil.de",
41
32
  Development = "https://apiv2-dev.emil.de",
42
33
  ProductionZurich = "https://eu-central-2.apiv2.emil.de"
43
34
  }
@@ -64,10 +55,8 @@ export declare class BaseAPI {
64
55
  constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance);
65
56
  selectEnvironment(env: Environment): void;
66
57
  selectBasePath(path: string): void;
67
- getPermissions(): Array<string>;
68
- authorize(username: string, password: string, targetWorkspace?: string): Promise<void>;
69
- switchWorkspace(targetWorkspace: string): Promise<void>;
70
- refreshTokenInternal(): Promise<LoginClass>;
58
+ authorize(username: string, password: string): Promise<void>;
59
+ refreshTokenInternal(): Promise<string>;
71
60
  private storeTokenData;
72
61
  loadTokenData(): void;
73
62
  cleanTokenData(): void;
package/dist/base.js CHANGED
@@ -99,7 +99,6 @@ var Environment;
99
99
  (function (Environment) {
100
100
  Environment["Production"] = "https://apiv2.emil.de";
101
101
  Environment["Test"] = "https://apiv2-test.emil.de";
102
- Environment["Staging"] = "https://apiv2-staging.emil.de";
103
102
  Environment["Development"] = "https://apiv2-dev.emil.de";
104
103
  Environment["ProductionZurich"] = "https://eu-central-2.apiv2.emil.de";
105
104
  })(Environment = exports.Environment || (exports.Environment = {}));
@@ -124,13 +123,9 @@ var BaseAPI = /** @class */ (function () {
124
123
  this.axios = axios;
125
124
  this.loadTokenData();
126
125
  if (configuration) {
127
- var accessToken = this.tokenData.accessToken;
128
126
  this.configuration = configuration;
129
127
  this.basePath = configuration.basePath || this.basePath;
130
- // Use config token if provided, otherwise use tokenData token
131
- var configToken = this.configuration.accessToken;
132
- var storedToken = accessToken ? "Bearer ".concat(accessToken) : '';
133
- this.configuration.accessToken = configToken || storedToken;
128
+ this.configuration.accessToken = this.tokenData.accessToken ? "Bearer ".concat(this.tokenData.accessToken) : '';
134
129
  }
135
130
  else {
136
131
  var _a = this.tokenData, accessToken = _a.accessToken, username = _a.username;
@@ -148,18 +143,11 @@ var BaseAPI = /** @class */ (function () {
148
143
  BaseAPI.prototype.selectBasePath = function (path) {
149
144
  this.configuration.basePath = path;
150
145
  };
151
- BaseAPI.prototype.getPermissions = function () {
152
- var _a;
153
- if (!((_a = this.tokenData) === null || _a === void 0 ? void 0 : _a.permissions)) {
154
- return [];
155
- }
156
- return this.tokenData.permissions.split(',');
157
- };
158
- BaseAPI.prototype.authorize = function (username, password, targetWorkspace) {
146
+ BaseAPI.prototype.authorize = function (username, password) {
159
147
  return __awaiter(this, void 0, void 0, function () {
160
- var options, response, _a, accessToken, permissions;
161
- return __generator(this, function (_b) {
162
- switch (_b.label) {
148
+ var options, response, accessToken;
149
+ return __generator(this, function (_a) {
150
+ switch (_a.label) {
163
151
  case 0:
164
152
  options = {
165
153
  method: 'POST',
@@ -173,53 +161,12 @@ var BaseAPI = /** @class */ (function () {
173
161
  };
174
162
  return [4 /*yield*/, axios_1.default.request(options)];
175
163
  case 1:
176
- response = _b.sent();
177
- _a = response.data, accessToken = _a.accessToken, permissions = _a.permissions;
164
+ response = _a.sent();
165
+ accessToken = response.data.accessToken;
178
166
  this.configuration.username = username;
179
167
  this.configuration.accessToken = "Bearer ".concat(accessToken);
180
168
  this.tokenData.username = username;
181
169
  this.tokenData.accessToken = accessToken;
182
- this.tokenData.permissions = permissions;
183
- if (!targetWorkspace) return [3 /*break*/, 3];
184
- return [4 /*yield*/, this.switchWorkspace(targetWorkspace)];
185
- case 2:
186
- _b.sent();
187
- return [3 /*break*/, 4];
188
- case 3:
189
- // Only store if no workspace switch (since switchWorkspace will store after switching)
190
- this.storeTokenData(__assign({}, this.tokenData));
191
- _b.label = 4;
192
- case 4: return [2 /*return*/];
193
- }
194
- });
195
- });
196
- };
197
- BaseAPI.prototype.switchWorkspace = function (targetWorkspace) {
198
- return __awaiter(this, void 0, void 0, function () {
199
- var options, response, _a, accessToken, permissions;
200
- return __generator(this, function (_b) {
201
- switch (_b.label) {
202
- case 0:
203
- options = {
204
- method: 'POST',
205
- url: "".concat(this.configuration.basePath, "/authservice/v1/workspaces/switch"),
206
- headers: {
207
- 'Content-Type': 'application/json',
208
- 'Authorization': "Bearer ".concat(this.configuration.accessToken),
209
- },
210
- data: {
211
- username: this.configuration.username,
212
- targetWorkspace: targetWorkspace,
213
- },
214
- withCredentials: true,
215
- };
216
- return [4 /*yield*/, axios_1.default.request(options)];
217
- case 1:
218
- response = _b.sent();
219
- _a = response.data, accessToken = _a.accessToken, permissions = _a.permissions;
220
- this.configuration.accessToken = "Bearer ".concat(accessToken);
221
- this.tokenData.accessToken = accessToken;
222
- this.tokenData.permissions = permissions;
223
170
  this.storeTokenData(__assign({}, this.tokenData));
224
171
  return [2 /*return*/];
225
172
  }
@@ -228,22 +175,14 @@ var BaseAPI = /** @class */ (function () {
228
175
  };
229
176
  BaseAPI.prototype.refreshTokenInternal = function () {
230
177
  return __awaiter(this, void 0, void 0, function () {
231
- var username, refreshTokenAxios, options, response;
232
- var _this = this;
178
+ var username, options, accessToken;
233
179
  return __generator(this, function (_a) {
234
180
  switch (_a.label) {
235
181
  case 0:
236
182
  username = this.configuration.username;
237
183
  if (!username) {
238
- throw new Error('Failed to refresh token.');
184
+ return [2 /*return*/, ''];
239
185
  }
240
- refreshTokenAxios = axios_1.default.create();
241
- refreshTokenAxios.interceptors.response.use(function (response) {
242
- var permissions = response.data.permissions;
243
- _this.tokenData.permissions = permissions;
244
- _this.storeTokenData(_this.tokenData);
245
- return response;
246
- });
247
186
  options = {
248
187
  method: 'POST',
249
188
  url: "".concat(this.configuration.basePath, "/authservice/v1/refresh-token"),
@@ -253,10 +192,10 @@ var BaseAPI = /** @class */ (function () {
253
192
  data: { username: username },
254
193
  withCredentials: true,
255
194
  };
256
- return [4 /*yield*/, refreshTokenAxios.request(options)];
195
+ return [4 /*yield*/, axios_1.default.request(options)];
257
196
  case 1:
258
- response = _a.sent();
259
- return [2 /*return*/, response.data];
197
+ accessToken = (_a.sent()).data.accessToken;
198
+ return [2 /*return*/, accessToken];
260
199
  }
261
200
  });
262
201
  });
@@ -282,23 +221,22 @@ var BaseAPI = /** @class */ (function () {
282
221
  axios.interceptors.response.use(function (res) {
283
222
  return res;
284
223
  }, function (err) { return __awaiter(_this, void 0, void 0, function () {
285
- var originalConfig, _a, tokenString, permissions, accessToken, _error_1, _b, tokenString, permissions, accessToken, _error_2;
286
- return __generator(this, function (_c) {
287
- switch (_c.label) {
224
+ var originalConfig, tokenString, accessToken, _error_1, tokenString, accessToken, _error_2;
225
+ return __generator(this, function (_a) {
226
+ switch (_a.label) {
288
227
  case 0:
289
228
  originalConfig = err.config;
290
229
  if (!(err.response && !(err.response instanceof XMLHttpRequest))) return [3 /*break*/, 5];
291
230
  if (!((err.response.status === 401 || err.response.status === 403)
292
231
  && !originalConfig._retry)) return [3 /*break*/, 4];
293
232
  originalConfig._retry = true;
294
- _c.label = 1;
233
+ _a.label = 1;
295
234
  case 1:
296
- _c.trys.push([1, 3, , 4]);
235
+ _a.trys.push([1, 3, , 4]);
297
236
  return [4 /*yield*/, this.refreshTokenInternal()];
298
237
  case 2:
299
- _a = _c.sent(), tokenString = _a.accessToken, permissions = _a.permissions;
238
+ tokenString = _a.sent();
300
239
  accessToken = "Bearer ".concat(tokenString);
301
- this.tokenData.permissions = permissions;
302
240
  delete originalConfig.headers['Authorization'];
303
241
  originalConfig.headers['Authorization'] = accessToken;
304
242
  this.configuration.accessToken = accessToken;
@@ -306,7 +244,7 @@ var BaseAPI = /** @class */ (function () {
306
244
  this.storeTokenData(this.tokenData);
307
245
  return [2 /*return*/, axios(originalConfig)];
308
246
  case 3:
309
- _error_1 = _c.sent();
247
+ _error_1 = _a.sent();
310
248
  if (_error_1.response && _error_1.response.data) {
311
249
  return [2 /*return*/, Promise.reject(_error_1.response.data)];
312
250
  }
@@ -317,14 +255,13 @@ var BaseAPI = /** @class */ (function () {
317
255
  && originalConfig.headers.hasOwnProperty('Authorization')
318
256
  && _retry_count < 4)) return [3 /*break*/, 9];
319
257
  _retry_count++;
320
- _c.label = 6;
258
+ _a.label = 6;
321
259
  case 6:
322
- _c.trys.push([6, 8, , 9]);
260
+ _a.trys.push([6, 8, , 9]);
323
261
  return [4 /*yield*/, this.refreshTokenInternal()];
324
262
  case 7:
325
- _b = _c.sent(), tokenString = _b.accessToken, permissions = _b.permissions;
263
+ tokenString = _a.sent();
326
264
  accessToken = "Bearer ".concat(tokenString);
327
- this.tokenData.permissions = permissions;
328
265
  _retry = true;
329
266
  originalConfig.headers['Authorization'] = accessToken;
330
267
  this.configuration.accessToken = accessToken;
@@ -332,7 +269,7 @@ var BaseAPI = /** @class */ (function () {
332
269
  this.storeTokenData(this.tokenData);
333
270
  return [2 /*return*/, axios.request(__assign({}, originalConfig))];
334
271
  case 8:
335
- _error_2 = _c.sent();
272
+ _error_2 = _a.sent();
336
273
  if (_error_2.response && _error_2.response.data) {
337
274
  return [2 /*return*/, Promise.reject(_error_2.response.data)];
338
275
  }
package/dist/common.js CHANGED
@@ -140,7 +140,7 @@ var setBearerAuthToObject = function (object, configuration) {
140
140
  _b.label = 4;
141
141
  case 4:
142
142
  accessToken = _a;
143
- object["Authorization"] = configuration.getBearerToken(accessToken);
143
+ object["Authorization"] = "Bearer " + accessToken;
144
144
  _b.label = 5;
145
145
  case 5: return [2 /*return*/];
146
146
  }
@@ -170,7 +170,7 @@ var setOAuthToObject = function (object, name, scopes, configuration) {
170
170
  _b.label = 4;
171
171
  case 4:
172
172
  localVarAccessTokenValue = _a;
173
- object["Authorization"] = configuration.getBearerToken(localVarAccessTokenValue);
173
+ object["Authorization"] = "Bearer " + localVarAccessTokenValue;
174
174
  _b.label = 5;
175
175
  case 5: return [2 /*return*/];
176
176
  }
@@ -80,10 +80,4 @@ export declare class Configuration {
80
80
  * @return True if the given MIME is JSON, false otherwise.
81
81
  */
82
82
  isJsonMime(mime: string): boolean;
83
- /**
84
- * Returns "Bearer" token.
85
- * @param token - access token.
86
- * @return Bearer token.
87
- */
88
- getBearerToken(token?: string): string;
89
83
  }
@@ -39,14 +39,6 @@ var Configuration = /** @class */ (function () {
39
39
  var jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
40
40
  return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
41
41
  };
42
- /**
43
- * Returns "Bearer" token.
44
- * @param token - access token.
45
- * @return Bearer token.
46
- */
47
- Configuration.prototype.getBearerToken = function (token) {
48
- return ('' + token).startsWith("Bearer") ? token : "Bearer " + token;
49
- };
50
42
  return Configuration;
51
43
  }());
52
44
  exports.Configuration = Configuration;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emilgroup/payment-sdk",
3
- "version": "1.13.1-beta.125",
3
+ "version": "1.13.1-beta.126",
4
4
  "description": "OpenAPI client for @emilgroup/payment-sdk",
5
5
  "author": "OpenAPI-Generator Contributors",
6
6
  "keywords": [
package/tsconfig.json CHANGED
@@ -5,7 +5,6 @@
5
5
  "module": "CommonJS",
6
6
  "noImplicitAny": true,
7
7
  "esModuleInterop": true,
8
- "noImplicitOverride": true,
9
8
  "outDir": "dist",
10
9
  "rootDir": ".",
11
10
  "lib": [