@emilgroup/payment-sdk 1.22.1-beta.74 → 1.22.1-beta.75

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 (89) hide show
  1. package/.openapi-generator/FILES +4 -0
  2. package/README.md +2 -2
  3. package/api/bank-accounts-api.ts +24 -12
  4. package/api/bank-orders-api.ts +20 -10
  5. package/api/bank-transaction-api.ts +154 -20
  6. package/api/billing-addresses-api.ts +20 -10
  7. package/api/credit-allocation-api.ts +12 -6
  8. package/api/exceeding-credits-api.ts +12 -6
  9. package/api/ibanvalidator-api.ts +4 -2
  10. package/api/payment-methods-api.ts +12 -6
  11. package/api/payment-receipts-api.ts +20 -10
  12. package/api/payment-reminders-api.ts +16 -8
  13. package/api/payment-requests-api.ts +20 -10
  14. package/api/payment-setup-api.ts +8 -4
  15. package/api/payments-api.ts +24 -12
  16. package/api/payout-methods-api.ts +24 -12
  17. package/api/policy-payment-methods-api.ts +12 -6
  18. package/api/refunds-api.ts +12 -6
  19. package/api/tenant-bank-account-api.ts +20 -10
  20. package/base.ts +174 -41
  21. package/common.ts +3 -2
  22. package/configuration.ts +20 -0
  23. package/dist/api/bank-accounts-api.d.ts +6 -6
  24. package/dist/api/bank-accounts-api.js +36 -22
  25. package/dist/api/bank-orders-api.d.ts +5 -5
  26. package/dist/api/bank-orders-api.js +29 -18
  27. package/dist/api/bank-transaction-api.d.ts +80 -14
  28. package/dist/api/bank-transaction-api.js +144 -28
  29. package/dist/api/billing-addresses-api.d.ts +5 -5
  30. package/dist/api/billing-addresses-api.js +32 -19
  31. package/dist/api/credit-allocation-api.d.ts +3 -3
  32. package/dist/api/credit-allocation-api.js +18 -11
  33. package/dist/api/exceeding-credits-api.d.ts +3 -3
  34. package/dist/api/exceeding-credits-api.js +18 -11
  35. package/dist/api/health-check-api.d.ts +1 -1
  36. package/dist/api/ibanvalidator-api.d.ts +1 -1
  37. package/dist/api/ibanvalidator-api.js +7 -4
  38. package/dist/api/payment-methods-api.d.ts +3 -3
  39. package/dist/api/payment-methods-api.js +18 -11
  40. package/dist/api/payment-receipts-api.d.ts +5 -5
  41. package/dist/api/payment-receipts-api.js +29 -18
  42. package/dist/api/payment-reminders-api.d.ts +4 -4
  43. package/dist/api/payment-reminders-api.js +25 -15
  44. package/dist/api/payment-requests-api.d.ts +5 -5
  45. package/dist/api/payment-requests-api.js +29 -18
  46. package/dist/api/payment-setup-api.d.ts +2 -2
  47. package/dist/api/payment-setup-api.js +14 -8
  48. package/dist/api/payments-api.d.ts +4 -4
  49. package/dist/api/payments-api.js +28 -18
  50. package/dist/api/payout-methods-api.d.ts +6 -6
  51. package/dist/api/payout-methods-api.js +36 -22
  52. package/dist/api/policy-payment-methods-api.d.ts +3 -3
  53. package/dist/api/policy-payment-methods-api.js +18 -11
  54. package/dist/api/refunds-api.d.ts +3 -3
  55. package/dist/api/refunds-api.js +15 -10
  56. package/dist/api/tenant-bank-account-api.d.ts +5 -5
  57. package/dist/api/tenant-bank-account-api.js +29 -18
  58. package/dist/api/webhooks-api.d.ts +2 -2
  59. package/dist/base.d.ts +24 -0
  60. package/dist/base.js +178 -59
  61. package/dist/common.d.ts +1 -1
  62. package/dist/common.js +1 -0
  63. package/dist/configuration.d.ts +17 -0
  64. package/dist/configuration.js +2 -0
  65. package/dist/models/bank-transaction-class.d.ts +7 -0
  66. package/dist/models/bank-transaction-entity.d.ts +7 -0
  67. package/dist/models/index.d.ts +4 -0
  68. package/dist/models/index.js +4 -0
  69. package/dist/models/link-bank-transaction-payment-requests-request-dto-rest.d.ts +30 -0
  70. package/dist/models/link-bank-transaction-payment-requests-request-dto-rest.js +15 -0
  71. package/dist/models/link-bank-transaction-payment-requests-response-class.d.ts +25 -0
  72. package/dist/models/link-bank-transaction-payment-requests-response-class.js +15 -0
  73. package/dist/models/payment-receipt-class.d.ts +12 -0
  74. package/dist/models/payment-receipt-entity.d.ts +139 -0
  75. package/dist/models/payment-receipt-entity.js +20 -0
  76. package/dist/models/payment-request-class.d.ts +1 -0
  77. package/dist/models/payment-request-class.js +1 -0
  78. package/dist/models/payment-request-entity.d.ts +223 -0
  79. package/dist/models/payment-request-entity.js +39 -0
  80. package/models/bank-transaction-class.ts +7 -0
  81. package/models/bank-transaction-entity.ts +7 -0
  82. package/models/index.ts +4 -0
  83. package/models/link-bank-transaction-payment-requests-request-dto-rest.ts +36 -0
  84. package/models/link-bank-transaction-payment-requests-response-class.ts +31 -0
  85. package/models/payment-receipt-class.ts +12 -0
  86. package/models/payment-receipt-entity.ts +148 -0
  87. package/models/payment-request-class.ts +1 -0
  88. package/models/payment-request-entity.ts +233 -0
  89. package/package.json +2 -2
