@emilgroup/payment-sdk 1.22.1-beta.81 → 1.22.1-beta.83

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.
Files changed (137) hide show
  1. package/.openapi-generator/FILES +0 -6
  2. package/README.md +2 -2
  3. package/api/bank-accounts-api.ts +18 -48
  4. package/api/bank-orders-api.ts +15 -40
  5. package/api/bank-transaction-api.ts +26 -181
  6. package/api/billing-addresses-api.ts +15 -40
  7. package/api/credit-allocation-api.ts +9 -24
  8. package/api/exceeding-credits-api.ts +6 -128
  9. package/api/health-check-api.ts +1 -1
  10. package/api/ibanvalidator-api.ts +3 -8
  11. package/api/payment-methods-api.ts +9 -24
  12. package/api/payment-receipts-api.ts +15 -40
  13. package/api/payment-reminders-api.ts +12 -32
  14. package/api/payment-requests-api.ts +27 -52
  15. package/api/payment-setup-api.ts +6 -16
  16. package/api/payments-api.ts +16 -46
  17. package/api/payout-methods-api.ts +18 -48
  18. package/api/policy-payment-methods-api.ts +9 -24
  19. package/api/refunds-api.ts +9 -24
  20. package/api/tenant-bank-account-api.ts +15 -40
  21. package/api/webhooks-api.ts +2 -2
  22. package/base.ts +43 -239
  23. package/common.ts +2 -3
  24. package/configuration.ts +0 -20
  25. package/dist/api/bank-accounts-api.d.ts +6 -6
  26. package/dist/api/bank-accounts-api.js +46 -82
  27. package/dist/api/bank-orders-api.d.ts +5 -5
  28. package/dist/api/bank-orders-api.js +38 -67
  29. package/dist/api/bank-transaction-api.d.ts +14 -80
  30. package/dist/api/bank-transaction-api.js +52 -194
  31. package/dist/api/billing-addresses-api.d.ts +5 -5
  32. package/dist/api/billing-addresses-api.js +39 -71
  33. package/dist/api/credit-allocation-api.d.ts +3 -3
  34. package/dist/api/credit-allocation-api.js +23 -41
  35. package/dist/api/exceeding-credits-api.d.ts +2 -59
  36. package/dist/api/exceeding-credits-api.js +15 -126
  37. package/dist/api/health-check-api.d.ts +1 -1
  38. package/dist/api/health-check-api.js +1 -1
  39. package/dist/api/ibanvalidator-api.d.ts +1 -1
  40. package/dist/api/ibanvalidator-api.js +8 -15
  41. package/dist/api/payment-methods-api.d.ts +3 -3
  42. package/dist/api/payment-methods-api.js +23 -41
  43. package/dist/api/payment-receipts-api.d.ts +5 -5
  44. package/dist/api/payment-receipts-api.js +38 -67
  45. package/dist/api/payment-reminders-api.d.ts +4 -4
  46. package/dist/api/payment-reminders-api.js +31 -56
  47. package/dist/api/payment-requests-api.d.ts +17 -17
  48. package/dist/api/payment-requests-api.js +47 -76
  49. package/dist/api/payment-setup-api.d.ts +2 -2
  50. package/dist/api/payment-setup-api.js +16 -30
  51. package/dist/api/payments-api.d.ts +4 -4
  52. package/dist/api/payments-api.js +34 -62
  53. package/dist/api/payout-methods-api.d.ts +6 -6
  54. package/dist/api/payout-methods-api.js +46 -82
  55. package/dist/api/policy-payment-methods-api.d.ts +3 -3
  56. package/dist/api/policy-payment-methods-api.js +23 -41
  57. package/dist/api/refunds-api.d.ts +3 -3
  58. package/dist/api/refunds-api.js +22 -37
  59. package/dist/api/tenant-bank-account-api.d.ts +5 -5
  60. package/dist/api/tenant-bank-account-api.js +38 -67
  61. package/dist/api/webhooks-api.d.ts +2 -2
  62. package/dist/api/webhooks-api.js +2 -2
  63. package/dist/base.d.ts +0 -26
  64. package/dist/base.js +60 -243
  65. package/dist/common.d.ts +1 -1
  66. package/dist/common.js +0 -1
  67. package/dist/configuration.d.ts +0 -17
  68. package/dist/configuration.js +0 -2
  69. package/dist/models/bank-transaction-class.d.ts +0 -7
  70. package/dist/models/bank-transaction-entity.d.ts +0 -7
  71. package/dist/models/bank-transaction-invoice-entity.d.ts +0 -24
  72. package/dist/models/create-payment-order-dto.d.ts +1 -1
  73. package/dist/models/create-payment-receipt-request-dto.d.ts +3 -3
  74. package/dist/models/create-payment-request-dto.d.ts +1 -1
  75. package/dist/models/create-payment-request-request-dto.d.ts +0 -6
  76. package/dist/models/credit-allocation-class.d.ts +0 -6
  77. package/dist/models/credit-allocation-entity.d.ts +0 -6
  78. package/dist/models/exceeding-credit-entity.d.ts +0 -6
  79. package/dist/models/index.d.ts +0 -6
  80. package/dist/models/index.js +0 -6
  81. package/dist/models/list-billing-addresses-response-class.d.ts +9 -9
  82. package/dist/models/list-exceeding-credits-response-class.d.ts +18 -6
  83. package/dist/models/list-payment-receipts-response-class.d.ts +9 -9
  84. package/dist/models/list-payment-requests-response-class.d.ts +18 -6
  85. package/dist/models/list-payout-methods-response-class.d.ts +9 -9
  86. package/dist/models/list-refunds-response-class.d.ts +18 -6
  87. package/dist/models/payment-class-without-expand-properties.d.ts +2 -2
  88. package/dist/models/payment-class.d.ts +2 -2
  89. package/dist/models/payment-entity.d.ts +1 -1
  90. package/dist/models/payment-receipt-class.d.ts +1 -13
  91. package/dist/models/payment-request-class.d.ts +6 -13
  92. package/dist/models/payment-request-class.js +0 -1
  93. package/dist/models/shared-transaction-class.d.ts +0 -6
  94. package/dist/models/transaction-entity.d.ts +0 -6
  95. package/models/bank-transaction-class.ts +0 -7
  96. package/models/bank-transaction-entity.ts +0 -7
  97. package/models/bank-transaction-invoice-entity.ts +0 -24
  98. package/models/create-payment-order-dto.ts +1 -1
  99. package/models/create-payment-receipt-request-dto.ts +3 -3
  100. package/models/create-payment-request-dto.ts +1 -1
  101. package/models/create-payment-request-request-dto.ts +0 -6
  102. package/models/credit-allocation-class.ts +0 -6
  103. package/models/credit-allocation-entity.ts +0 -6
  104. package/models/exceeding-credit-entity.ts +0 -6
  105. package/models/index.ts +0 -6
  106. package/models/list-billing-addresses-response-class.ts +9 -9
  107. package/models/list-exceeding-credits-response-class.ts +18 -6
  108. package/models/list-payment-receipts-response-class.ts +9 -9
  109. package/models/list-payment-requests-response-class.ts +18 -6
  110. package/models/list-payout-methods-response-class.ts +9 -9
  111. package/models/list-refunds-response-class.ts +18 -6
  112. package/models/payment-class-without-expand-properties.ts +2 -2
  113. package/models/payment-class.ts +2 -2
  114. package/models/payment-entity.ts +1 -1
  115. package/models/payment-receipt-class.ts +1 -13
  116. package/models/payment-request-class.ts +6 -13
  117. package/models/shared-transaction-class.ts +0 -6
  118. package/models/transaction-entity.ts +0 -6
  119. package/package.json +2 -2
  120. package/dist/models/create-exceeding-credit-request-dto.d.ts +0 -48
  121. package/dist/models/create-exceeding-credit-request-dto.js +0 -15
  122. package/dist/models/create-exceeding-credit-response-class.d.ts +0 -25
  123. package/dist/models/create-exceeding-credit-response-class.js +0 -15
  124. package/dist/models/link-bank-transaction-payment-requests-request-dto-rest.d.ts +0 -30
  125. package/dist/models/link-bank-transaction-payment-requests-request-dto-rest.js +0 -15
  126. package/dist/models/link-bank-transaction-payment-requests-response-class.d.ts +0 -25
  127. package/dist/models/link-bank-transaction-payment-requests-response-class.js +0 -15
  128. package/dist/models/payment-receipt-entity.d.ts +0 -139
  129. package/dist/models/payment-receipt-entity.js +0 -20
  130. package/dist/models/payment-request-entity.d.ts +0 -223
  131. package/dist/models/payment-request-entity.js +0 -39
  132. package/models/create-exceeding-credit-request-dto.ts +0 -54
  133. package/models/create-exceeding-credit-response-class.ts +0 -31
  134. package/models/link-bank-transaction-payment-requests-request-dto-rest.ts +0 -36
  135. package/models/link-bank-transaction-payment-requests-response-class.ts +0 -31
  136. package/models/payment-receipt-entity.ts +0 -148
  137. package/models/payment-request-entity.ts +0 -233
