@emilgroup/payment-sdk-node 1.21.1-beta.123 → 1.21.1-beta.125

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-node@1.21.1-beta.123 --save
20
+ npm install @emilgroup/payment-sdk-node@1.21.1-beta.125 --save
21
21
  ```
22
22
  or
23
23
  ```
24
- yarn add @emilgroup/payment-sdk-node@1.21.1-beta.123
24
+ yarn add @emilgroup/payment-sdk-node@1.21.1-beta.125
25
25
  ```
26
26
 
27
27
  And then you can import `PaymentsApi`.
package/base.ts CHANGED
@@ -41,23 +41,12 @@ export const COLLECTION_FORMATS = {
41
41
 
42
42
  export interface LoginClass {
43
43
  accessToken: string;
44
- permissions: string;
45
- }
46
-
47
- export interface SwitchWorkspaceRequest {
48
- username: string;
49
- targetWorkspace: string;
50
- }
51
-
52
- export interface SwitchWorkspaceResponseClass {
53
- accessToken: string;
54
- permissions: string;
44
+ permissions: Array<string>;
55
45
  }
56
46
 
57
47
  export enum Environment {
58
48
  Production = 'https://apiv2.emil.de',
59
49
  Test = 'https://apiv2-test.emil.de',
60
- Staging = 'https://apiv2-staging.emil.de',
61
50
  Development = 'https://apiv2-dev.emil.de',
62
51
  ProductionZurich = 'https://eu-central-2.apiv2.emil.de',
63
52
  }
@@ -104,13 +93,13 @@ export class BaseAPI {
104
93
  this.attachInterceptor(axios);
105
94
  }
106
95
 
107
- async initialize(env: Environment = Environment.Production, targetWorkspace?: string) {
96
+ async initialize(env: Environment = Environment.Production) {
108
97
  this.configuration.basePath = env;
109
98
 
110
99
  await this.loadCredentials();
111
100
 
112
101
  if (this.username) {
113
- await this.authorize(this.username, this.password, targetWorkspace);
102
+ await this.authorize(this.username, this.password);
114
103
  this.password = null; // to avoid keeping password loaded in memory.
115
104
  }
116
105
  }
@@ -160,7 +149,7 @@ export class BaseAPI {
160
149
  this.configuration.basePath = env;
161
150
  }
162
151
 
163
- async authorize(username: string, password: string, targetWorkspace?: string): Promise<void> {
152
+ async authorize(username: string, password: string): Promise<void> {
164
153
  const options: AxiosRequestConfig = {
165
154
  method: 'POST',
166
155
  url: `${this.configuration.basePath}/authservice/v1/login`,
@@ -180,38 +169,6 @@ export class BaseAPI {
180
169
 
181
170
  const refreshToken = this.extractRefreshToken(response)
182
171
  this.configuration.refreshToken = refreshToken;
183
-
184
- // Switch workspace if provided
185
- if (targetWorkspace) {
186
- await this.switchWorkspace(targetWorkspace);
187
- }
188
- }
189
-
190
- async switchWorkspace(targetWorkspace: string): Promise<void> {
191
- const options: AxiosRequestConfig = {
192
- method: 'POST',
193
- url: `${this.configuration.basePath}/authservice/v1/workspaces/switch`,
194
- headers: {
195
- 'Content-Type': 'application/json',
196
- 'Authorization': `Bearer ${this.configuration.accessToken}`,
197
- 'Cookie': this.configuration.refreshToken,
198
- },
199
- data: {
200
- username: this.configuration.username,
201
- targetWorkspace,
202
- } as SwitchWorkspaceRequest,
203
- withCredentials: true,
204
- };
205
-
206
- const response = await globalAxios.request<SwitchWorkspaceResponseClass>(options);
207
-
208
- const { data: { accessToken } } = response;
209
- this.configuration.accessToken = `Bearer ${accessToken}`;
210
-
211
- const refreshToken = this.extractRefreshToken(response);
212
- if (refreshToken) {
213
- this.configuration.refreshToken = refreshToken;
214
- }
215
172
  }
216
173
 
217
174
  async refreshTokenInternal(): Promise<string> {
@@ -267,7 +224,7 @@ export class BaseAPI {
267
224
  const tokenString = await this.refreshTokenInternal();
268
225
  const accessToken = `Bearer ${tokenString}`;
269
226
 
270
- originalConfig.headers['Authorization'] = accessToken;
227
+ originalConfig.headers['Authorization'] = `Bearer ${accessToken}`
271
228
 
272
229
  this.configuration.accessToken = accessToken;
273
230
 
@@ -320,7 +277,7 @@ export class BaseAPI {
320
277
  * @extends {Error}
321
278
  */
322
279
  export class RequiredError extends Error {
323
- override name: "RequiredError" = "RequiredError";
280
+ name: "RequiredError" = "RequiredError";
324
281
  constructor(public field: string, msg?: string) {
325
282
  super(msg);
326
283
  }
package/common.ts CHANGED
@@ -66,7 +66,7 @@ export const setBearerAuthToObject = async function (object: any, configuration?
66
66
  const accessToken = typeof configuration.accessToken === 'function'
67
67
  ? await configuration.accessToken()
68
68
  : await configuration.accessToken;
69
- object["Authorization"] = configuration.getBearerToken(accessToken);
69
+ object["Authorization"] = "Bearer " + accessToken;
70
70
  }
71
71
  }
72
72
 
@@ -79,7 +79,7 @@ export const setOAuthToObject = async function (object: any, name: string, scope
79
79
  const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
80
80
  ? await configuration.accessToken(name, scopes)
81
81
  : await configuration.accessToken;
82
- object["Authorization"] = configuration.getBearerToken(localVarAccessTokenValue);
82
+ object["Authorization"] = "Bearer " + localVarAccessTokenValue;
83
83
  }
84
84
  }
85
85
 
package/configuration.ts CHANGED
@@ -106,13 +106,4 @@ export class Configuration {
106
106
  const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
107
107
  return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
108
108
  }
109
-
110
- /**
111
- * Returns "Bearer" token.
112
- * @param token - access token.
113
- * @return Bearer token.
114
- */
115
- public getBearerToken(token?: string): string {
116
- return ('' + token).startsWith("Bearer") ? token : "Bearer " + token;
117
- }
118
109
  }
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
  }
@@ -63,13 +54,12 @@ export declare class BaseAPI {
63
54
  private username?;
64
55
  private password?;
65
56
  constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance);
66
- initialize(env?: Environment, targetWorkspace?: string): Promise<void>;
57
+ initialize(env?: Environment): Promise<void>;
67
58
  private loadCredentials;
68
59
  private readConfigFile;
69
60
  private readEnvVariables;
70
61
  selectEnvironment(env: Environment): void;
71
- authorize(username: string, password: string, targetWorkspace?: string): Promise<void>;
72
- switchWorkspace(targetWorkspace: string): Promise<void>;
62
+ authorize(username: string, password: string): Promise<void>;
73
63
  refreshTokenInternal(): Promise<string>;
74
64
  private extractRefreshToken;
75
65
  getConfiguration(): Configuration;
package/dist/base.js CHANGED
@@ -129,7 +129,6 @@ var Environment;
129
129
  (function (Environment) {
130
130
  Environment["Production"] = "https://apiv2.emil.de";
131
131
  Environment["Test"] = "https://apiv2-test.emil.de";
132
- Environment["Staging"] = "https://apiv2-staging.emil.de";
133
132
  Environment["Development"] = "https://apiv2-dev.emil.de";
134
133
  Environment["ProductionZurich"] = "https://eu-central-2.apiv2.emil.de";
135
134
  })(Environment = exports.Environment || (exports.Environment = {}));
@@ -162,7 +161,7 @@ var BaseAPI = /** @class */ (function () {
162
161
  }
163
162
  this.attachInterceptor(axios);
164
163
  }
165
- BaseAPI.prototype.initialize = function (env, targetWorkspace) {
164
+ BaseAPI.prototype.initialize = function (env) {
166
165
  if (env === void 0) { env = Environment.Production; }
167
166
  return __awaiter(this, void 0, void 0, function () {
168
167
  return __generator(this, function (_a) {
@@ -173,7 +172,7 @@ var BaseAPI = /** @class */ (function () {
173
172
  case 1:
174
173
  _a.sent();
175
174
  if (!this.username) return [3 /*break*/, 3];
176
- return [4 /*yield*/, this.authorize(this.username, this.password, targetWorkspace)];
175
+ return [4 /*yield*/, this.authorize(this.username, this.password)];
177
176
  case 2:
178
177
  _a.sent();
179
178
  this.password = null; // to avoid keeping password loaded in memory.
@@ -243,7 +242,7 @@ var BaseAPI = /** @class */ (function () {
243
242
  BaseAPI.prototype.selectEnvironment = function (env) {
244
243
  this.configuration.basePath = env;
245
244
  };
246
- BaseAPI.prototype.authorize = function (username, password, targetWorkspace) {
245
+ BaseAPI.prototype.authorize = function (username, password) {
247
246
  return __awaiter(this, void 0, void 0, function () {
248
247
  var options, response, accessToken, refreshToken;
249
248
  return __generator(this, function (_a) {
@@ -267,45 +266,6 @@ var BaseAPI = /** @class */ (function () {
267
266
  this.configuration.accessToken = "Bearer ".concat(accessToken);
268
267
  refreshToken = this.extractRefreshToken(response);
269
268
  this.configuration.refreshToken = refreshToken;
270
- if (!targetWorkspace) return [3 /*break*/, 3];
271
- return [4 /*yield*/, this.switchWorkspace(targetWorkspace)];
272
- case 2:
273
- _a.sent();
274
- _a.label = 3;
275
- case 3: return [2 /*return*/];
276
- }
277
- });
278
- });
279
- };
280
- BaseAPI.prototype.switchWorkspace = function (targetWorkspace) {
281
- return __awaiter(this, void 0, void 0, function () {
282
- var options, response, accessToken, refreshToken;
283
- return __generator(this, function (_a) {
284
- switch (_a.label) {
285
- case 0:
286
- options = {
287
- method: 'POST',
288
- url: "".concat(this.configuration.basePath, "/authservice/v1/workspaces/switch"),
289
- headers: {
290
- 'Content-Type': 'application/json',
291
- 'Authorization': "Bearer ".concat(this.configuration.accessToken),
292
- 'Cookie': this.configuration.refreshToken,
293
- },
294
- data: {
295
- username: this.configuration.username,
296
- targetWorkspace: targetWorkspace,
297
- },
298
- withCredentials: true,
299
- };
300
- return [4 /*yield*/, axios_1.default.request(options)];
301
- case 1:
302
- response = _a.sent();
303
- accessToken = response.data.accessToken;
304
- this.configuration.accessToken = "Bearer ".concat(accessToken);
305
- refreshToken = this.extractRefreshToken(response);
306
- if (refreshToken) {
307
- this.configuration.refreshToken = refreshToken;
308
- }
309
269
  return [2 /*return*/];
310
270
  }
311
271
  });
@@ -369,7 +329,7 @@ var BaseAPI = /** @class */ (function () {
369
329
  case 2:
370
330
  tokenString = _a.sent();
371
331
  accessToken = "Bearer ".concat(tokenString);
372
- originalConfig.headers['Authorization'] = accessToken;
332
+ originalConfig.headers['Authorization'] = "Bearer ".concat(accessToken);
373
333
  this.configuration.accessToken = accessToken;
374
334
  return [2 /*return*/, axios.request(originalConfig)];
375
335
  case 3:
package/dist/common.js CHANGED
@@ -141,7 +141,7 @@ var setBearerAuthToObject = function (object, configuration) {
141
141
  _b.label = 4;
142
142
  case 4:
143
143
  accessToken = _a;
144
- object["Authorization"] = configuration.getBearerToken(accessToken);
144
+ object["Authorization"] = "Bearer " + accessToken;
145
145
  _b.label = 5;
146
146
  case 5: return [2 /*return*/];
147
147
  }
@@ -171,7 +171,7 @@ var setOAuthToObject = function (object, name, scopes, configuration) {
171
171
  _b.label = 4;
172
172
  case 4:
173
173
  localVarAccessTokenValue = _a;
174
- object["Authorization"] = configuration.getBearerToken(localVarAccessTokenValue);
174
+ object["Authorization"] = "Bearer " + localVarAccessTokenValue;
175
175
  _b.label = 5;
176
176
  case 5: return [2 /*return*/];
177
177
  }
@@ -87,10 +87,4 @@ export declare class Configuration {
87
87
  * @return True if the given MIME is JSON, false otherwise.
88
88
  */
89
89
  isJsonMime(mime: string): boolean;
90
- /**
91
- * Returns "Bearer" token.
92
- * @param token - access token.
93
- * @return Bearer token.
94
- */
95
- getBearerToken(token?: string): string;
96
90
  }
@@ -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-node",
3
- "version": "1.21.1-beta.123",
3
+ "version": "1.21.1-beta.125",
4
4
  "description": "OpenAPI client for @emilgroup/payment-sdk-node",
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": [