@emilgroup/notification-sdk 0.8.1-beta.59 → 0.8.1-beta.6

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 (110) hide show
  1. package/.openapi-generator/FILES +0 -23
  2. package/README.md +2 -2
  3. package/api/email-messages-api.ts +36 -56
  4. package/api/email-tracking-api.ts +48 -291
  5. package/api/email-verifications-api.ts +12 -24
  6. package/api/layouts-api.ts +46 -76
  7. package/api/notification-templates-api.ts +46 -76
  8. package/api/notifications-api.ts +6 -121
  9. package/api.ts +0 -6
  10. package/base.ts +41 -174
  11. package/configuration.ts +0 -20
  12. package/dist/api/email-messages-api.d.ts +28 -40
  13. package/dist/api/email-messages-api.js +40 -62
  14. package/dist/api/email-tracking-api.d.ts +40 -170
  15. package/dist/api/email-tracking-api.js +48 -261
  16. package/dist/api/email-verifications-api.d.ts +8 -16
  17. package/dist/api/email-verifications-api.js +16 -30
  18. package/dist/api/layouts-api.d.ts +36 -56
  19. package/dist/api/layouts-api.js +50 -81
  20. package/dist/api/notification-templates-api.d.ts +36 -56
  21. package/dist/api/notification-templates-api.js +50 -81
  22. package/dist/api/notifications-api.d.ts +4 -65
  23. package/dist/api/notifications-api.js +8 -111
  24. package/dist/api.d.ts +0 -3
  25. package/dist/api.js +0 -3
  26. package/dist/base.d.ts +0 -24
  27. package/dist/base.js +59 -178
  28. package/dist/configuration.d.ts +0 -17
  29. package/dist/configuration.js +0 -2
  30. package/dist/models/email-message-class.d.ts +7 -73
  31. package/dist/models/email-message-class.js +3 -22
  32. package/dist/models/email-thread-class.d.ts +5 -37
  33. package/dist/models/index.d.ts +0 -20
  34. package/dist/models/index.js +0 -20
  35. package/dist/models/send-notification-request-dto.d.ts +1 -10
  36. package/dist/models/send-notification-request-dto.js +1 -2
  37. package/models/email-message-class.ts +8 -78
  38. package/models/email-thread-class.ts +5 -37
  39. package/models/index.ts +0 -20
  40. package/models/send-notification-request-dto.ts +2 -9
  41. package/package.json +1 -1
  42. package/api/email-mailboxes-api.ts +0 -150
  43. package/api/email-subscriptions-api.ts +0 -781
  44. package/api/msgraph-webhooks-api.ts +0 -278
  45. package/dist/api/email-mailboxes-api.d.ts +0 -87
  46. package/dist/api/email-mailboxes-api.js +0 -221
  47. package/dist/api/email-subscriptions-api.d.ts +0 -432
  48. package/dist/api/email-subscriptions-api.js +0 -738
  49. package/dist/api/msgraph-webhooks-api.d.ts +0 -168
  50. package/dist/api/msgraph-webhooks-api.js +0 -305
  51. package/dist/models/assign-email-thread-entity-body-dto.d.ts +0 -43
  52. package/dist/models/assign-email-thread-entity-body-dto.js +0 -22
  53. package/dist/models/assign-email-thread-entity-response-class.d.ts +0 -25
  54. package/dist/models/assign-email-thread-entity-response-class.js +0 -15
  55. package/dist/models/catch-up-email-subscription-response-class.d.ts +0 -24
  56. package/dist/models/catch-up-email-subscription-response-class.js +0 -15
  57. package/dist/models/catch-up-email-subscriptions-request-dto.d.ts +0 -24
  58. package/dist/models/catch-up-email-subscriptions-request-dto.js +0 -15
  59. package/dist/models/catch-up-email-subscriptions-response-class.d.ts +0 -30
  60. package/dist/models/catch-up-email-subscriptions-response-class.js +0 -15
  61. package/dist/models/email-mailbox-class.d.ts +0 -47
  62. package/dist/models/email-mailbox-class.js +0 -20
  63. package/dist/models/email-message-summary-class.d.ts +0 -98
  64. package/dist/models/email-message-summary-class.js +0 -33
  65. package/dist/models/email-subscription-class.d.ts +0 -110
  66. package/dist/models/email-subscription-class.js +0 -23
  67. package/dist/models/entity-ref-class.d.ts +0 -37
  68. package/dist/models/entity-ref-class.js +0 -22
  69. package/dist/models/get-email-subscription-response-class.d.ts +0 -25
  70. package/dist/models/get-email-subscription-response-class.js +0 -15
  71. package/dist/models/grpc-send-email-request-dto.d.ts +0 -137
  72. package/dist/models/grpc-send-email-request-dto.js +0 -22
  73. package/dist/models/inline-attachment-dto.d.ts +0 -36
  74. package/dist/models/inline-attachment-dto.js +0 -15
  75. package/dist/models/list-email-mailboxes-response-class.d.ts +0 -43
  76. package/dist/models/list-email-mailboxes-response-class.js +0 -15
  77. package/dist/models/list-email-subscriptions-response-class.d.ts +0 -43
  78. package/dist/models/list-email-subscriptions-response-class.js +0 -15
  79. package/dist/models/reconcile-email-subscriptions-request-dto.d.ts +0 -24
  80. package/dist/models/reconcile-email-subscriptions-request-dto.js +0 -15
  81. package/dist/models/reconcile-email-subscriptions-response-class.d.ts +0 -48
  82. package/dist/models/reconcile-email-subscriptions-response-class.js +0 -15
  83. package/dist/models/renew-email-subscription-response-class.d.ts +0 -25
  84. package/dist/models/renew-email-subscription-response-class.js +0 -15
  85. package/dist/models/send-email-request-dto.d.ts +0 -131
  86. package/dist/models/send-email-request-dto.js +0 -22
  87. package/dist/models/send-email-response-class.d.ts +0 -24
  88. package/dist/models/send-email-response-class.js +0 -15
  89. package/dist/models/unassign-email-thread-entity-response-class.d.ts +0 -25
  90. package/dist/models/unassign-email-thread-entity-response-class.js +0 -15
  91. package/models/assign-email-thread-entity-body-dto.ts +0 -52
  92. package/models/assign-email-thread-entity-response-class.ts +0 -31
  93. package/models/catch-up-email-subscription-response-class.ts +0 -30
  94. package/models/catch-up-email-subscriptions-request-dto.ts +0 -30
  95. package/models/catch-up-email-subscriptions-response-class.ts +0 -36
  96. package/models/email-mailbox-class.ts +0 -56
  97. package/models/email-message-summary-class.ts +0 -109
  98. package/models/email-subscription-class.ts +0 -119
  99. package/models/entity-ref-class.ts +0 -46
  100. package/models/get-email-subscription-response-class.ts +0 -31
  101. package/models/grpc-send-email-request-dto.ts +0 -144
  102. package/models/inline-attachment-dto.ts +0 -42
  103. package/models/list-email-mailboxes-response-class.ts +0 -49
  104. package/models/list-email-subscriptions-response-class.ts +0 -49
  105. package/models/reconcile-email-subscriptions-request-dto.ts +0 -30
  106. package/models/reconcile-email-subscriptions-response-class.ts +0 -54
  107. package/models/renew-email-subscription-response-class.ts +0 -31
  108. package/models/send-email-request-dto.ts +0 -138
  109. package/models/send-email-response-class.ts +0 -30
  110. package/models/unassign-email-thread-entity-response-class.ts +0 -31
