@emilgroup/notification-sdk 0.8.1-beta.63 → 0.8.1-beta.65

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.
@@ -286,7 +286,7 @@ var MSGraphWebhooksApi = /** @class */ (function (_super) {
286
286
  */
287
287
  MSGraphWebhooksApi.prototype.receiveLifecycle = function (requestParameters, options) {
288
288
  var _this = this;
289
- return (0, exports.MSGraphWebhooksApiFp)(this.configuration).receiveLifecycle(requestParameters.tenantSlug, requestParameters.validationToken, requestParameters.body, options).then(function (request) { return request(_this.axios, _this.basePath); });
289
+ return (0, exports.MSGraphWebhooksApiFp)(this.configuration).receiveLifecycle(requestParameters.tenantSlug, requestParameters.validationToken, requestParameters.body, this.withOwner(options)).then(function (request) { return request(_this.axios, _this.basePath); });
290
290
  };
291
291
  /**
292
292
  * Public route called by Microsoft Graph. Echoes `validationToken` as text/plain, otherwise enqueues the notifications and answers 202. See docs/webhooks/msgraph.md. **Required Permissions** none
@@ -298,7 +298,7 @@ var MSGraphWebhooksApi = /** @class */ (function (_super) {
298
298
  */
299
299
  MSGraphWebhooksApi.prototype.receiveNotifications = function (requestParameters, options) {
300
300
  var _this = this;
301
- return (0, exports.MSGraphWebhooksApiFp)(this.configuration).receiveNotifications(requestParameters.tenantSlug, requestParameters.validationToken, requestParameters.body, options).then(function (request) { return request(_this.axios, _this.basePath); });
301
+ return (0, exports.MSGraphWebhooksApiFp)(this.configuration).receiveNotifications(requestParameters.tenantSlug, requestParameters.validationToken, requestParameters.body, this.withOwner(options)).then(function (request) { return request(_this.axios, _this.basePath); });
302
302
  };
303
303
  return MSGraphWebhooksApi;
304
304
  }(base_1.BaseAPI));
@@ -103,9 +103,10 @@ var NotificationTemplatesApiAxiosParamCreator = function (configuration) {
103
103
  createNotificationTemplate: function (createNotificationTemplateRequestDto, authorization, options) {
104
104
  if (options === void 0) { options = {}; }
105
105
  return __awaiter(_this, void 0, void 0, function () {
106
- var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, authorizationValue, headersFromBaseOptions;
107
- return __generator(this, function (_a) {
108
- switch (_a.label) {
106
+ var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, authorizationIsAuth, authorizationValue, authorizationKeepEmpty, headersFromBaseOptions;
107
+ var _a;
108
+ return __generator(this, function (_b) {
109
+ switch (_b.label) {
109
110
  case 0:
110
111
  // verify required parameter 'createNotificationTemplateRequestDto' is not null or undefined
111
112
  (0, common_1.assertParamExists)('createNotificationTemplate', 'createNotificationTemplateRequestDto', createNotificationTemplateRequestDto);
@@ -121,14 +122,17 @@ var NotificationTemplatesApiAxiosParamCreator = function (configuration) {
121
122
  // authentication bearer required
122
123
  // http bearer authentication required
123
124
  return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)
124
- // Only Authorization falls back to the configured token; an empty value is never sent.
125
+ // Only Authorization falls back to the configured token. Without a session it is sent as before, empty when
126
+ // no token is stored, so a refused call still refreshes; a session call (account header) sends none.
125
127
  ];
126
128
  case 1:
127
129
  // authentication bearer required
128
130
  // http bearer authentication required
129
- _a.sent();
130
- authorizationValue = 'Authorization'.toLowerCase() === 'authorization' ? (authorization || baseAccessToken) : authorization;
131
- if (authorizationValue) {
131
+ _b.sent();
132
+ authorizationIsAuth = 'Authorization'.toLowerCase() === 'authorization';
133
+ authorizationValue = authorizationIsAuth ? (authorization || baseAccessToken) : authorization;
134
+ authorizationKeepEmpty = authorizationIsAuth && authorizationValue === '' && !((_a = baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions.headers) === null || _a === void 0 ? void 0 : _a['X-Emil-Account']);
135
+ if (authorizationValue || authorizationKeepEmpty) {
132
136
  localVarHeaderParameter['Authorization'] = String(authorizationValue);
133
137
  }
134
138
  localVarHeaderParameter['Content-Type'] = 'application/json';
@@ -155,9 +159,10 @@ var NotificationTemplatesApiAxiosParamCreator = function (configuration) {
155
159
  deleteNotificationTemplate: function (id, authorization, options) {
156
160
  if (options === void 0) { options = {}; }
157
161
  return __awaiter(_this, void 0, void 0, function () {
158
- var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, authorizationValue, headersFromBaseOptions;
159
- return __generator(this, function (_a) {
160
- switch (_a.label) {
162
+ var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, authorizationIsAuth, authorizationValue, authorizationKeepEmpty, headersFromBaseOptions;
163
+ var _a;
164
+ return __generator(this, function (_b) {
165
+ switch (_b.label) {
161
166
  case 0:
162
167
  // verify required parameter 'id' is not null or undefined
163
168
  (0, common_1.assertParamExists)('deleteNotificationTemplate', 'id', id);
@@ -174,14 +179,17 @@ var NotificationTemplatesApiAxiosParamCreator = function (configuration) {
174
179
  // authentication bearer required
175
180
  // http bearer authentication required
176
181
  return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)
177
- // Only Authorization falls back to the configured token; an empty value is never sent.
182
+ // Only Authorization falls back to the configured token. Without a session it is sent as before, empty when
183
+ // no token is stored, so a refused call still refreshes; a session call (account header) sends none.
178
184
  ];
179
185
  case 1:
180
186
  // authentication bearer required
181
187
  // http bearer authentication required
182
- _a.sent();
183
- authorizationValue = 'Authorization'.toLowerCase() === 'authorization' ? (authorization || baseAccessToken) : authorization;
184
- if (authorizationValue) {
188
+ _b.sent();
189
+ authorizationIsAuth = 'Authorization'.toLowerCase() === 'authorization';
190
+ authorizationValue = authorizationIsAuth ? (authorization || baseAccessToken) : authorization;
191
+ authorizationKeepEmpty = authorizationIsAuth && authorizationValue === '' && !((_a = baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions.headers) === null || _a === void 0 ? void 0 : _a['X-Emil-Account']);
192
+ if (authorizationValue || authorizationKeepEmpty) {
185
193
  localVarHeaderParameter['Authorization'] = String(authorizationValue);
186
194
  }
187
195
  (0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
@@ -208,9 +216,10 @@ var NotificationTemplatesApiAxiosParamCreator = function (configuration) {
208
216
  getNotificationTemplate: function (id, id2, authorization, expand, options) {
209
217
  if (options === void 0) { options = {}; }
210
218
  return __awaiter(_this, void 0, void 0, function () {
211
- var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, authorizationValue, headersFromBaseOptions;
212
- return __generator(this, function (_a) {
213
- switch (_a.label) {
219
+ var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, authorizationIsAuth, authorizationValue, authorizationKeepEmpty, headersFromBaseOptions;
220
+ var _a;
221
+ return __generator(this, function (_b) {
222
+ switch (_b.label) {
214
223
  case 0:
215
224
  // verify required parameter 'id' is not null or undefined
216
225
  (0, common_1.assertParamExists)('getNotificationTemplate', 'id', id);
@@ -232,15 +241,17 @@ var NotificationTemplatesApiAxiosParamCreator = function (configuration) {
232
241
  case 1:
233
242
  // authentication bearer required
234
243
  // http bearer authentication required
235
- _a.sent();
244
+ _b.sent();
236
245
  if (id2 !== undefined) {
237
246
  localVarQueryParameter['id'] = id2;
238
247
  }
239
248
  if (expand !== undefined) {
240
249
  localVarQueryParameter['expand'] = expand;
241
250
  }
242
- authorizationValue = 'Authorization'.toLowerCase() === 'authorization' ? (authorization || baseAccessToken) : authorization;
243
- if (authorizationValue) {
251
+ authorizationIsAuth = 'Authorization'.toLowerCase() === 'authorization';
252
+ authorizationValue = authorizationIsAuth ? (authorization || baseAccessToken) : authorization;
253
+ authorizationKeepEmpty = authorizationIsAuth && authorizationValue === '' && !((_a = baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions.headers) === null || _a === void 0 ? void 0 : _a['X-Emil-Account']);
254
+ if (authorizationValue || authorizationKeepEmpty) {
244
255
  localVarHeaderParameter['Authorization'] = String(authorizationValue);
245
256
  }
246
257
  (0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
@@ -271,9 +282,10 @@ var NotificationTemplatesApiAxiosParamCreator = function (configuration) {
271
282
  listNotificationTemplates: function (authorization, pageSize, pageToken, filter, search, order, expand, filters, options) {
272
283
  if (options === void 0) { options = {}; }
273
284
  return __awaiter(_this, void 0, void 0, function () {
274
- var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, authorizationValue, headersFromBaseOptions;
275
- return __generator(this, function (_a) {
276
- switch (_a.label) {
285
+ var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, authorizationIsAuth, authorizationValue, authorizationKeepEmpty, headersFromBaseOptions;
286
+ var _a;
287
+ return __generator(this, function (_b) {
288
+ switch (_b.label) {
277
289
  case 0:
278
290
  localVarPath = "/notificationservice/v1/notification-templates";
279
291
  localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
@@ -290,7 +302,7 @@ var NotificationTemplatesApiAxiosParamCreator = function (configuration) {
290
302
  case 1:
291
303
  // authentication bearer required
292
304
  // http bearer authentication required
293
- _a.sent();
305
+ _b.sent();
294
306
  if (pageSize !== undefined) {
295
307
  localVarQueryParameter['pageSize'] = pageSize;
296
308
  }
@@ -312,8 +324,10 @@ var NotificationTemplatesApiAxiosParamCreator = function (configuration) {
312
324
  if (filters !== undefined) {
313
325
  localVarQueryParameter['filters'] = filters;
314
326
  }
315
- authorizationValue = 'Authorization'.toLowerCase() === 'authorization' ? (authorization || baseAccessToken) : authorization;
316
- if (authorizationValue) {
327
+ authorizationIsAuth = 'Authorization'.toLowerCase() === 'authorization';
328
+ authorizationValue = authorizationIsAuth ? (authorization || baseAccessToken) : authorization;
329
+ authorizationKeepEmpty = authorizationIsAuth && authorizationValue === '' && !((_a = baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions.headers) === null || _a === void 0 ? void 0 : _a['X-Emil-Account']);
330
+ if (authorizationValue || authorizationKeepEmpty) {
317
331
  localVarHeaderParameter['Authorization'] = String(authorizationValue);
318
332
  }
319
333
  (0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
@@ -339,9 +353,10 @@ var NotificationTemplatesApiAxiosParamCreator = function (configuration) {
339
353
  updateNotificationTemplate: function (id, updateNotificationTemplateRequestDto, authorization, options) {
340
354
  if (options === void 0) { options = {}; }
341
355
  return __awaiter(_this, void 0, void 0, function () {
342
- var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, authorizationValue, headersFromBaseOptions;
343
- return __generator(this, function (_a) {
344
- switch (_a.label) {
356
+ var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, authorizationIsAuth, authorizationValue, authorizationKeepEmpty, headersFromBaseOptions;
357
+ var _a;
358
+ return __generator(this, function (_b) {
359
+ switch (_b.label) {
345
360
  case 0:
346
361
  // verify required parameter 'id' is not null or undefined
347
362
  (0, common_1.assertParamExists)('updateNotificationTemplate', 'id', id);
@@ -360,14 +375,17 @@ var NotificationTemplatesApiAxiosParamCreator = function (configuration) {
360
375
  // authentication bearer required
361
376
  // http bearer authentication required
362
377
  return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)
363
- // Only Authorization falls back to the configured token; an empty value is never sent.
378
+ // Only Authorization falls back to the configured token. Without a session it is sent as before, empty when
379
+ // no token is stored, so a refused call still refreshes; a session call (account header) sends none.
364
380
  ];
365
381
  case 1:
366
382
  // authentication bearer required
367
383
  // http bearer authentication required
368
- _a.sent();
369
- authorizationValue = 'Authorization'.toLowerCase() === 'authorization' ? (authorization || baseAccessToken) : authorization;
370
- if (authorizationValue) {
384
+ _b.sent();
385
+ authorizationIsAuth = 'Authorization'.toLowerCase() === 'authorization';
386
+ authorizationValue = authorizationIsAuth ? (authorization || baseAccessToken) : authorization;
387
+ authorizationKeepEmpty = authorizationIsAuth && authorizationValue === '' && !((_a = baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions.headers) === null || _a === void 0 ? void 0 : _a['X-Emil-Account']);
388
+ if (authorizationValue || authorizationKeepEmpty) {
371
389
  localVarHeaderParameter['Authorization'] = String(authorizationValue);
372
390
  }
373
391
  localVarHeaderParameter['Content-Type'] = 'application/json';
@@ -605,7 +623,7 @@ var NotificationTemplatesApi = /** @class */ (function (_super) {
605
623
  */
606
624
  NotificationTemplatesApi.prototype.createNotificationTemplate = function (requestParameters, options) {
607
625
  var _this = this;
608
- return (0, exports.NotificationTemplatesApiFp)(this.configuration).createNotificationTemplate(requestParameters.createNotificationTemplateRequestDto, requestParameters.authorization, options).then(function (request) { return request(_this.axios, _this.basePath); });
626
+ return (0, exports.NotificationTemplatesApiFp)(this.configuration).createNotificationTemplate(requestParameters.createNotificationTemplateRequestDto, requestParameters.authorization, this.withOwner(options)).then(function (request) { return request(_this.axios, _this.basePath); });
609
627
  };
610
628
  /**
611
629
  * Permanently deletes the notification template with the given id. **Required Permissions** \"notification-management.email-templates.delete\"
@@ -617,7 +635,7 @@ var NotificationTemplatesApi = /** @class */ (function (_super) {
617
635
  */
618
636
  NotificationTemplatesApi.prototype.deleteNotificationTemplate = function (requestParameters, options) {
619
637
  var _this = this;
620
- return (0, exports.NotificationTemplatesApiFp)(this.configuration).deleteNotificationTemplate(requestParameters.id, requestParameters.authorization, options).then(function (request) { return request(_this.axios, _this.basePath); });
638
+ return (0, exports.NotificationTemplatesApiFp)(this.configuration).deleteNotificationTemplate(requestParameters.id, requestParameters.authorization, this.withOwner(options)).then(function (request) { return request(_this.axios, _this.basePath); });
621
639
  };
622
640
  /**
623
641
  * Retrieves the details of the notification template with the given id. **Required Permissions** \"notification-management.email-templates.view\"
@@ -629,7 +647,7 @@ var NotificationTemplatesApi = /** @class */ (function (_super) {
629
647
  */
630
648
  NotificationTemplatesApi.prototype.getNotificationTemplate = function (requestParameters, options) {
631
649
  var _this = this;
632
- return (0, exports.NotificationTemplatesApiFp)(this.configuration).getNotificationTemplate(requestParameters.id, requestParameters.id2, requestParameters.authorization, requestParameters.expand, options).then(function (request) { return request(_this.axios, _this.basePath); });
650
+ return (0, exports.NotificationTemplatesApiFp)(this.configuration).getNotificationTemplate(requestParameters.id, requestParameters.id2, requestParameters.authorization, requestParameters.expand, this.withOwner(options)).then(function (request) { return request(_this.axios, _this.basePath); });
633
651
  };
634
652
  /**
635
653
  * Returns a list of notification templates. For more information about pagination, read the Pagination documentation. **Required Permissions** \"notification-management.email-templates.view\"
@@ -642,7 +660,7 @@ var NotificationTemplatesApi = /** @class */ (function (_super) {
642
660
  NotificationTemplatesApi.prototype.listNotificationTemplates = function (requestParameters, options) {
643
661
  var _this = this;
644
662
  if (requestParameters === void 0) { requestParameters = {}; }
645
- return (0, exports.NotificationTemplatesApiFp)(this.configuration).listNotificationTemplates(requestParameters.authorization, requestParameters.pageSize, requestParameters.pageToken, requestParameters.filter, requestParameters.search, requestParameters.order, requestParameters.expand, requestParameters.filters, options).then(function (request) { return request(_this.axios, _this.basePath); });
663
+ return (0, exports.NotificationTemplatesApiFp)(this.configuration).listNotificationTemplates(requestParameters.authorization, requestParameters.pageSize, requestParameters.pageToken, requestParameters.filter, requestParameters.search, requestParameters.order, requestParameters.expand, requestParameters.filters, this.withOwner(options)).then(function (request) { return request(_this.axios, _this.basePath); });
646
664
  };
647
665
  /**
648
666
  * Updates the specified notification template by setting the values of the parameters passed. Any parameters not provided will be left unchanged. **Required Permissions** \"notification-management.email-templates.update\"
@@ -654,7 +672,7 @@ var NotificationTemplatesApi = /** @class */ (function (_super) {
654
672
  */
655
673
  NotificationTemplatesApi.prototype.updateNotificationTemplate = function (requestParameters, options) {
656
674
  var _this = this;
657
- return (0, exports.NotificationTemplatesApiFp)(this.configuration).updateNotificationTemplate(requestParameters.id, requestParameters.updateNotificationTemplateRequestDto, requestParameters.authorization, options).then(function (request) { return request(_this.axios, _this.basePath); });
675
+ return (0, exports.NotificationTemplatesApiFp)(this.configuration).updateNotificationTemplate(requestParameters.id, requestParameters.updateNotificationTemplateRequestDto, requestParameters.authorization, this.withOwner(options)).then(function (request) { return request(_this.axios, _this.basePath); });
658
676
  };
659
677
  return NotificationTemplatesApi;
660
678
  }(base_1.BaseAPI));
@@ -103,9 +103,10 @@ var NotificationsApiAxiosParamCreator = function (configuration) {
103
103
  sendEmail: function (sendEmailRequestDto, authorization, options) {
104
104
  if (options === void 0) { options = {}; }
105
105
  return __awaiter(_this, void 0, void 0, function () {
106
- var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, authorizationValue, headersFromBaseOptions;
107
- return __generator(this, function (_a) {
108
- switch (_a.label) {
106
+ var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, authorizationIsAuth, authorizationValue, authorizationKeepEmpty, headersFromBaseOptions;
107
+ var _a;
108
+ return __generator(this, function (_b) {
109
+ switch (_b.label) {
109
110
  case 0:
110
111
  // verify required parameter 'sendEmailRequestDto' is not null or undefined
111
112
  (0, common_1.assertParamExists)('sendEmail', 'sendEmailRequestDto', sendEmailRequestDto);
@@ -121,14 +122,17 @@ var NotificationsApiAxiosParamCreator = function (configuration) {
121
122
  // authentication bearer required
122
123
  // http bearer authentication required
123
124
  return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)
124
- // Only Authorization falls back to the configured token; an empty value is never sent.
125
+ // Only Authorization falls back to the configured token. Without a session it is sent as before, empty when
126
+ // no token is stored, so a refused call still refreshes; a session call (account header) sends none.
125
127
  ];
126
128
  case 1:
127
129
  // authentication bearer required
128
130
  // http bearer authentication required
129
- _a.sent();
130
- authorizationValue = 'Authorization'.toLowerCase() === 'authorization' ? (authorization || baseAccessToken) : authorization;
131
- if (authorizationValue) {
131
+ _b.sent();
132
+ authorizationIsAuth = 'Authorization'.toLowerCase() === 'authorization';
133
+ authorizationValue = authorizationIsAuth ? (authorization || baseAccessToken) : authorization;
134
+ authorizationKeepEmpty = authorizationIsAuth && authorizationValue === '' && !((_a = baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions.headers) === null || _a === void 0 ? void 0 : _a['X-Emil-Account']);
135
+ if (authorizationValue || authorizationKeepEmpty) {
132
136
  localVarHeaderParameter['Authorization'] = String(authorizationValue);
133
137
  }
134
138
  localVarHeaderParameter['Content-Type'] = 'application/json';
@@ -155,9 +159,10 @@ var NotificationsApiAxiosParamCreator = function (configuration) {
155
159
  sendNotification: function (sendNotificationRequestDto, authorization, options) {
156
160
  if (options === void 0) { options = {}; }
157
161
  return __awaiter(_this, void 0, void 0, function () {
158
- var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, authorizationValue, headersFromBaseOptions;
159
- return __generator(this, function (_a) {
160
- switch (_a.label) {
162
+ var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, authorizationIsAuth, authorizationValue, authorizationKeepEmpty, headersFromBaseOptions;
163
+ var _a;
164
+ return __generator(this, function (_b) {
165
+ switch (_b.label) {
161
166
  case 0:
162
167
  // verify required parameter 'sendNotificationRequestDto' is not null or undefined
163
168
  (0, common_1.assertParamExists)('sendNotification', 'sendNotificationRequestDto', sendNotificationRequestDto);
@@ -173,14 +178,17 @@ var NotificationsApiAxiosParamCreator = function (configuration) {
173
178
  // authentication bearer required
174
179
  // http bearer authentication required
175
180
  return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)
176
- // Only Authorization falls back to the configured token; an empty value is never sent.
181
+ // Only Authorization falls back to the configured token. Without a session it is sent as before, empty when
182
+ // no token is stored, so a refused call still refreshes; a session call (account header) sends none.
177
183
  ];
178
184
  case 1:
179
185
  // authentication bearer required
180
186
  // http bearer authentication required
181
- _a.sent();
182
- authorizationValue = 'Authorization'.toLowerCase() === 'authorization' ? (authorization || baseAccessToken) : authorization;
183
- if (authorizationValue) {
187
+ _b.sent();
188
+ authorizationIsAuth = 'Authorization'.toLowerCase() === 'authorization';
189
+ authorizationValue = authorizationIsAuth ? (authorization || baseAccessToken) : authorization;
190
+ authorizationKeepEmpty = authorizationIsAuth && authorizationValue === '' && !((_a = baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions.headers) === null || _a === void 0 ? void 0 : _a['X-Emil-Account']);
191
+ if (authorizationValue || authorizationKeepEmpty) {
184
192
  localVarHeaderParameter['Authorization'] = String(authorizationValue);
185
193
  }
186
194
  localVarHeaderParameter['Content-Type'] = 'application/json';
@@ -304,7 +312,7 @@ var NotificationsApi = /** @class */ (function (_super) {
304
312
  */
305
313
  NotificationsApi.prototype.sendEmail = function (requestParameters, options) {
306
314
  var _this = this;
307
- return (0, exports.NotificationsApiFp)(this.configuration).sendEmail(requestParameters.sendEmailRequestDto, requestParameters.authorization, options).then(function (request) { return request(_this.axios, _this.basePath); });
315
+ return (0, exports.NotificationsApiFp)(this.configuration).sendEmail(requestParameters.sendEmailRequestDto, requestParameters.authorization, this.withOwner(options)).then(function (request) { return request(_this.axios, _this.basePath); });
308
316
  };
309
317
  /**
310
318
  * Sends an email using the notification template identified by `templateSlug`. Provide `entityType` and `entityCode` to track replies in an email thread. **Required Permissions** none
@@ -316,7 +324,7 @@ var NotificationsApi = /** @class */ (function (_super) {
316
324
  */
317
325
  NotificationsApi.prototype.sendNotification = function (requestParameters, options) {
318
326
  var _this = this;
319
- return (0, exports.NotificationsApiFp)(this.configuration).sendNotification(requestParameters.sendNotificationRequestDto, requestParameters.authorization, options).then(function (request) { return request(_this.axios, _this.basePath); });
327
+ return (0, exports.NotificationsApiFp)(this.configuration).sendNotification(requestParameters.sendNotificationRequestDto, requestParameters.authorization, this.withOwner(options)).then(function (request) { return request(_this.axios, _this.basePath); });
320
328
  };
321
329
  return NotificationsApi;
322
330
  }(base_1.BaseAPI));
package/dist/base.d.ts CHANGED
@@ -96,6 +96,8 @@ export declare class BaseAPI {
96
96
  private storeTokenData;
97
97
  loadTokenData(): void;
98
98
  cleanTokenData(): void;
99
+ private ownAccount;
100
+ protected withOwner(options?: AxiosRequestConfig): AxiosRequestConfig;
99
101
  private attachInterceptor;
100
102
  }
101
103
  /**
package/dist/base.js CHANGED
@@ -117,6 +117,9 @@ var Environment;
117
117
  })(Environment = exports.Environment || (exports.Environment = {}));
118
118
  var _retry_count = 0;
119
119
  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';
120
123
  function resetRetry() {
121
124
  _retry_count = 0;
122
125
  }
@@ -142,6 +145,15 @@ var BaseAPI = /** @class */ (function () {
142
145
  this.axios = axios;
143
146
  this.loadTokenData();
144
147
  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
+ }
145
157
  var accessToken = this.tokenData.accessToken;
146
158
  this.configuration = configuration;
147
159
  this.basePath = configuration.basePath || this.basePath;
@@ -185,19 +197,24 @@ var BaseAPI = /** @class */ (function () {
185
197
  this.configuration.accessToken = '';
186
198
  this.configuration.baseOptions = __assign(__assign({}, baseOptions), { withCredentials: true, headers: __assign(__assign({}, headers), (_a = {}, _a[ACCOUNT_HEADER] = this.sessionAccount(), _a)) });
187
199
  };
188
- BaseAPI.prototype.useHeaderAuth = function (accessToken) {
200
+ BaseAPI.prototype.useHeaderAuth = function (accessToken, keepSessionData) {
201
+ if (keepSessionData === void 0) { keepSessionData = false; }
189
202
  this.configuration.accessToken = accessToken ? "Bearer ".concat(accessToken) : '';
190
203
  this.tokenData.accessToken = accessToken;
191
- delete this.tokenData.authMode;
192
- delete this.tokenData.sub;
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
+ }
193
209
  if (this.configuration.cookieAuth) {
194
210
  var _a = this.configuration.baseOptions || {}, withCredentials = _a.withCredentials, headers = _a.headers, baseOptions = __rest(_a, ["withCredentials", "headers"]);
195
211
  var _b = headers || {}, _c = ACCOUNT_HEADER, account = _b[_c], otherHeaders = __rest(_b, [typeof _c === "symbol" ? _c : _c + ""]);
196
212
  this.configuration.baseOptions = __assign(__assign({}, baseOptions), { headers: otherHeaders });
197
213
  }
198
214
  };
199
- BaseAPI.prototype.applyTokenReply = function (_a) {
215
+ BaseAPI.prototype.applyTokenReply = function (_a, fromRefresh) {
200
216
  var accessToken = _a.accessToken, authMode = _a.authMode, session = _a.session;
217
+ if (fromRefresh === void 0) { fromRefresh = false; }
201
218
  if (this.configuration.cookieAuth && SESSION_MODES.indexOf(authMode) !== -1 && (session === null || session === void 0 ? void 0 : session.sub)) {
202
219
  this.tokenData.authMode = authMode;
203
220
  this.tokenData.sub = session.sub;
@@ -215,7 +232,7 @@ var BaseAPI = /** @class */ (function () {
215
232
  this.useSessionAuth();
216
233
  }
217
234
  else {
218
- this.useHeaderAuth(accessToken);
235
+ this.useHeaderAuth(accessToken, fromRefresh);
219
236
  }
220
237
  };
221
238
  BaseAPI.prototype.sessionHeaders = function () {
@@ -350,8 +367,35 @@ var BaseAPI = /** @class */ (function () {
350
367
  }
351
368
  refreshTokenAxios = axios_1.default.create();
352
369
  refreshTokenAxios.interceptors.response.use(function (response) {
353
- var permissions = response.data.permissions;
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
+ }
354
389
  _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
+ }
355
399
  _this.storeTokenData(_this.tokenData);
356
400
  return response;
357
401
  });
@@ -386,17 +430,32 @@ var BaseAPI = /** @class */ (function () {
386
430
  BaseAPI.prototype.cleanTokenData = function () {
387
431
  this.storeTokenData(null);
388
432
  };
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
+ };
389
444
  BaseAPI.prototype.attachInterceptor = function (axios) {
390
445
  var _this = this;
391
446
  axios.interceptors.response.use(function (res) {
392
447
  return res;
393
448
  }, function (err) { return __awaiter(_this, void 0, void 0, function () {
394
- var originalConfig, reply, _error_1, reply, _error_2;
449
+ var originalConfig, owner, reply, _error_1, reply, _error_2;
395
450
  var _this = this;
396
451
  return __generator(this, function (_a) {
397
452
  switch (_a.label) {
398
453
  case 0:
399
454
  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
+ }
400
459
  if (!(err.response && !(err.response instanceof XMLHttpRequest))) return [3 /*break*/, 5];
401
460
  if (!((err.response.status === 401 || err.response.status === 403)
402
461
  && !originalConfig._retry)) return [3 /*break*/, 4];
@@ -408,7 +467,7 @@ var BaseAPI = /** @class */ (function () {
408
467
  case 2:
409
468
  reply = _a.sent();
410
469
  this.tokenData.permissions = reply.permissions;
411
- this.applyTokenReply(reply);
470
+ this.applyTokenReply(reply, true);
412
471
  this.storeTokenData(this.tokenData);
413
472
  if (!this.usesSession()) {
414
473
  return [2 /*return*/, axios(this.withCurrentAuth(originalConfig))];
@@ -450,9 +509,14 @@ var BaseAPI = /** @class */ (function () {
450
509
  reply = _a.sent();
451
510
  this.tokenData.permissions = reply.permissions;
452
511
  _retry = true;
453
- this.applyTokenReply(reply);
512
+ this.applyTokenReply(reply, true);
454
513
  this.storeTokenData(this.tokenData);
455
- return [2 /*return*/, axios.request(__assign({}, this.withCurrentAuth(originalConfig)))];
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
+ })];
456
520
  case 9:
457
521
  _error_2 = _a.sent();
458
522
  if (_error_2.response && _error_2.response.data) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emilgroup/notification-sdk",
3
- "version": "0.8.1-beta.63",
3
+ "version": "0.8.1-beta.65",
4
4
  "description": "OpenAPI client for @emilgroup/notification-sdk",
5
5
  "author": "OpenAPI-Generator Contributors",
6
6
  "keywords": [