@@ -296,7 +296,7 @@ var WebhooksApi = /** @class */ (function (_super) {
296
296
  */
297
297
  WebhooksApi.prototype.postWebhook = function (requestParameters, options) {
298
298
  var _this = this;
299
- return (0, exports.WebhooksApiFp)(this.configuration).postWebhook(requestParameters.pspType, requestParameters.tenantSlug, requestParameters.body, this.withOwner(options)).then(function (request) { return request(_this.axios, _this.basePath); });
299
+ return (0, exports.WebhooksApiFp)(this.configuration).postWebhook(requestParameters.pspType, requestParameters.tenantSlug, requestParameters.body, options).then(function (request) { return request(_this.axios, _this.basePath); });
300
300
  };
301
301
  /**
302
302
  * This will processes the webhook from external payment service provider. **Required Permissions** none
@@ -308,7 +308,7 @@ var WebhooksApi = /** @class */ (function (_super) {
308
308
  */
309
309
  WebhooksApi.prototype.postWebhookWithProductSlug = function (requestParameters, options) {
310
310
  var _this = this;
311
- return (0, exports.WebhooksApiFp)(this.configuration).postWebhookWithProductSlug(requestParameters.pspType, requestParameters.tenantSlug, requestParameters.productSlug, requestParameters.body, this.withOwner(options)).then(function (request) { return request(_this.axios, _this.basePath); });
311
+ return (0, exports.WebhooksApiFp)(this.configuration).postWebhookWithProductSlug(requestParameters.pspType, requestParameters.tenantSlug, requestParameters.productSlug, requestParameters.body, options).then(function (request) { return request(_this.axios, _this.basePath); });
312
312
  };
313
313
  return WebhooksApi;
314
314
  }(base_1.BaseAPI));
package/dist/base.d.ts CHANGED
@@ -22,19 +22,9 @@ export declare const COLLECTION_FORMATS: {
22
22
  tsv: string;
23
23
  pipes: string;
24
24
  };
25
- export interface SessionClass {
26
- sub: string;
27
- username?: string;
28
- email?: string;
29
- tenantSlug?: string;
30
- permissions?: string;
31
- expiresAt?: number;
32
- }
33
25
  export interface LoginClass {
34
26
  accessToken: string;
35
27
  permissions: string;
36
- authMode?: string;
37
- session?: SessionClass;
38
28
  }
39
29
  export interface SwitchWorkspaceRequest {
40
30
  username: string;
@@ -43,8 +33,6 @@ export interface SwitchWorkspaceRequest {
43
33
  export interface SwitchWorkspaceResponseClass {
44
34
  accessToken: string;
45
35
  permissions: string;
46
- authMode?: string;
47
- session?: SessionClass;
48
36
  }
49
37
  export declare enum Environment {
50
38
  Production = "https://apiv2.emil.de",
@@ -75,18 +63,6 @@ export declare class BaseAPI {
75
63
  protected configuration: Configuration | undefined;
76
64
  private tokenData?;
77
65
  constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance);
78
- private sessionAccount;
79
- private authBasePath;
80
- private usesSession;
81
- private useSessionAuth;
82
- private useHeaderAuth;
83
- private applyTokenReply;
84
- private sessionHeaders;
85
- private withCurrentAuth;
86
- private canRetryWithToken;
87
- private canResend;
88
- private switchToToken;
89
- private retryWithToken;
90
66
  selectEnvironment(env: Environment): void;
91
67
  selectBasePath(path: string): void;
92
68
  getPermissions(): Array<string>;
@@ -96,8 +72,6 @@ export declare class BaseAPI {
96
72
  private storeTokenData;
97
73
  loadTokenData(): void;
98
74
  cleanTokenData(): void;
99
- private ownAccount;
100
- protected withOwner(options?: AxiosRequestConfig): AxiosRequestConfig;
101
75
  private attachInterceptor;
102
76
  }
103
77
  /**
package/dist/base.js CHANGED
@@ -74,17 +74,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
74
74
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
75
75
  }
76
76
  };
77
- var __rest = (this && this.__rest) || function (s, e) {
78
- var t = {};
79
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
80
- t[p] = s[p];
81
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
82
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
83
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
84
- t[p[i]] = s[p[i]];
85
- }
86
- return t;
87
- };
88
77
  var __importDefault = (this && this.__importDefault) || function (mod) {
89
78
  return (mod && mod.__esModule) ? mod : { "default": mod };
90
79
  };
@@ -117,21 +106,12 @@ var Environment;
117
106
  })(Environment = exports.Environment || (exports.Environment = {}));
118
107
  var _retry_count = 0;
119
108
  var _retry = null;
120
- // Marks each request with the account (username) of the SDK object that sent it: only SDK objects of that
121
- // account refresh and resend it, never an object of another account open in the same browser.
122
- var REQUEST_OWNER = '_emilSdkOwner';
123
109
  function resetRetry() {
124
110
  _retry_count = 0;
125
111
  }
126
112
  exports.resetRetry = resetRetry;
127
113
  var NETWORK_ERROR_MESSAGE = "Network Error";
128
114
  var TOKEN_DATA = 'APP_TOKEN';
129
- // Sent only to authservice, to ask for a server session.
130
- var AUTH_MODE_HEADER = 'X-Emil-Auth-Mode';
131
- // Names the account on every call; one browser session can hold several.
132
- var ACCOUNT_HEADER = 'X-Emil-Account';
133
- var SESSION_MODES = ['both', 'session'];
134
- var RESEND_SAFE_METHODS = ['get', 'head', 'options'];
135
115
  /**
136
116
  *
137
117
  * @export
@@ -145,30 +125,13 @@ var BaseAPI = /** @class */ (function () {
145
125
  this.axios = axios;
146
126
  this.loadTokenData();
147
127
  if (configuration) {
148
- // Two accounts in one browser share APP_TOKEN: never take the token or session account saved for
149
- // another account. The mode stays (an app naming its account keeps its session). Saved with the next refresh.
150
- var ownUser = configuration.username;
151
- var storedUser = this.tokenData.username;
152
- if (ownUser && storedUser && ownUser.toLowerCase() !== storedUser.toLowerCase()) {
153
- delete this.tokenData.accessToken;
154
- delete this.tokenData.sub;
155
- this.tokenData.username = ownUser;
156
- }
157
128
  var accessToken = this.tokenData.accessToken;
158
129
  this.configuration = configuration;
159
130
  this.basePath = configuration.basePath || this.basePath;
160
- if (configuration.cookieAuth) {
161
- this.configuration.username = this.configuration.username || this.tokenData.username;
162
- }
163
- if (this.usesSession()) {
164
- this.useSessionAuth();
165
- }
166
- else {
167
- // Use config token if provided, otherwise use tokenData token
168
- var configToken = this.configuration.accessToken;
169
- var storedToken = accessToken ? "Bearer ".concat(accessToken) : '';
170
- this.configuration.accessToken = configToken || storedToken;
171
- }
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;
172
135
  }
173
136
  else {
174
137
  var _a = this.tokenData, accessToken = _a.accessToken, username = _a.username;
@@ -180,100 +143,6 @@ var BaseAPI = /** @class */ (function () {
180
143
  }
181
144
  this.attachInterceptor(axios);
182
145
  }
183
- // The app's own account wins over APP_TOKEN, which holds whichever tab wrote last.
184
- BaseAPI.prototype.sessionAccount = function () {
185
- return this.configuration.account || this.tokenData.sub;
186
- };
187
- // Apps may pass the address as the second argument only; authservice is on the same host.
188
- BaseAPI.prototype.authBasePath = function () {
189
- return this.configuration.basePath || this.basePath;
190
- };
191
- BaseAPI.prototype.usesSession = function () {
192
- return !!this.configuration.cookieAuth && SESSION_MODES.indexOf(this.tokenData.authMode) !== -1 && !!this.sessionAccount();
193
- };
194
- BaseAPI.prototype.useSessionAuth = function () {
195
- var _a;
196
- var _b = this.configuration.baseOptions || {}, headers = _b.headers, baseOptions = __rest(_b, ["headers"]);
197
- this.configuration.accessToken = '';
198
- this.configuration.baseOptions = __assign(__assign({}, baseOptions), { withCredentials: true, headers: __assign(__assign({}, headers), (_a = {}, _a[ACCOUNT_HEADER] = this.sessionAccount(), _a)) });
199
- };
200
- BaseAPI.prototype.useHeaderAuth = function (accessToken, keepSessionData) {
201
- if (keepSessionData === void 0) { keepSessionData = false; }
202
- this.configuration.accessToken = accessToken ? "Bearer ".concat(accessToken) : '';
203
- this.tokenData.accessToken = accessToken;
204
- // An app without cookieAuth does not own the session fields: its refresh leaves them for the session apps.
205
- if (!keepSessionData || this.configuration.cookieAuth) {
206
- delete this.tokenData.authMode;
207
- delete this.tokenData.sub;
208
- }
209
- if (this.configuration.cookieAuth) {
210
- var _a = this.configuration.baseOptions || {}, withCredentials = _a.withCredentials, headers = _a.headers, baseOptions = __rest(_a, ["withCredentials", "headers"]);
211
- var _b = headers || {}, _c = ACCOUNT_HEADER, account = _b[_c], otherHeaders = __rest(_b, [typeof _c === "symbol" ? _c : _c + ""]);
212
- this.configuration.baseOptions = __assign(__assign({}, baseOptions), { headers: otherHeaders });
213
- }
214
- };
215
- BaseAPI.prototype.applyTokenReply = function (_a, fromRefresh) {
216
- var accessToken = _a.accessToken, authMode = _a.authMode, session = _a.session;
217
- if (fromRefresh === void 0) { fromRefresh = false; }
218
- if (this.configuration.cookieAuth && SESSION_MODES.indexOf(authMode) !== -1 && (session === null || session === void 0 ? void 0 : session.sub)) {
219
- this.tokenData.authMode = authMode;
220
- this.tokenData.sub = session.sub;
221
- if (this.configuration.account) {
222
- // A workspace switch moves the app to another account.
223
- this.configuration.account = session.sub;
224
- }
225
- // Both keeps the token for apps not moved yet; session mode keeps no token at all.
226
- if (authMode === 'both' && accessToken) {
227
- this.tokenData.accessToken = accessToken;
228
- }
229
- else {
230
- delete this.tokenData.accessToken;
231
- }
232
- this.useSessionAuth();
233
- }
234
- else {
235
- this.useHeaderAuth(accessToken, fromRefresh);
236
- }
237
- };
238
- BaseAPI.prototype.sessionHeaders = function () {
239
- var _a, _b;
240
- if (!this.configuration.cookieAuth) {
241
- return {};
242
- }
243
- return __assign((_a = {}, _a[AUTH_MODE_HEADER] = 'session', _a), (this.usesSession() && (_b = {}, _b[ACCOUNT_HEADER] = this.sessionAccount(), _b)));
244
- };
245
- BaseAPI.prototype.withCurrentAuth = function (config) {
246
- delete config.headers['Authorization'];
247
- delete config.headers[ACCOUNT_HEADER];
248
- if (this.usesSession()) {
249
- config.headers[ACCOUNT_HEADER] = this.sessionAccount();
250
- config.withCredentials = true;
251
- }
252
- else if (this.configuration.accessToken) {
253
- config.headers['Authorization'] = this.configuration.accessToken;
254
- }
255
- return config;
256
- };
257
- // Both keeps the token, so a session call the browser could not complete can be sent again with it.
258
- BaseAPI.prototype.canRetryWithToken = function (config) {
259
- var _a;
260
- return !!config.withCredentials && !!((_a = config.headers) === null || _a === void 0 ? void 0 : _a[ACCOUNT_HEADER])
261
- && !!this.tokenData.accessToken && this.tokenData.authMode !== 'session';
262
- };
263
- // A network error can come after the server ran the call, so only a call that is safe to repeat is sent again.
264
- BaseAPI.prototype.canResend = function (config) {
265
- return RESEND_SAFE_METHODS.indexOf((config.method || 'get').toLowerCase()) !== -1
266
- || Object.keys(config.headers || {}).some(function (name) { return name.toLowerCase() === 'idempotency-key'; });
267
- };
268
- BaseAPI.prototype.switchToToken = function () {
269
- this.useHeaderAuth(this.tokenData.accessToken);
270
- this.storeTokenData(this.tokenData);
271
- };
272
- BaseAPI.prototype.retryWithToken = function (axios, config) {
273
- this.switchToToken();
274
- config.withCredentials = false;
275
- return axios(this.withCurrentAuth(config));
276
- };
277
146
  BaseAPI.prototype.selectEnvironment = function (env) {
278
147
  this.selectBasePath(env);
279
148
  };
@@ -289,15 +158,14 @@ var BaseAPI = /** @class */ (function () {
289
158
  };
290
159
  BaseAPI.prototype.authorize = function (username, password, targetWorkspace) {
291
160
  return __awaiter(this, void 0, void 0, function () {
292
- var options, response;
293
- var _a;
161
+ var options, response, _a, accessToken, permissions;
294
162
  return __generator(this, function (_b) {
295
163
  switch (_b.label) {
296
164
  case 0:
297
165
  options = {
298
166
  method: 'POST',
299
- url: "".concat(this.authBasePath(), "/authservice/v1/login"),
300
- headers: __assign({ 'Content-Type': 'application/json' }, (this.configuration.cookieAuth && (_a = {}, _a[AUTH_MODE_HEADER] = 'session', _a))),
167
+ url: "".concat(this.configuration.basePath, "/authservice/v1/login"),
168
+ headers: { 'Content-Type': 'application/json' },
301
169
  data: {
302
170
  username: username,
303
171
  password: password,
@@ -307,10 +175,12 @@ var BaseAPI = /** @class */ (function () {
307
175
  return [4 /*yield*/, axios_1.default.request(options)];
308
176
  case 1:
309
177
  response = _b.sent();
178
+ _a = response.data, accessToken = _a.accessToken, permissions = _a.permissions;
310
179
  this.configuration.username = username;
180
+ this.configuration.accessToken = "Bearer ".concat(accessToken);
311
181
  this.tokenData.username = username;
312
- this.tokenData.permissions = response.data.permissions;
313
- this.applyTokenReply(response.data);
182
+ this.tokenData.accessToken = accessToken;
183
+ this.tokenData.permissions = permissions;
314
184
  if (!targetWorkspace) return [3 /*break*/, 3];
315
185
  return [4 /*yield*/, this.switchWorkspace(targetWorkspace)];
316
186
  case 2:
@@ -329,14 +199,17 @@ var BaseAPI = /** @class */ (function () {
329
199
  };
330
200
  BaseAPI.prototype.switchWorkspace = function (targetWorkspace) {
331
201
  return __awaiter(this, void 0, void 0, function () {
332
- var options, response;
333
- return __generator(this, function (_a) {
334
- switch (_a.label) {
202
+ var options, response, _a, accessToken, permissions;
203
+ return __generator(this, function (_b) {
204
+ switch (_b.label) {
335
205
  case 0:
336
206
  options = {
337
207
  method: 'POST',
338
- url: "".concat(this.authBasePath(), "/authservice/v1/workspaces/switch"),
339
- headers: __assign(__assign({ 'Content-Type': 'application/json' }, this.sessionHeaders()), (!this.usesSession() && !!this.configuration.accessToken && { 'Authorization': this.configuration.accessToken })),
208
+ url: "".concat(this.configuration.basePath, "/authservice/v1/workspaces/switch"),
209
+ headers: {
210
+ 'Content-Type': 'application/json',
211
+ 'Authorization': "Bearer ".concat(this.configuration.accessToken),
212
+ },
340
213
  data: {
341
214
  username: this.configuration.username,
342
215
  targetWorkspace: targetWorkspace,
@@ -345,9 +218,11 @@ var BaseAPI = /** @class */ (function () {
345
218
  };
346
219
  return [4 /*yield*/, axios_1.default.request(options)];
347
220
  case 1:
348
- response = _a.sent();
349
- this.tokenData.permissions = response.data.permissions;
350
- this.applyTokenReply(response.data);
221
+ response = _b.sent();
222
+ _a = response.data, accessToken = _a.accessToken, permissions = _a.permissions;
223
+ this.configuration.accessToken = "Bearer ".concat(accessToken);
224
+ this.tokenData.accessToken = accessToken;
225
+ this.tokenData.permissions = permissions;
351
226
  this.storeTokenData(__assign({}, this.tokenData));
352
227
  return [2 /*return*/];
353
228
  }
@@ -367,42 +242,17 @@ var BaseAPI = /** @class */ (function () {
367
242
  }
368
243
  refreshTokenAxios = axios_1.default.create();
369
244
  refreshTokenAxios.interceptors.response.use(function (response) {
370
- var _a, _b;
371
- var _c = response.data, permissions = _c.permissions, accessToken = _c.accessToken, authMode = _c.authMode;
372
- // Decided before the merge below: newer session data must not keep the new token from this object.
373
- var onSession = _this.usesSession();
374
- // Newer data saved for this account (e.g. the session mode the shell saved later) wins over the copy
375
- // read when the object was made; data of another account or another workspace (sub) is never taken.
376
- var latest = ((typeof window !== 'undefined' && (0, common_1.defaultStorage)().get(TOKEN_DATA)) || {});
377
- var ownSub = _this.sessionAccount();
378
- if (((_a = latest.username) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === username.toLowerCase()
379
- && (!ownSub || !latest.sub || latest.sub === ownSub)) {
380
- // A bare reset ({username}, an app's account check) keeps this copy's other fields; any fuller record
381
- // is the truth, so fields it lacks were removed on purpose (e.g. a rollback) and stay removed.
382
- var bareReset = Object.keys(latest).every(function (key) { return key === 'username'; });
383
- _this.tokenData = bareReset ? __assign(__assign({}, _this.tokenData), latest) : __assign({}, latest);
384
- }
385
- // The reply is for this account: label it, or an SDK object of another account would take the token.
386
- if (((_b = _this.tokenData.username) === null || _b === void 0 ? void 0 : _b.toLowerCase()) !== username.toLowerCase()) {
387
- _this.tokenData.username = username;
388
- }
245
+ var permissions = response.data.permissions;
389
246
  _this.tokenData.permissions = permissions;
390
- // Keep the new token for the page's next SDK objects; session data is left as it is.
391
- if (accessToken && !onSession) {
392
- _this.tokenData.accessToken = accessToken;
393
- _this.configuration.accessToken = "Bearer ".concat(accessToken);
394
- }
395
- else if (accessToken && authMode === 'both') {
396
- // Both: this app stays on the session; the token is kept for apps not moved yet.
397
- _this.tokenData.accessToken = accessToken;
398
- }
399
247
  _this.storeTokenData(_this.tokenData);
400
248
  return response;
401
249
  });
402
250
  options = {
403
251
  method: 'POST',
404
- url: "".concat(this.authBasePath(), "/authservice/v1/refresh-token"),
405
- headers: __assign({ 'Content-Type': 'application/json' }, this.sessionHeaders()),
252
+ url: "".concat(this.configuration.basePath, "/authservice/v1/refresh-token"),
253
+ headers: {
254
+ 'Content-Type': 'application/json',
255
+ },
406
256
  data: { username: username },
407
257
  withCredentials: true,
408
258
  };
@@ -430,100 +280,67 @@ var BaseAPI = /** @class */ (function () {
430
280
  BaseAPI.prototype.cleanTokenData = function () {
431
281
  this.storeTokenData(null);
432
282
  };
433
- BaseAPI.prototype.ownAccount = function () {
434
- return (this.configuration.username || '').toLowerCase();
435
- };
436
- BaseAPI.prototype.withOwner = function (options) {
437
- var _a;
438
- // An object without a username cannot refresh itself: its requests stay unmarked, as before.
439
- if (!this.ownAccount()) {
440
- return __assign({}, options);
441
- }
442
- return __assign(__assign({}, options), (_a = {}, _a[REQUEST_OWNER] = this.ownAccount(), _a));
443
- };
444
283
  BaseAPI.prototype.attachInterceptor = function (axios) {
445
284
  var _this = this;
446
285
  axios.interceptors.response.use(function (res) {
447
286
  return res;
448
287
  }, function (err) { return __awaiter(_this, void 0, void 0, function () {
449
- var originalConfig, owner, reply, _error_1, reply, _error_2;
450
- var _this = this;
451
- return __generator(this, function (_a) {
452
- switch (_a.label) {
288
+ var originalConfig, _a, tokenString, permissions, accessToken, _error_1, _b, tokenString, permissions, accessToken, _error_2;
289
+ return __generator(this, function (_c) {
290
+ switch (_c.label) {
453
291
  case 0:
454
292
  originalConfig = err.config;
455
- owner = originalConfig === null || originalConfig === void 0 ? void 0 : originalConfig[REQUEST_OWNER];
456
- if (owner !== undefined && owner !== this.ownAccount()) {
457
- return [2 /*return*/, Promise.reject(err)];
458
- }
459
293
  if (!(err.response && !(err.response instanceof XMLHttpRequest))) return [3 /*break*/, 5];
460
294
  if (!((err.response.status === 401 || err.response.status === 403)
461
295
  && !originalConfig._retry)) return [3 /*break*/, 4];
462
296
  originalConfig._retry = true;
463
- _a.label = 1;
297
+ _c.label = 1;
464
298
  case 1:
465
- _a.trys.push([1, 3, , 4]);
299
+ _c.trys.push([1, 3, , 4]);
466
300
  return [4 /*yield*/, this.refreshTokenInternal()];
467
301
  case 2:
468
- reply = _a.sent();
469
- this.tokenData.permissions = reply.permissions;
470
- this.applyTokenReply(reply, true);
302
+ _a = _c.sent(), tokenString = _a.accessToken, permissions = _a.permissions;
303
+ accessToken = "Bearer ".concat(tokenString);
304
+ this.tokenData.permissions = permissions;
305
+ delete originalConfig.headers['Authorization'];
306
+ originalConfig.headers['Authorization'] = accessToken;
307
+ this.configuration.accessToken = accessToken;
308
+ this.tokenData.accessToken = tokenString;
471
309
  this.storeTokenData(this.tokenData);
472
- if (!this.usesSession()) {
473
- return [2 /*return*/, axios(this.withCurrentAuth(originalConfig))];
474
- }
475
- // Both mode: if the browser does not send the session cookie (another site), use the token.
476
- return [2 /*return*/, axios(this.withCurrentAuth(originalConfig)).catch(function (retryError) {
477
- var _a;
478
- if (((_a = retryError === null || retryError === void 0 ? void 0 : retryError.response) === null || _a === void 0 ? void 0 : _a.status) !== 401 || !_this.tokenData.accessToken) {
479
- return Promise.reject(retryError);
480
- }
481
- return _this.retryWithToken(axios, originalConfig);
482
- })];
310
+ return [2 /*return*/, axios(originalConfig)];
483
311
  case 3:
484
- _error_1 = _a.sent();
312
+ _error_1 = _c.sent();
485
313
  if (_error_1.response && _error_1.response.data) {
486
314
  return [2 /*return*/, Promise.reject(_error_1.response.data)];
487
315
  }
488
316
  return [2 /*return*/, Promise.reject(_error_1)];
489
- case 4: return [3 /*break*/, 10];
317
+ case 4: return [3 /*break*/, 9];
490
318
  case 5:
491
- if (!(err.message === NETWORK_ERROR_MESSAGE && this.canRetryWithToken(originalConfig))) return [3 /*break*/, 6];
492
- // Both mode: the browser blocked the session call or hid its reply; later calls use the token.
493
- if (!this.canResend(originalConfig)) {
494
- this.switchToToken();
495
- return [2 /*return*/, Promise.reject(err)];
496
- }
497
- return [2 /*return*/, this.retryWithToken(axios, originalConfig)];
498
- case 6:
499
319
  if (!(err.message === NETWORK_ERROR_MESSAGE
500
- && (originalConfig.headers.hasOwnProperty('Authorization')
501
- || (this.configuration.cookieAuth && originalConfig.withCredentials && this.canResend(originalConfig)))
502
- && _retry_count < 4)) return [3 /*break*/, 10];
320
+ && originalConfig.headers.hasOwnProperty('Authorization')
321
+ && _retry_count < 4)) return [3 /*break*/, 9];
503
322
  _retry_count++;
504
- _a.label = 7;
505
- case 7:
506
- _a.trys.push([7, 9, , 10]);
323
+ _c.label = 6;
324
+ case 6:
325
+ _c.trys.push([6, 8, , 9]);
507
326
  return [4 /*yield*/, this.refreshTokenInternal()];
508
- case 8:
509
- reply = _a.sent();
510
- this.tokenData.permissions = reply.permissions;
327
+ case 7:
328
+ _b = _c.sent(), tokenString = _b.accessToken, permissions = _b.permissions;
329
+ accessToken = "Bearer ".concat(tokenString);
330
+ this.tokenData.permissions = permissions;
511
331
  _retry = true;
512
- this.applyTokenReply(reply, true);
332
+ originalConfig.headers['Authorization'] = accessToken;
333
+ this.configuration.accessToken = accessToken;
334
+ this.tokenData.accessToken = tokenString;
513
335
  this.storeTokenData(this.tokenData);
514
- // The limit is for refreshes that do not help; one that worked starts the count again.
515
- // Not awaited, so a failed retry reaches the app as the same axios error as before.
516
- return [2 /*return*/, axios.request(__assign({}, this.withCurrentAuth(originalConfig))).then(function (retried) {
517
- _retry_count = 0;
518
- return retried;
519
- })];
520
- case 9:
521
- _error_2 = _a.sent();
336
+ return [2 /*return*/, axios.request(__assign({}, originalConfig))];
337
+ case 8:
338
+ _error_2 = _c.sent();
522
339
  if (_error_2.response && _error_2.response.data) {
523
340
  return [2 /*return*/, Promise.reject(_error_2.response.data)];
524
341
  }
525
342
  return [2 /*return*/, Promise.reject(_error_2)];
526
- case 10: return [2 /*return*/, Promise.reject(err)];
343
+ case 9: return [2 /*return*/, Promise.reject(err)];
527
344
  }
528
345
  });
529
346
  }); });
package/dist/common.d.ts CHANGED
@@ -62,7 +62,7 @@ export declare const toPathString: (url: URL) => string;
62
62
  *
63
63
  * @export
64
64
  */
65
- export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) => <T = unknown, R = AxiosResponse<T, any, {}, any>>(axios?: AxiosInstance, basePath?: string) => Promise<R>;
65
+ export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) => <T = unknown, R = AxiosResponse<T, any, {}>>(axios?: AxiosInstance, basePath?: string) => Promise<R>;
66
66
  /**
67
67
  * Emil Payment Service
68
68
  * This service directly communicates with the various Payment Service Providers (PSPs) in order to charge or refund customers. This service will automatically connect to the PSP linked in your admin configuration; meaning if you configured Stripe, it will automatically create a payment on Stripe when you create it in Emil.
package/dist/common.js CHANGED
@@ -233,7 +233,6 @@ exports.toPathString = toPathString;
233
233
  * @export
234
234
  */
235
235
  var createRequestFunction = function (axiosArgs, globalAxios, BASE_PATH, configuration) {
236
- // Typed by hand: since axios 1.20, request() returns an internal axios type that SDK declarations cannot name.
237
236
  return function (axios, basePath) {
238
237
  if (axios === void 0) { axios = globalAxios; }
239
238
  if (basePath === void 0) { basePath = BASE_PATH; }
@@ -17,8 +17,6 @@ export interface ConfigurationParameters {
17
17
  basePath?: string;
18
18
  baseOptions?: any;
19
19
  formDataCtor?: new () => any;
20
- cookieAuth?: boolean;
21
- account?: string;
22
20
  }
23
21
  export declare class Configuration {
24
22
  /**
@@ -70,21 +68,6 @@ export declare class Configuration {
70
68
  * @type {new () => FormData}
71
69
  */
72
70
  formDataCtor?: new () => any;
73
- /**
74
- * Use a server session when authservice makes one; otherwise the token, as without this option.
75
- * Set `account` too, so each SDK object keeps its own account.
76
- *
77
- * @type {boolean}
78
- * @memberof Configuration
79
- */
80
- cookieAuth?: boolean;
81
- /**
82
- * The session account (Cognito sub) this app shows, so the SDK never takes another tab's account.
83
- *
84
- * @type {string}
85
- * @memberof Configuration
86
- */
87
- account?: string;
88
71
  constructor(param?: ConfigurationParameters);
89
72
  /**
90
73
  * Check if the given MIME is a JSON MIME.
@@ -24,8 +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
- this.account = param.account;
29
27
  }
30
28
  /**
31
29
  * Check if the given MIME is a JSON MIME.
@@ -12,7 +12,6 @@
12
12
  import { BankOrderClass } from './bank-order-class';
13
13
  import { BankTransactionInvoiceClass } from './bank-transaction-invoice-class';
14
14
  import { InvoiceMatchSuggestionClass } from './invoice-match-suggestion-class';
15
- import { PaymentReceiptClass } from './payment-receipt-class';
16
15
  import { SuggestionGenerationProgressClass } from './suggestion-generation-progress-class';
17
16
  import { TenantBankAccountClassWithoutExpandProperties } from './tenant-bank-account-class-without-expand-properties';
18
17
  /**
@@ -153,12 +152,6 @@ export interface BankTransactionClass {
153
152
  * @memberof BankTransactionClass
154
153
  */
155
154
  'suggestionGenerationProgress'?: SuggestionGenerationProgressClass;
156
- /**
157
- * Payment receipts created by linking this outgoing transaction to payment requests
158
- * @type {Array<PaymentReceiptClass>}
159
- * @memberof BankTransactionClass
160
- */
161
- 'paymentReceipts'?: Array<PaymentReceiptClass>;
162
155
  }
163
156
  export declare const BankTransactionClassLabelEnum: {
164
157
  readonly Automated: "automated";
@@ -13,7 +13,6 @@ import { BankOrderEntity } from './bank-order-entity';
13
13
  import { BankTransactionInvoiceEntity } from './bank-transaction-invoice-entity';
14
14
  import { ExceedingCreditEntity } from './exceeding-credit-entity';
15
15
  import { InvoiceMatchSuggestionEntity } from './invoice-match-suggestion-entity';
16
- import { PaymentReceiptEntity } from './payment-receipt-entity';
17
16
  import { SuggestionGenerationProgressEntity } from './suggestion-generation-progress-entity';
18
17
  import { TenantBankAccountEntity } from './tenant-bank-account-entity';
19
18
  /**
@@ -138,12 +137,6 @@ export interface BankTransactionEntity {
138
137
  * @memberof BankTransactionEntity
139
138
  */
140
139
  'exceedingCredits': Array<ExceedingCreditEntity>;
141
- /**
142
- *
143
- * @type {Array<PaymentReceiptEntity>}
144
- * @memberof BankTransactionEntity
145
- */
146
- 'paymentReceipts': Array<PaymentReceiptEntity>;
147
140
  /**
148
141
  *
149
142
  * @type {string}
@@ -77,30 +77,6 @@ export interface BankTransactionInvoiceEntity {
77
77
  * @memberof BankTransactionInvoiceEntity
78
78
  */
79
79
  'bankTransaction': BankTransactionEntity;
80
- /**
81
- *
82
- * @type {string}
83
- * @memberof BankTransactionInvoiceEntity
84
- */
85
- 'unlinkCode'?: string | null;
86
- /**
87
- *
88
- * @type {string}
89
- * @memberof BankTransactionInvoiceEntity
90
- */
91
- 'unlinkedPaymentCode'?: string | null;
92
- /**
93
- *
94
- * @type {Array<string>}
95
- * @memberof BankTransactionInvoiceEntity
96
- */
97
- 'unlinkedCreditCodes'?: Array<string> | null;
98
- /**
99
- *
100
- * @type {string}
101
- * @memberof BankTransactionInvoiceEntity
102
- */
103
- 'unlinkEventPublishedAt'?: string | null;
104
80
  /**
105
81
  *
106
82
  * @type {string}
@@ -28,7 +28,7 @@ export interface CreatePaymentOrderDto {
28
28
  */
29
29
  'comment'?: string;
30
30
  /**
31
- * The payment date: a calendar date, not a point in time. Send the date alone (`2026-10-10`), which is read as midnight UTC of that day, or a timestamp at midnight UTC (`2026-10-10T00:00:00.000Z`). Timestamps are read as UTC: any other time is stored as the instant it names and books on that instant’s UTC calendar day, so a local midnight east of UTC (`2026-10-10T00:00:00+02:00`) books on the previous day.
31
+ * Optional payment date.
32
32
  * @type {string}
33
33
  * @memberof CreatePaymentOrderDto
34
34
  */