@@ -93,60 +93,7 @@ var NotificationsApiAxiosParamCreator = function (configuration) {
93
93
  var _this = this;
94
94
  return {
95
95
  /**
96
- * Sends an email with a caller-supplied HTML and/or text body, delivered as given. Attachments can reference documents already in S3 or be sent inline as base64. **Required Permissions** none
97
- * @summary Send an email without a template
98
- * @param {SendEmailRequestDto} sendEmailRequestDto
99
- * @param {string} [authorization] Bearer Token
100
- * @param {*} [options] Override http request option.
101
- * @throws {RequiredError}
102
- */
103
- sendEmail: function (sendEmailRequestDto, authorization, options) {
104
- if (options === void 0) { options = {}; }
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) {
109
- case 0:
110
- // verify required parameter 'sendEmailRequestDto' is not null or undefined
111
- (0, common_1.assertParamExists)('sendEmail', 'sendEmailRequestDto', sendEmailRequestDto);
112
- localVarPath = "/notificationservice/v1/notifications/emails";
113
- localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
114
- if (configuration) {
115
- baseOptions = configuration.baseOptions;
116
- baseAccessToken = configuration.accessToken;
117
- }
118
- localVarRequestOptions = __assign(__assign({ method: 'POST' }, baseOptions), options);
119
- localVarHeaderParameter = {};
120
- localVarQueryParameter = {};
121
- // authentication bearer required
122
- // http bearer authentication required
123
- 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
- ];
126
- case 1:
127
- // authentication bearer required
128
- // http bearer authentication required
129
- _a.sent();
130
- authorizationValue = 'Authorization'.toLowerCase() === 'authorization' ? (authorization || baseAccessToken) : authorization;
131
- if (authorizationValue) {
132
- localVarHeaderParameter['Authorization'] = String(authorizationValue);
133
- }
134
- localVarHeaderParameter['Content-Type'] = 'application/json';
135
- (0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
136
- headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
137
- localVarRequestOptions.headers = __assign(__assign(__assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
138
- localVarRequestOptions.data = (0, common_1.serializeDataIfNeeded)(sendEmailRequestDto, localVarRequestOptions, configuration);
139
- return [2 /*return*/, {
140
- url: (0, common_1.toPathString)(localVarUrlObj),
141
- options: localVarRequestOptions,
142
- }];
143
- }
144
- });
145
- });
146
- },
147
- /**
148
- * Sends an email using the notification template identified by `templateSlug`. Provide `entityType` and `entityCode` to track replies in an email thread. **Required Permissions** none
149
- * @summary Send a notification
96
+ * undefined **Required Permissions** none
150
97
  * @param {SendNotificationRequestDto} sendNotificationRequestDto
151
98
  * @param {string} [authorization] Bearer Token
152
99
  * @param {*} [options] Override http request option.
@@ -155,7 +102,7 @@ var NotificationsApiAxiosParamCreator = function (configuration) {
155
102
  sendNotification: function (sendNotificationRequestDto, authorization, options) {
156
103
  if (options === void 0) { options = {}; }
157
104
  return __awaiter(_this, void 0, void 0, function () {
158
- var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, authorizationValue, headersFromBaseOptions;
105
+ var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, headersFromBaseOptions;
159
106
  return __generator(this, function (_a) {
160
107
  switch (_a.label) {
161
108
  case 0:
@@ -172,16 +119,13 @@ var NotificationsApiAxiosParamCreator = function (configuration) {
172
119
  localVarQueryParameter = {};
173
120
  // authentication bearer required
174
121
  // http bearer authentication required
175
- return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)
176
- // Only Authorization falls back to the configured token; an empty value is never sent.
177
- ];
122
+ return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)];
178
123
  case 1:
179
124
  // authentication bearer required
180
125
  // http bearer authentication required
181
126
  _a.sent();
182
- authorizationValue = 'Authorization'.toLowerCase() === 'authorization' ? (authorization || baseAccessToken) : authorization;
183
- if (authorizationValue) {
184
- localVarHeaderParameter['Authorization'] = String(authorizationValue);
127
+ if (authorization !== undefined && authorization !== null || baseAccessToken !== undefined && baseAccessToken !== null) {
128
+ localVarHeaderParameter['Authorization'] = String(authorization ? authorization : baseAccessToken);
185
129
  }
186
130
  localVarHeaderParameter['Content-Type'] = 'application/json';
187
131
  (0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
@@ -207,29 +151,7 @@ var NotificationsApiFp = function (configuration) {
207
151
  var localVarAxiosParamCreator = (0, exports.NotificationsApiAxiosParamCreator)(configuration);
208
152
  return {
209
153
  /**
210
- * Sends an email with a caller-supplied HTML and/or text body, delivered as given. Attachments can reference documents already in S3 or be sent inline as base64. **Required Permissions** none
211
- * @summary Send an email without a template
212
- * @param {SendEmailRequestDto} sendEmailRequestDto
213
- * @param {string} [authorization] Bearer Token
214
- * @param {*} [options] Override http request option.
215
- * @throws {RequiredError}
216
- */
217
- sendEmail: function (sendEmailRequestDto, authorization, options) {
218
- return __awaiter(this, void 0, void 0, function () {
219
- var localVarAxiosArgs;
220
- return __generator(this, function (_a) {
221
- switch (_a.label) {
222
- case 0: return [4 /*yield*/, localVarAxiosParamCreator.sendEmail(sendEmailRequestDto, authorization, options)];
223
- case 1:
224
- localVarAxiosArgs = _a.sent();
225
- return [2 /*return*/, (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)];
226
- }
227
- });
228
- });
229
- },
230
- /**
231
- * Sends an email using the notification template identified by `templateSlug`. Provide `entityType` and `entityCode` to track replies in an email thread. **Required Permissions** none
232
- * @summary Send a notification
154
+ * undefined **Required Permissions** none
233
155
  * @param {SendNotificationRequestDto} sendNotificationRequestDto
234
156
  * @param {string} [authorization] Bearer Token
235
157
  * @param {*} [options] Override http request option.
@@ -259,19 +181,7 @@ var NotificationsApiFactory = function (configuration, basePath, axios) {
259
181
  var localVarFp = (0, exports.NotificationsApiFp)(configuration);
260
182
  return {
261
183
  /**
262
- * Sends an email with a caller-supplied HTML and/or text body, delivered as given. Attachments can reference documents already in S3 or be sent inline as base64. **Required Permissions** none
263
- * @summary Send an email without a template
264
- * @param {SendEmailRequestDto} sendEmailRequestDto
265
- * @param {string} [authorization] Bearer Token
266
- * @param {*} [options] Override http request option.
267
- * @throws {RequiredError}
268
- */
269
- sendEmail: function (sendEmailRequestDto, authorization, options) {
270
- return localVarFp.sendEmail(sendEmailRequestDto, authorization, options).then(function (request) { return request(axios, basePath); });
271
- },
272
- /**
273
- * Sends an email using the notification template identified by `templateSlug`. Provide `entityType` and `entityCode` to track replies in an email thread. **Required Permissions** none
274
- * @summary Send a notification
184
+ * undefined **Required Permissions** none
275
185
  * @param {SendNotificationRequestDto} sendNotificationRequestDto
276
186
  * @param {string} [authorization] Bearer Token
277
187
  * @param {*} [options] Override http request option.
@@ -295,20 +205,7 @@ var NotificationsApi = /** @class */ (function (_super) {
295
205
  return _super !== null && _super.apply(this, arguments) || this;
296
206
  }
297
207
  /**
298
- * Sends an email with a caller-supplied HTML and/or text body, delivered as given. Attachments can reference documents already in S3 or be sent inline as base64. **Required Permissions** none
299
- * @summary Send an email without a template
300
- * @param {NotificationsApiSendEmailRequest} requestParameters Request parameters.
301
- * @param {*} [options] Override http request option.
302
- * @throws {RequiredError}
303
- * @memberof NotificationsApi
304
- */
305
- NotificationsApi.prototype.sendEmail = function (requestParameters, options) {
306
- 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); });
308
- };
309
- /**
310
- * Sends an email using the notification template identified by `templateSlug`. Provide `entityType` and `entityCode` to track replies in an email thread. **Required Permissions** none
311
- * @summary Send a notification
208
+ * undefined **Required Permissions** none
312
209
  * @param {NotificationsApiSendNotificationRequest} requestParameters Request parameters.
313
210
  * @param {*} [options] Override http request option.
314
211
  * @throws {RequiredError}
package/dist/api.d.ts CHANGED
@@ -9,13 +9,10 @@
9
9
  * https://openapi-generator.tech
10
10
  * Do not edit the class manually.
11
11
  */
