@emilgroup/migration-sdk 0.10.1-beta.13 → 0.10.1-beta.2

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/migration-sdk@0.10.1-beta.13 --save
20
+ npm install @emilgroup/migration-sdk@0.10.1-beta.2 --save
21
21
  ```
22
22
  or
23
23
  ```
24
- yarn add @emilgroup/migration-sdk@0.10.1-beta.13
24
+ yarn add @emilgroup/migration-sdk@0.10.1-beta.2
25
25
  ```
26
26
 
27
27
  And then you can import ``.
package/base.ts CHANGED
@@ -93,14 +93,10 @@ export class BaseAPI {
93
93
  this.configuration = configuration;
94
94
  this.basePath = configuration.basePath || this.basePath;
95
95
 
96
- if (configuration.cookieAuth) {
97
- this.useCookieAuth();
98
- } else {
99
- // Use config token if provided, otherwise use tokenData token
100
- const configToken = this.configuration.accessToken;
101
- const storedToken = accessToken ? `Bearer ${accessToken}` : '';
102
- this.configuration.accessToken = configToken || storedToken;
103
- }
96
+ // Use config token if provided, otherwise use tokenData token
97
+ const configToken = this.configuration.accessToken;
98
+ const storedToken = accessToken ? `Bearer ${accessToken}` : '';
99
+ this.configuration.accessToken = configToken || storedToken;
104
100
  } else {
105
101
  const { accessToken, username } = this.tokenData;
106
102
 
@@ -114,12 +110,6 @@ export class BaseAPI {
114
110
  this.attachInterceptor(axios);
115
111
  }
116
112
 
117
- // Cookie mode: the browser sends the HttpOnly access cookie, so no token is read from storage.
118
- private useCookieAuth() {
119
- this.configuration.username = this.configuration.username || this.tokenData.username;
120
- this.configuration.baseOptions = { ...this.configuration.baseOptions, withCredentials: true };
121
- }
122
-
123
113
  selectEnvironment(env: Environment) {
124
114
  this.selectBasePath(env);
125
115
  }
@@ -153,12 +143,10 @@ export class BaseAPI {
153
143
  const { data: { accessToken, permissions } } = response;
154
144
 
155
145
  this.configuration.username = username;
146
+ this.configuration.accessToken = `Bearer ${accessToken}`;
156
147
  this.tokenData.username = username;
148
+ this.tokenData.accessToken = accessToken;
157
149
  this.tokenData.permissions = permissions;
158
- if (!this.configuration.cookieAuth) {
159
- this.configuration.accessToken = `Bearer ${accessToken}`;
160
- this.tokenData.accessToken = accessToken;
161
- }
162
150
 
163
151
  }
164
152
 
@@ -196,11 +184,6 @@ export class BaseAPI {
196
184
 
197
185
  private storeTokenData(tokenData?: TokenData) {
198
186
  if (typeof window !== 'undefined') {
199
- if (tokenData && this.configuration?.cookieAuth) {
200
- // Cookie mode saves who is logged in, never the token; a token saved by apps not yet migrated stays.
201
- const { username, permissions } = tokenData;
202
- tokenData = { ...(defaultStorage().get<TokenData>(TOKEN_DATA) || {}), username, permissions };
203
- }
204
187
  defaultStorage().set<TokenData>(TOKEN_DATA, tokenData);
205
188
  }
206
189
  }
@@ -231,17 +214,15 @@ export class BaseAPI {
231
214
  originalConfig._retry = true;
232
215
  try {
233
216
  const { accessToken: tokenString, permissions } = await this.refreshTokenInternal();
217
+ const accessToken = `Bearer ${tokenString}`;
234
218
  this.tokenData.permissions = permissions;
235
219
 
236
220
  delete originalConfig.headers['Authorization']
237
221
 
238
- // In cookie mode the refresh reply renewed the access cookie, so retry without a header.
239
- if (!this.configuration.cookieAuth) {
240
- const accessToken = `Bearer ${tokenString}`;
241
- originalConfig.headers['Authorization'] = accessToken;
242
- this.configuration.accessToken = accessToken;
243
- this.tokenData.accessToken = tokenString;
244
- }
222
+ originalConfig.headers['Authorization'] = accessToken;
223
+
224
+ this.configuration.accessToken = accessToken;
225
+ this.tokenData.accessToken = tokenString;
245
226
 
246
227
  this.storeTokenData(this.tokenData);
247
228
 
package/configuration.ts CHANGED
@@ -21,7 +21,6 @@ export interface ConfigurationParameters {
21
21
  basePath?: string;
22
22
  baseOptions?: any;
23
23
  formDataCtor?: new () => any;
24
- cookieAuth?: boolean;
25
24
  }
26
25
 
27
26
  export class Configuration {
@@ -75,15 +74,6 @@ export class Configuration {
75
74
  */
76
75
  formDataCtor?: new () => any;
77
76
 
78
- /**
79
- * Authenticate with the HttpOnly access cookie instead of a stored token: every call sends credentials.
80
- * The browser holds one cookie, so use it with one logged-in account; log out through the auth service.
81
- *
82
- * @type {boolean}
83
- * @memberof Configuration
84
- */
85
- cookieAuth?: boolean;
86
-
87
77
  constructor(param: ConfigurationParameters = {}) {
88
78
  this.apiKey = param.apiKey;
89
79
  this.username = param.username;
@@ -92,7 +82,6 @@ export class Configuration {
92
82
  this.basePath = param.basePath;
93
83
  this.baseOptions = param.baseOptions;
94
84
  this.formDataCtor = param.formDataCtor;
95
- this.cookieAuth = param.cookieAuth;
96
85
  }
97
86
 
98
87
  /**
package/dist/base.d.ts CHANGED
@@ -55,7 +55,6 @@ export declare class BaseAPI {
55
55
  protected configuration: Configuration | undefined;
56
56
  private tokenData?;
57
57
  constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance);
58
- private useCookieAuth;
59
58
  selectEnvironment(env: Environment): void;
60
59
  selectBasePath(path: string): void;
61
60
  getPermissions(): Array<string>;
package/dist/base.js CHANGED
@@ -128,15 +128,10 @@ var BaseAPI = /** @class */ (function () {
128
128
  var accessToken = this.tokenData.accessToken;
129
129
  this.configuration = configuration;
130
130
  this.basePath = configuration.basePath || this.basePath;
131
- if (configuration.cookieAuth) {
132
- this.useCookieAuth();
133
- }
134
- else {
135
- // Use config token if provided, otherwise use tokenData token
136
- var configToken = this.configuration.accessToken;
137
- var storedToken = accessToken ? "Bearer ".concat(accessToken) : '';
138
- this.configuration.accessToken = configToken || storedToken;
139
- }
131
+ // Use config token if provided, otherwise use tokenData token
132
+ var configToken = this.configuration.accessToken;
133
+ var storedToken = accessToken ? "Bearer ".concat(accessToken) : '';
134
+ this.configuration.accessToken = configToken || storedToken;
140
135
  }
141
136
  else {
142
137
  var _a = this.tokenData, accessToken = _a.accessToken, username = _a.username;
@@ -148,11 +143,6 @@ var BaseAPI = /** @class */ (function () {
148
143
  }
149
144
  this.attachInterceptor(axios);
150
145
  }
151
- // Cookie mode: the browser sends the HttpOnly access cookie, so no token is read from storage.
152
- BaseAPI.prototype.useCookieAuth = function () {
153
- this.configuration.username = this.configuration.username || this.tokenData.username;
154
- this.configuration.baseOptions = __assign(__assign({}, this.configuration.baseOptions), { withCredentials: true });
155
- };
156
146
  BaseAPI.prototype.selectEnvironment = function (env) {
157
147
  this.selectBasePath(env);
158
148
  };
@@ -187,12 +177,10 @@ var BaseAPI = /** @class */ (function () {
187
177
  response = _b.sent();
188
178
  _a = response.data, accessToken = _a.accessToken, permissions = _a.permissions;
189
179
  this.configuration.username = username;
180
+ this.configuration.accessToken = "Bearer ".concat(accessToken);
190
181
  this.tokenData.username = username;
182
+ this.tokenData.accessToken = accessToken;
191
183
  this.tokenData.permissions = permissions;
192
- if (!this.configuration.cookieAuth) {
193
- this.configuration.accessToken = "Bearer ".concat(accessToken);
194
- this.tokenData.accessToken = accessToken;
195
- }
196
184
  return [2 /*return*/];
197
185
  }
198
186
  });
@@ -234,13 +222,7 @@ var BaseAPI = /** @class */ (function () {
234
222
  });
235
223
  };
236
224
  BaseAPI.prototype.storeTokenData = function (tokenData) {
237
- var _a;
238
225
  if (typeof window !== 'undefined') {
239
- if (tokenData && ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.cookieAuth)) {
240
- // Cookie mode saves who is logged in, never the token; a token saved by apps not yet migrated stays.
241
- var username = tokenData.username, permissions = tokenData.permissions;
242
- tokenData = __assign(__assign({}, ((0, common_1.defaultStorage)().get(TOKEN_DATA) || {})), { username: username, permissions: permissions });
243
- }
244
226
  (0, common_1.defaultStorage)().set(TOKEN_DATA, tokenData);
245
227
  }
246
228
  };
@@ -275,15 +257,12 @@ var BaseAPI = /** @class */ (function () {
275
257
  return [4 /*yield*/, this.refreshTokenInternal()];
276
258
  case 2:
277
259
  _a = _c.sent(), tokenString = _a.accessToken, permissions = _a.permissions;
260
+ accessToken = "Bearer ".concat(tokenString);
278
261
  this.tokenData.permissions = permissions;
279
262
  delete originalConfig.headers['Authorization'];
280
- // In cookie mode the refresh reply renewed the access cookie, so retry without a header.
281
- if (!this.configuration.cookieAuth) {
282
- accessToken = "Bearer ".concat(tokenString);
283
- originalConfig.headers['Authorization'] = accessToken;
284
- this.configuration.accessToken = accessToken;
285
- this.tokenData.accessToken = tokenString;
286
- }
263
+ originalConfig.headers['Authorization'] = accessToken;
264
+ this.configuration.accessToken = accessToken;
265
+ this.tokenData.accessToken = tokenString;
287
266
  this.storeTokenData(this.tokenData);
288
267
  return [2 /*return*/, axios(originalConfig)];
289
268
  case 3:
@@ -17,7 +17,6 @@ export interface ConfigurationParameters {
17
17
  basePath?: string;
18
18
  baseOptions?: any;
19
19
  formDataCtor?: new () => any;
20
- cookieAuth?: boolean;
21
20
  }
22
21
  export declare class Configuration {
23
22
  /**
@@ -69,14 +68,6 @@ export declare class Configuration {
69
68
  * @type {new () => FormData}
70
69
  */
71
70
  formDataCtor?: new () => any;
72
- /**
73
- * Authenticate with the HttpOnly access cookie instead of a stored token: every call sends credentials.
74
- * The browser holds one cookie, so use it with one logged-in account; log out through the auth service.
75
- *
76
- * @type {boolean}
77
- * @memberof Configuration
78
- */
79
- cookieAuth?: boolean;
80
71
  constructor(param?: ConfigurationParameters);
81
72
  /**
82
73
  * Check if the given MIME is a JSON MIME.
@@ -24,7 +24,6 @@ var Configuration = /** @class */ (function () {
24
24
  this.basePath = param.basePath;
25
25
  this.baseOptions = param.baseOptions;
26
26
  this.formDataCtor = param.formDataCtor;
27
- this.cookieAuth = param.cookieAuth;
28
27
  }
29
28
  /**
30
29
  * Check if the given MIME is a JSON MIME.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emilgroup/migration-sdk",
3
- "version": "0.10.1-beta.13",
3
+ "version": "0.10.1-beta.2",
4
4
  "description": "OpenAPI client for @emilgroup/migration-sdk",
5
5
  "author": "OpenAPI-Generator Contributors",
6
6
  "keywords": [