@@ -67,8 +67,10 @@ export const TenantBankAccountApiAxiosParamCreator = function (configuration?: C
67
67
  // http bearer authentication required
68
68
  await setBearerAuthToObject(localVarHeaderParameter, configuration)
69
69
 
70
- if (authorization !== undefined && authorization !== null || baseAccessToken !== undefined && baseAccessToken !== null) {
71
- localVarHeaderParameter['Authorization'] = String(authorization ? authorization : baseAccessToken);
70
+ // Only Authorization falls back to the configured token; an empty value is never sent.
71
+ const authorizationValue = 'Authorization'.toLowerCase() === 'authorization' ? (authorization || baseAccessToken) : authorization;
72
+ if (authorizationValue) {
73
+ localVarHeaderParameter['Authorization'] = String(authorizationValue);
72
74
  }
73
75
 
74
76
 
@@ -115,8 +117,10 @@ export const TenantBankAccountApiAxiosParamCreator = function (configuration?: C
115
117
  // http bearer authentication required
116
118
  await setBearerAuthToObject(localVarHeaderParameter, configuration)
117
119
 
118
- if (authorization !== undefined && authorization !== null || baseAccessToken !== undefined && baseAccessToken !== null) {
119
- localVarHeaderParameter['Authorization'] = String(authorization ? authorization : baseAccessToken);
120
+ // Only Authorization falls back to the configured token; an empty value is never sent.
121
+ const authorizationValue = 'Authorization'.toLowerCase() === 'authorization' ? (authorization || baseAccessToken) : authorization;
122
+ if (authorizationValue) {
123
+ localVarHeaderParameter['Authorization'] = String(authorizationValue);
120
124
  }
121
125
 
122
126
 
@@ -165,8 +169,10 @@ export const TenantBankAccountApiAxiosParamCreator = function (configuration?: C
165
169
  localVarQueryParameter['expand'] = expand;
166
170
  }
167
171
 
168
- if (authorization !== undefined && authorization !== null || baseAccessToken !== undefined && baseAccessToken !== null) {
169
- localVarHeaderParameter['Authorization'] = String(authorization ? authorization : baseAccessToken);
172
+ // Only Authorization falls back to the configured token; an empty value is never sent.
173
+ const authorizationValue = 'Authorization'.toLowerCase() === 'authorization' ? (authorization || baseAccessToken) : authorization;
174
+ if (authorizationValue) {
175
+ localVarHeaderParameter['Authorization'] = String(authorizationValue);
170
176
  }
171
177
 
172
178
 
@@ -241,8 +247,10 @@ export const TenantBankAccountApiAxiosParamCreator = function (configuration?: C
241
247
  localVarQueryParameter['filters'] = filters;
242
248
  }
243
249
 
244
- if (authorization !== undefined && authorization !== null || baseAccessToken !== undefined && baseAccessToken !== null) {
245
- localVarHeaderParameter['Authorization'] = String(authorization ? authorization : baseAccessToken);
250
+ // Only Authorization falls back to the configured token; an empty value is never sent.
251
+ const authorizationValue = 'Authorization'.toLowerCase() === 'authorization' ? (authorization || baseAccessToken) : authorization;
252
+ if (authorizationValue) {
253
+ localVarHeaderParameter['Authorization'] = String(authorizationValue);
246
254
  }
247
255
 
248
256
 
@@ -289,8 +297,10 @@ export const TenantBankAccountApiAxiosParamCreator = function (configuration?: C
289
297
  // http bearer authentication required
290
298
  await setBearerAuthToObject(localVarHeaderParameter, configuration)
291
299
 
292
- if (authorization !== undefined && authorization !== null || baseAccessToken !== undefined && baseAccessToken !== null) {
293
- localVarHeaderParameter['Authorization'] = String(authorization ? authorization : baseAccessToken);
300
+ // Only Authorization falls back to the configured token; an empty value is never sent.
301
+ const authorizationValue = 'Authorization'.toLowerCase() === 'authorization' ? (authorization || baseAccessToken) : authorization;
302
+ if (authorizationValue) {
303
+ localVarHeaderParameter['Authorization'] = String(authorizationValue);
294
304
  }
295
305
 
296
306
 
package/base.ts CHANGED
@@ -32,9 +32,20 @@ export const COLLECTION_FORMATS = {
32
32
  pipes: "|",
33
33
  };
34
34
 
35
+ export interface SessionClass {
36
+ sub: string;
37
+ username?: string;
38
+ email?: string;
39
+ tenantSlug?: string;
40
+ permissions?: string;
41
+ expiresAt?: number;
42
+ }
43
+
35
44
  export interface LoginClass {
36
45
  accessToken: string;
37
46
  permissions: string;
47
+ authMode?: string;
48
+ session?: SessionClass;
38
49
  }
39
50
 
40
51
  export interface SwitchWorkspaceRequest {
@@ -45,6 +56,8 @@ export interface SwitchWorkspaceRequest {
45
56
  export interface SwitchWorkspaceResponseClass {
46
57
  accessToken: string;
47
58
  permissions: string;
59
+ authMode?: string;
60
+ session?: SessionClass;
48
61
  }
49
62
 
50
63
  export enum Environment {
@@ -77,10 +90,19 @@ interface TokenData {
77
90
  accessToken?: string;
78
91
  username?: string;
79
92
  permissions?: string;
93
+ // 'both' or 'session' when authservice keeps the tokens in a server session.
94
+ authMode?: string;
95
+ sub?: string;
80
96
  }
81
97
 
82
98
  const NETWORK_ERROR_MESSAGE = "Network Error";
83
99
  const TOKEN_DATA = 'APP_TOKEN';
100
+ // Sent only to authservice, to ask for a server session.
101
+ const AUTH_MODE_HEADER = 'X-Emil-Auth-Mode';
102
+ // Names the account on every call; one browser session can hold several.
103
+ const ACCOUNT_HEADER = 'X-Emil-Account';
104
+ const SESSION_MODES = ['both', 'session'];
105
+ const RESEND_SAFE_METHODS = ['get', 'head', 'options'];
84
106
 
85
107
  /**
86
108
  *
@@ -102,10 +124,18 @@ export class BaseAPI {
102
124
  this.configuration = configuration;
103
125
  this.basePath = configuration.basePath || this.basePath;
104
126
 
105
- // Use config token if provided, otherwise use tokenData token
106
- const configToken = this.configuration.accessToken;
107
- const storedToken = accessToken ? `Bearer ${accessToken}` : '';
108
- this.configuration.accessToken = configToken || storedToken;
127
+ if (configuration.cookieAuth) {
128
+ this.configuration.username = this.configuration.username || this.tokenData.username;
129
+ }
130
+
131
+ if (this.usesSession()) {
132
+ this.useSessionAuth();
133
+ } else {
134
+ // Use config token if provided, otherwise use tokenData token
135
+ const configToken = this.configuration.accessToken;
136
+ const storedToken = accessToken ? `Bearer ${accessToken}` : '';
137
+ this.configuration.accessToken = configToken || storedToken;
138
+ }
109
139
  } else {
110
140
  const { accessToken, username } = this.tokenData;
111
141
 
@@ -119,6 +149,107 @@ export class BaseAPI {
119
149
  this.attachInterceptor(axios);
120
150
  }
121
151
 
152
+ // The app's own account wins over APP_TOKEN, which holds whichever tab wrote last.
153
+ private sessionAccount(): string | undefined {
154
+ return this.configuration.account || this.tokenData.sub;
155
+ }
156
+
157
+ // Apps may pass the address as the second argument only; authservice is on the same host.
158
+ private authBasePath(): string {
159
+ return this.configuration.basePath || this.basePath;
160
+ }
161
+
162
+ private usesSession(): boolean {
163
+ return !!this.configuration.cookieAuth && SESSION_MODES.indexOf(this.tokenData.authMode) !== -1 && !!this.sessionAccount();
164
+ }
165
+
166
+ private useSessionAuth() {
167
+ const { headers, ...baseOptions } = this.configuration.baseOptions || {};
168
+ this.configuration.accessToken = '';
169
+ this.configuration.baseOptions = {
170
+ ...baseOptions,
171
+ withCredentials: true,
172
+ headers: { ...headers, [ACCOUNT_HEADER]: this.sessionAccount() },
173
+ };
174
+ }
175
+
176
+ private useHeaderAuth(accessToken: string) {
177
+ this.configuration.accessToken = accessToken ? `Bearer ${accessToken}` : '';
178
+ this.tokenData.accessToken = accessToken;
179
+ delete this.tokenData.authMode;
180
+ delete this.tokenData.sub;
181
+ if (this.configuration.cookieAuth) {
182
+ const { withCredentials, headers, ...baseOptions } = this.configuration.baseOptions || {};
183
+ const { [ACCOUNT_HEADER]: account, ...otherHeaders } = headers || {};
184
+ this.configuration.baseOptions = { ...baseOptions, headers: otherHeaders };
185
+ }
186
+ }
187
+
188
+ private applyTokenReply({ accessToken, authMode, session }: LoginClass) {
189
+ if (this.configuration.cookieAuth && SESSION_MODES.indexOf(authMode) !== -1 && session?.sub) {
190
+ this.tokenData.authMode = authMode;
191
+ this.tokenData.sub = session.sub;
192
+ if (this.configuration.account) {
193
+ // A workspace switch moves the app to another account.
194
+ this.configuration.account = session.sub;
195
+ }
196
+ // Both keeps the token for apps not moved yet; session mode keeps no token at all.
197
+ if (authMode === 'both' && accessToken) {
198
+ this.tokenData.accessToken = accessToken;
199
+ } else {
200
+ delete this.tokenData.accessToken;
201
+ }
202
+ this.useSessionAuth();
203
+ } else {
204
+ this.useHeaderAuth(accessToken);
205
+ }
206
+ }
207
+
208
+ private sessionHeaders(): Record<string, string> {
209
+ if (!this.configuration.cookieAuth) {
210
+ return {};
211
+ }
212
+ return {
213
+ [AUTH_MODE_HEADER]: 'session',
214
+ ...(this.usesSession() && { [ACCOUNT_HEADER]: this.sessionAccount() }),
215
+ };
216
+ }
217
+
218
+ private withCurrentAuth(config: AxiosRequestConfig): AxiosRequestConfig {
219
+ delete config.headers['Authorization'];
220
+ delete config.headers[ACCOUNT_HEADER];
221
+ if (this.usesSession()) {
222
+ config.headers[ACCOUNT_HEADER] = this.sessionAccount();
223
+ config.withCredentials = true;
224
+ } else if (this.configuration.accessToken) {
225
+ config.headers['Authorization'] = this.configuration.accessToken;
226
+ }
227
+ return config;
228
+ }
229
+
230
+ // Both keeps the token, so a session call the browser could not complete can be sent again with it.
231
+ private canRetryWithToken(config: AxiosRequestConfig): boolean {
232
+ return !!config.withCredentials && !!config.headers?.[ACCOUNT_HEADER]
233
+ && !!this.tokenData.accessToken && this.tokenData.authMode !== 'session';
234
+ }
235
+
236
+ // A network error can come after the server ran the call, so only a call that is safe to repeat is sent again.
237
+ private canResend(config: AxiosRequestConfig): boolean {
238
+ return RESEND_SAFE_METHODS.indexOf((config.method || 'get').toLowerCase()) !== -1
239
+ || Object.keys(config.headers || {}).some((name) => name.toLowerCase() === 'idempotency-key');
240
+ }
241
+
242
+ private switchToToken() {
243
+ this.useHeaderAuth(this.tokenData.accessToken);
244
+ this.storeTokenData(this.tokenData);
245
+ }
246
+
247
+ private retryWithToken(axios: AxiosInstance, config: AxiosRequestConfig) {
248
+ this.switchToToken();
249
+ config.withCredentials = false;
250
+ return axios(this.withCurrentAuth(config));
251
+ }
252
+
122
253
  selectEnvironment(env: Environment) {
123
254
  this.selectBasePath(env);
124
255
  }
@@ -138,8 +269,8 @@ export class BaseAPI {
138
269
  async authorize(username: string, password: string, targetWorkspace?: string): Promise<void> {
139
270
  const options: AxiosRequestConfig = {
140
271
  method: 'POST',
141
- url: `${this.configuration.basePath}/authservice/v1/login`,
142
- headers: { 'Content-Type': 'application/json' },
272
+ url: `${this.authBasePath()}/authservice/v1/login`,
273
+ headers: { 'Content-Type': 'application/json', ...(this.configuration.cookieAuth && { [AUTH_MODE_HEADER]: 'session' }) },
143
274
  data: {
144
275
  username,
145
276
  password,
@@ -149,13 +280,10 @@ export class BaseAPI {
149
280
 
150
281
  const response = await globalAxios.request<LoginClass>(options);
151
282
 
152
- const { data: { accessToken, permissions } } = response;
153
-
154
283
  this.configuration.username = username;
155
- this.configuration.accessToken = `Bearer ${accessToken}`;
156
284
  this.tokenData.username = username;
157
- this.tokenData.accessToken = accessToken;
158
- this.tokenData.permissions = permissions;
285
+ this.tokenData.permissions = response.data.permissions;
286
+ this.applyTokenReply(response.data);
159
287
 
160
288
  // Switch workspace if provided
161
289
  if (targetWorkspace) {
@@ -175,10 +303,11 @@ export class BaseAPI {
175
303
  async switchWorkspace(targetWorkspace: string): Promise<void> {
176
304
  const options: AxiosRequestConfig = {
177
305
  method: 'POST',
178
- url: `${this.configuration.basePath}/authservice/v1/workspaces/switch`,
306
+ url: `${this.authBasePath()}/authservice/v1/workspaces/switch`,
179
307
  headers: {
180
308
  'Content-Type': 'application/json',
181
- 'Authorization': `Bearer ${this.configuration.accessToken}`,
309
+ ...this.sessionHeaders(),
310
+ ...(!this.usesSession() && !!this.configuration.accessToken && { 'Authorization': this.configuration.accessToken as string }),
182
311
  },
183
312
  data: {
184
313
  username: this.configuration.username,
@@ -189,11 +318,8 @@ export class BaseAPI {
189
318
 
190
319
  const response = await globalAxios.request<SwitchWorkspaceResponseClass>(options);
191
320
 
192
- const { data: { accessToken, permissions } } = response;
193
-
194
- this.configuration.accessToken = `Bearer ${accessToken}`;
195
- this.tokenData.accessToken = accessToken;
196
- this.tokenData.permissions = permissions;
321
+ this.tokenData.permissions = response.data.permissions;
322
+ this.applyTokenReply(response.data);
197
323
 
198
324
  this.storeTokenData({
199
325
  ...this.tokenData
@@ -219,9 +345,10 @@ export class BaseAPI {
219
345
 
220
346
  const options: AxiosRequestConfig = {
221
347
  method: 'POST',
222
- url: `${this.configuration.basePath}/authservice/v1/refresh-token`,
348
+ url: `${this.authBasePath()}/authservice/v1/refresh-token`,
223
349
  headers: {
224
350
  'Content-Type': 'application/json',
351
+ ...this.sessionHeaders(),
225
352
  },
226
353
  data: { username: username },
227
354
  withCredentials: true,
@@ -262,20 +389,22 @@ export class BaseAPI {
262
389
  && !originalConfig._retry) {
263
390
  originalConfig._retry = true;
264
391
  try {
265
- const { accessToken: tokenString, permissions } = await this.refreshTokenInternal();
266
- const accessToken = `Bearer ${tokenString}`;
267
- this.tokenData.permissions = permissions;
268
-
269
- delete originalConfig.headers['Authorization']
270
-
271
- originalConfig.headers['Authorization'] = accessToken;
272
-
273
- this.configuration.accessToken = accessToken;
274
- this.tokenData.accessToken = tokenString;
275
-
392
+ const reply = await this.refreshTokenInternal();
393
+ this.tokenData.permissions = reply.permissions;
394
+ this.applyTokenReply(reply);
276
395
  this.storeTokenData(this.tokenData);
277
396
 
278
- return axios(originalConfig);
397
+ if (!this.usesSession()) {
398
+ return axios(this.withCurrentAuth(originalConfig));
399
+ }
400
+
401
+ // Both mode: if the browser does not send the session cookie (another site), use the token.
402
+ return axios(this.withCurrentAuth(originalConfig)).catch((retryError) => {
403
+ if (retryError?.response?.status !== 401 || !this.tokenData.accessToken) {
404
+ return Promise.reject(retryError);
405
+ }
406
+ return this.retryWithToken(axios, originalConfig);
407
+ });
279
408
  } catch (_error) {
280
409
  if (_error.response && _error.response.data) {
281
410
  return Promise.reject(_error.response.data);
@@ -283,26 +412,30 @@ export class BaseAPI {
283
412
  return Promise.reject(_error);
284
413
  }
285
414
  }
415
+ } else if (err.message === NETWORK_ERROR_MESSAGE && this.canRetryWithToken(originalConfig)) {
416
+ // Both mode: the browser blocked the session call or hid its reply; later calls use the token.
417
+ if (!this.canResend(originalConfig)) {
418
+ this.switchToToken();
419
+ return Promise.reject(err);
420
+ }
421
+ return this.retryWithToken(axios, originalConfig);
286
422
  } else if (err.message === NETWORK_ERROR_MESSAGE
287
- && originalConfig.headers.hasOwnProperty('Authorization')
423
+ && (originalConfig.headers.hasOwnProperty('Authorization')
424
+ || (this.configuration.cookieAuth && originalConfig.withCredentials && this.canResend(originalConfig)))
288
425
  && _retry_count < 4
289
426
  ) {
290
427
  _retry_count++;
291
428
  try {
292
- const { accessToken: tokenString, permissions } = await this.refreshTokenInternal();
293
- const accessToken = `Bearer ${tokenString}`;
294
- this.tokenData.permissions = permissions;
429
+ // In session mode an unreadable 401 (no CORS headers on the error reply) also lands here.
430
+ const reply = await this.refreshTokenInternal();
431
+ this.tokenData.permissions = reply.permissions;
295
432
 
296
433
  _retry = true;
297
- originalConfig.headers['Authorization'] = accessToken;
298
-
299
- this.configuration.accessToken = accessToken;
300
- this.tokenData.accessToken = tokenString;
301
-
434
+ this.applyTokenReply(reply);
302
435
  this.storeTokenData(this.tokenData);
303
436
 
304
437
  return axios.request({
305
- ...originalConfig,
438
+ ...this.withCurrentAuth(originalConfig),
306
439
  });
307
440
  } catch (_error) {
308
441
  if (_error.response && _error.response.data) {
package/common.ts CHANGED
@@ -130,9 +130,10 @@ export const toPathString = function (url: URL) {
130
130
  * @export
131
131
  */
132
132
  export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
133
- return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
133
+ // Typed by hand: since axios 1.20, request() returns an internal axios type that SDK declarations cannot name.
134
+ return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH): Promise<R> => {
134
135
  const axiosRequestArgs = {...axiosArgs.options, url: (configuration?.basePath || basePath) + axiosArgs.url};
135
- return axios.request<T, R>(axiosRequestArgs);
136
+ return axios.request<T, R>(axiosRequestArgs) as Promise<R>;
136
137
  };
137
138
  }
138
139
 
package/configuration.ts CHANGED
@@ -21,6 +21,8 @@ export interface ConfigurationParameters {
21
21
  basePath?: string;
22
22
  baseOptions?: any;
23
23
  formDataCtor?: new () => any;
24
+ cookieAuth?: boolean;
25
+ account?: string;
24
26
  }
25
27
 
26
28
  export class Configuration {
@@ -74,6 +76,22 @@ export class Configuration {
74
76
  */
75
77
  formDataCtor?: new () => any;
76
78
 
79
+ /**
80
+ * Use a server session when authservice makes one; otherwise the token, as without this option.
81
+ * Set `account` too, so each SDK object keeps its own account.
82
+ *
83
+ * @type {boolean}
84
+ * @memberof Configuration
85
+ */
86
+ cookieAuth?: boolean;
87
+ /**
88
+ * The session account (Cognito sub) this app shows, so the SDK never takes another tab's account.
89
+ *
90
+ * @type {string}
91
+ * @memberof Configuration
92
+ */
93
+ account?: string;
94
+
77
95
  constructor(param: ConfigurationParameters = {}) {
78
96
  this.apiKey = param.apiKey;
79
97
  this.username = param.username;
@@ -82,6 +100,8 @@ export class Configuration {
82
100
  this.basePath = param.basePath;
83
101
  this.baseOptions = param.baseOptions;
84
102
  this.formDataCtor = param.formDataCtor;
103
+ this.cookieAuth = param.cookieAuth;
104
+ this.account = param.account;
85
105
  }
86
106
 
87
107
  /**
@@ -409,7 +409,7 @@ export declare class BankAccountsApi extends BaseAPI {
409
409
  * @throws {RequiredError}
410
410
  * @memberof BankAccountsApi
411
411
  */
412
- createBankAccount(requestParameters: BankAccountsApiCreateBankAccountRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<CreateBankAccountResponseClass, any, {}>>;
412
+ createBankAccount(requestParameters: BankAccountsApiCreateBankAccountRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<CreateBankAccountResponseClass, any, {}, any>>;
413
413
  /**
414
414
  * Deletes a bank account by code. If the bank account was primary, then the first available bank account for the specified partner/account will be marked as primary. **Required Permissions** \"payment-management.bank-accounts.delete\"
415
415
  * @summary Delete the bank account
@@ -418,7 +418,7 @@ export declare class BankAccountsApi extends BaseAPI {
418
418
  * @throws {RequiredError}
419
419
  * @memberof BankAccountsApi
420
420
  */
421
- deleteBankAccount(requestParameters: BankAccountsApiDeleteBankAccountRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<object, any, {}>>;
421
+ deleteBankAccount(requestParameters: BankAccountsApiDeleteBankAccountRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<object, any, {}, any>>;
422
422
  /**
423
423
  * Retrieves the details of the bank account that was previously created. Supply the unique bank account code that was returned when you created it and Emil Api will return the corresponding bank account information. **Required Permissions** \"payment-management.bank-accounts.view\"
424
424
  * @summary Retrieve the bank account
@@ -427,7 +427,7 @@ export declare class BankAccountsApi extends BaseAPI {
427
427
  * @throws {RequiredError}
428
428
  * @memberof BankAccountsApi
429
429
  */
430
- getBankAccount(requestParameters: BankAccountsApiGetBankAccountRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<GetBankAccountResponseClass, any, {}>>;
430
+ getBankAccount(requestParameters: BankAccountsApiGetBankAccountRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<GetBankAccountResponseClass, any, {}, any>>;
431
431
  /**
432
432
  * Returns a list of bank accounts you have previously created. The bank accounts are returned in sorted order, with the oldest one appearing first. For more information about pagination, read the Pagination documentation. **Required Permissions** \"payment-management.bank-accounts.view\"
433
433
  * @summary List bank accounts
@@ -436,7 +436,7 @@ export declare class BankAccountsApi extends BaseAPI {
436
436
  * @throws {RequiredError}
437
437
  * @memberof BankAccountsApi
438
438
  */
439
- listBankAccounts(requestParameters?: BankAccountsApiListBankAccountsRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<ListBankAccountsResponseClass, any, {}>>;
439
+ listBankAccounts(requestParameters?: BankAccountsApiListBankAccountsRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<ListBankAccountsResponseClass, any, {}, any>>;
440
440
  /**
441
441
  * Set the primary bank account for the specified partner/account **Required Permissions** \"payment-management.bank-accounts.update\"
442
442
  * @summary Set primary bank account
@@ -445,7 +445,7 @@ export declare class BankAccountsApi extends BaseAPI {
445
445
  * @throws {RequiredError}
446
446
  * @memberof BankAccountsApi
447
447
  */
448
- setPrimaryBankAccount(requestParameters: BankAccountsApiSetPrimaryBankAccountRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<object, any, {}>>;
448
+ setPrimaryBankAccount(requestParameters: BankAccountsApiSetPrimaryBankAccountRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<object, any, {}, any>>;
449
449
  /**
450
450
  * Update a bank account by code **Required Permissions** \"payment-management.bank-accounts.update\"
451
451
  * @summary Update the bank account
@@ -454,5 +454,5 @@ export declare class BankAccountsApi extends BaseAPI {
454
454
  * @throws {RequiredError}
455
455
  * @memberof BankAccountsApi
456
456
  */
457
- updateBankAccount(requestParameters: BankAccountsApiUpdateBankAccountRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<UpdateBankAccountResponseClass, any, {}>>;
457
+ updateBankAccount(requestParameters: BankAccountsApiUpdateBankAccountRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<UpdateBankAccountResponseClass, any, {}, any>>;
458
458
  }