12
- export * from './api/email-mailboxes-api';
13
12
  export * from './api/email-messages-api';
14
- export * from './api/email-subscriptions-api';
15
13
  export * from './api/email-tracking-api';
16
14
  export * from './api/email-verifications-api';
17
15
  export * from './api/health-api';
18
16
  export * from './api/layouts-api';
19
- export * from './api/msgraph-webhooks-api';
20
17
  export * from './api/notification-templates-api';
21
18
  export * from './api/notifications-api';
package/dist/api.js CHANGED
@@ -27,13 +27,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
27
27
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
28
28
  };
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
- __exportStar(require("./api/email-mailboxes-api"), exports);
31
30
  __exportStar(require("./api/email-messages-api"), exports);
32
- __exportStar(require("./api/email-subscriptions-api"), exports);
33
31
  __exportStar(require("./api/email-tracking-api"), exports);
34
32
  __exportStar(require("./api/email-verifications-api"), exports);
35
33
  __exportStar(require("./api/health-api"), exports);
36
34
  __exportStar(require("./api/layouts-api"), exports);
37
- __exportStar(require("./api/msgraph-webhooks-api"), exports);
38
35
  __exportStar(require("./api/notification-templates-api"), exports);
39
36
  __exportStar(require("./api/notifications-api"), exports);
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>;
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
  };
@@ -123,12 +112,6 @@ function resetRetry() {
123
112
  exports.resetRetry = resetRetry;
124
113
  var NETWORK_ERROR_MESSAGE = "Network Error";
125
114
  var TOKEN_DATA = 'APP_TOKEN';
126
- // Sent only to authservice, to ask for a server session.
127
- var AUTH_MODE_HEADER = 'X-Emil-Auth-Mode';
128
- // Names the account on every call; one browser session can hold several.
129
- var ACCOUNT_HEADER = 'X-Emil-Account';
130
- var SESSION_MODES = ['both', 'session'];
131
- var RESEND_SAFE_METHODS = ['get', 'head', 'options'];
132
115
  /**
133
116
  *
134
117
  * @export
@@ -145,18 +128,10 @@ var BaseAPI = /** @class */ (function () {
145
128
  var accessToken = this.tokenData.accessToken;
146
129
  this.configuration = configuration;
147
130
  this.basePath = configuration.basePath || this.basePath;
148
- if (configuration.cookieAuth) {
149
- this.configuration.username = this.configuration.username || this.tokenData.username;
150
- }
151
- if (this.usesSession()) {
152
- this.useSessionAuth();
153
- }
154
- else {
155
- // Use config token if provided, otherwise use tokenData token
156
- var configToken = this.configuration.accessToken;
157
- var storedToken = accessToken ? "Bearer ".concat(accessToken) : '';
158
- this.configuration.accessToken = configToken || storedToken;
159
- }
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;
160
135
  }
161
136
  else {
162
137
  var _a = this.tokenData, accessToken = _a.accessToken, username = _a.username;
@@ -168,95 +143,6 @@ var BaseAPI = /** @class */ (function () {
168
143
  }
169
144
  this.attachInterceptor(axios);
170
145
  }
171
- // The app's own account wins over APP_TOKEN, which holds whichever tab wrote last.
172
- BaseAPI.prototype.sessionAccount = function () {
173
- return this.configuration.account || this.tokenData.sub;
174
- };
175
- // Apps may pass the address as the second argument only; authservice is on the same host.
176
- BaseAPI.prototype.authBasePath = function () {
177
- return this.configuration.basePath || this.basePath;
178
- };
179
- BaseAPI.prototype.usesSession = function () {
180
- return !!this.configuration.cookieAuth && SESSION_MODES.indexOf(this.tokenData.authMode) !== -1 && !!this.sessionAccount();
181
- };
182
- BaseAPI.prototype.useSessionAuth = function () {
183
- var _a;
184
- var _b = this.configuration.baseOptions || {}, headers = _b.headers, baseOptions = __rest(_b, ["headers"]);
185
- this.configuration.accessToken = '';
186
- this.configuration.baseOptions = __assign(__assign({}, baseOptions), { withCredentials: true, headers: __assign(__assign({}, headers), (_a = {}, _a[ACCOUNT_HEADER] = this.sessionAccount(), _a)) });
187
- };
188
- BaseAPI.prototype.useHeaderAuth = function (accessToken) {
189
- this.configuration.accessToken = accessToken ? "Bearer ".concat(accessToken) : '';
190
- this.tokenData.accessToken = accessToken;
191
- delete this.tokenData.authMode;
192
- delete this.tokenData.sub;
193
- if (this.configuration.cookieAuth) {
194
- var _a = this.configuration.baseOptions || {}, withCredentials = _a.withCredentials, headers = _a.headers, baseOptions = __rest(_a, ["withCredentials", "headers"]);
195
- var _b = headers || {}, _c = ACCOUNT_HEADER, account = _b[_c], otherHeaders = __rest(_b, [typeof _c === "symbol" ? _c : _c + ""]);
196
- this.configuration.baseOptions = __assign(__assign({}, baseOptions), { headers: otherHeaders });
197
- }
198
- };
199
- BaseAPI.prototype.applyTokenReply = function (_a) {
200
- var accessToken = _a.accessToken, authMode = _a.authMode, session = _a.session;
201
- if (this.configuration.cookieAuth && SESSION_MODES.indexOf(authMode) !== -1 && (session === null || session === void 0 ? void 0 : session.sub)) {
202
- this.tokenData.authMode = authMode;
203
- this.tokenData.sub = session.sub;
204
- if (this.configuration.account) {
205
- // A workspace switch moves the app to another account.
206
- this.configuration.account = session.sub;
207
- }
208
- // Both keeps the token for apps not moved yet; session mode keeps no token at all.
209
- if (authMode === 'both' && accessToken) {
210
- this.tokenData.accessToken = accessToken;
211
- }
212
- else {
213
- delete this.tokenData.accessToken;
214
- }
215
- this.useSessionAuth();
216
- }
217
- else {
218
- this.useHeaderAuth(accessToken);
219
- }
220
- };
221
- BaseAPI.prototype.sessionHeaders = function () {
222
- var _a, _b;
223
- if (!this.configuration.cookieAuth) {
224
- return {};
225
- }
226
- return __assign((_a = {}, _a[AUTH_MODE_HEADER] = 'session', _a), (this.usesSession() && (_b = {}, _b[ACCOUNT_HEADER] = this.sessionAccount(), _b)));
227
- };
228
- BaseAPI.prototype.withCurrentAuth = function (config) {
229
- delete config.headers['Authorization'];
230
- delete config.headers[ACCOUNT_HEADER];
231
- if (this.usesSession()) {
232
- config.headers[ACCOUNT_HEADER] = this.sessionAccount();
233
- config.withCredentials = true;
234
- }
235
- else if (this.configuration.accessToken) {
236
- config.headers['Authorization'] = this.configuration.accessToken;
237
- }
238
- return config;
239
- };
240
- // Both keeps the token, so a session call the browser could not complete can be sent again with it.
241
- BaseAPI.prototype.canRetryWithToken = function (config) {
242
- var _a;
243
- return !!config.withCredentials && !!((_a = config.headers) === null || _a === void 0 ? void 0 : _a[ACCOUNT_HEADER])
244
- && !!this.tokenData.accessToken && this.tokenData.authMode !== 'session';
245
- };
246
- // A network error can come after the server ran the call, so only a call that is safe to repeat is sent again.
247
- BaseAPI.prototype.canResend = function (config) {
248
- return RESEND_SAFE_METHODS.indexOf((config.method || 'get').toLowerCase()) !== -1
249
- || Object.keys(config.headers || {}).some(function (name) { return name.toLowerCase() === 'idempotency-key'; });
250
- };
251
- BaseAPI.prototype.switchToToken = function () {
252
- this.useHeaderAuth(this.tokenData.accessToken);
253
- this.storeTokenData(this.tokenData);
254
- };
255
- BaseAPI.prototype.retryWithToken = function (axios, config) {
256
- this.switchToToken();
257
- config.withCredentials = false;
258
- return axios(this.withCurrentAuth(config));
259
- };
260
146
  BaseAPI.prototype.selectEnvironment = function (env) {
261
147
  this.selectBasePath(env);
262
148
  };
@@ -272,15 +158,14 @@ var BaseAPI = /** @class */ (function () {
272
158
  };
273
159
  BaseAPI.prototype.authorize = function (username, password, targetWorkspace) {
274
160
  return __awaiter(this, void 0, void 0, function () {
275
- var options, response;
276
- var _a;
161
+ var options, response, _a, accessToken, permissions;
277
162
  return __generator(this, function (_b) {
278
163
  switch (_b.label) {
279
164
  case 0:
280
165
  options = {
281
166
  method: 'POST',
282
- url: "".concat(this.authBasePath(), "/authservice/v1/login"),
283
- 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' },
284
169
  data: {
285
170
  username: username,
286
171
  password: password,
@@ -290,10 +175,12 @@ var BaseAPI = /** @class */ (function () {
290
175
  return [4 /*yield*/, axios_1.default.request(options)];
291
176
  case 1:
292
177
  response = _b.sent();
178
+ _a = response.data, accessToken = _a.accessToken, permissions = _a.permissions;
293
179
  this.configuration.username = username;
180
+ this.configuration.accessToken = "Bearer ".concat(accessToken);
294
181
  this.tokenData.username = username;
295
- this.tokenData.permissions = response.data.permissions;
296
- this.applyTokenReply(response.data);
182
+ this.tokenData.accessToken = accessToken;
183
+ this.tokenData.permissions = permissions;
297
184
  if (!targetWorkspace) return [3 /*break*/, 3];
298
185
  return [4 /*yield*/, this.switchWorkspace(targetWorkspace)];
299
186
  case 2:
@@ -312,14 +199,17 @@ var BaseAPI = /** @class */ (function () {
312
199
  };
313
200
  BaseAPI.prototype.switchWorkspace = function (targetWorkspace) {
314
201
  return __awaiter(this, void 0, void 0, function () {
315
- var options, response;
316
- return __generator(this, function (_a) {
317
- switch (_a.label) {
202
+ var options, response, _a, accessToken, permissions;
203
+ return __generator(this, function (_b) {
204
+ switch (_b.label) {
318
205
  case 0:
319
206
  options = {
320
207
  method: 'POST',
321
- url: "".concat(this.authBasePath(), "/authservice/v1/workspaces/switch"),
322
- 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
+ },
323
213
  data: {
324
214
  username: this.configuration.username,
325
215
  targetWorkspace: targetWorkspace,
@@ -328,9 +218,11 @@ var BaseAPI = /** @class */ (function () {
328
218
  };
329
219
  return [4 /*yield*/, axios_1.default.request(options)];
330
220
  case 1:
331
- response = _a.sent();
332
- this.tokenData.permissions = response.data.permissions;
333
- 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;
334
226
  this.storeTokenData(__assign({}, this.tokenData));
335
227
  return [2 /*return*/];
336
228
  }
@@ -357,8 +249,10 @@ var BaseAPI = /** @class */ (function () {
357
249
  });
358
250
  options = {
359
251
  method: 'POST',
360
- url: "".concat(this.authBasePath(), "/authservice/v1/refresh-token"),
361
- 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
+ },
362
256
  data: { username: username },
363
257
  withCredentials: true,
364
258
  };
@@ -391,75 +285,62 @@ var BaseAPI = /** @class */ (function () {
391
285
  axios.interceptors.response.use(function (res) {
392
286
  return res;
393
287
  }, function (err) { return __awaiter(_this, void 0, void 0, function () {
394
- var originalConfig, reply, _error_1, reply, _error_2;
395
- var _this = this;
396
- return __generator(this, function (_a) {
397
- 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) {
398
291
  case 0:
399
292
  originalConfig = err.config;
400
293
  if (!(err.response && !(err.response instanceof XMLHttpRequest))) return [3 /*break*/, 5];
401
294
  if (!((err.response.status === 401 || err.response.status === 403)
402
295
  && !originalConfig._retry)) return [3 /*break*/, 4];
403
296
  originalConfig._retry = true;
404
- _a.label = 1;
297
+ _c.label = 1;
405
298
  case 1:
406
- _a.trys.push([1, 3, , 4]);
299
+ _c.trys.push([1, 3, , 4]);
407
300
  return [4 /*yield*/, this.refreshTokenInternal()];
408
301
  case 2:
409
- reply = _a.sent();
410
- this.tokenData.permissions = reply.permissions;
411
- this.applyTokenReply(reply);
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;
412
309
  this.storeTokenData(this.tokenData);
413
- if (!this.usesSession()) {
414
- return [2 /*return*/, axios(this.withCurrentAuth(originalConfig))];
415
- }
416
- // Both mode: if the browser does not send the session cookie (another site), use the token.
417
- return [2 /*return*/, axios(this.withCurrentAuth(originalConfig)).catch(function (retryError) {
418
- var _a;
419
- if (((_a = retryError === null || retryError === void 0 ? void 0 : retryError.response) === null || _a === void 0 ? void 0 : _a.status) !== 401 || !_this.tokenData.accessToken) {
420
- return Promise.reject(retryError);
421
- }
422
- return _this.retryWithToken(axios, originalConfig);
423
- })];
310
+ return [2 /*return*/, axios(originalConfig)];
424
311
  case 3:
425
- _error_1 = _a.sent();
312
+ _error_1 = _c.sent();
426
313
  if (_error_1.response && _error_1.response.data) {
427
314
  return [2 /*return*/, Promise.reject(_error_1.response.data)];
428
315
  }
429
316
  return [2 /*return*/, Promise.reject(_error_1)];
430
- case 4: return [3 /*break*/, 10];
317
+ case 4: return [3 /*break*/, 9];
431
318
  case 5:
432
- if (!(err.message === NETWORK_ERROR_MESSAGE && this.canRetryWithToken(originalConfig))) return [3 /*break*/, 6];
433
- // Both mode: the browser blocked the session call or hid its reply; later calls use the token.
434
- if (!this.canResend(originalConfig)) {
435
- this.switchToToken();
436
- return [2 /*return*/, Promise.reject(err)];
437
- }
438
- return [2 /*return*/, this.retryWithToken(axios, originalConfig)];
439
- case 6:
440
319
  if (!(err.message === NETWORK_ERROR_MESSAGE
441
- && (originalConfig.headers.hasOwnProperty('Authorization')
442
- || (this.configuration.cookieAuth && originalConfig.withCredentials && this.canResend(originalConfig)))
443
- && _retry_count < 4)) return [3 /*break*/, 10];
320
+ && originalConfig.headers.hasOwnProperty('Authorization')
321
+ && _retry_count < 4)) return [3 /*break*/, 9];
444
322
  _retry_count++;
445
- _a.label = 7;
446
- case 7:
447
- _a.trys.push([7, 9, , 10]);
323
+ _c.label = 6;
324
+ case 6:
325
+ _c.trys.push([6, 8, , 9]);
448
326
  return [4 /*yield*/, this.refreshTokenInternal()];
449
- case 8:
450
- reply = _a.sent();
451
- 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;
452
331
  _retry = true;
453
- this.applyTokenReply(reply);
332
+ originalConfig.headers['Authorization'] = accessToken;
333
+ this.configuration.accessToken = accessToken;
334
+ this.tokenData.accessToken = tokenString;
454
335
  this.storeTokenData(this.tokenData);
455
- return [2 /*return*/, axios.request(__assign({}, this.withCurrentAuth(originalConfig)))];
456
- case 9:
457
- _error_2 = _a.sent();
336
+ return [2 /*return*/, axios.request(__assign({}, originalConfig))];
337
+ case 8:
338
+ _error_2 = _c.sent();
458
339
  if (_error_2.response && _error_2.response.data) {
459
340
  return [2 /*return*/, Promise.reject(_error_2.response.data)];
460
341
  }
461
342
  return [2 /*return*/, Promise.reject(_error_2)];
462
- case 10: return [2 /*return*/, Promise.reject(err)];
343
+ case 9: return [2 /*return*/, Promise.reject(err)];
463
344
  }
464
345
  });
465
346
  }); });
@@ -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.