@wireapp/api-client 27.0.8 → 27.0.10

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 (62) hide show
  1. package/lib/APIClient.d.ts +0 -1
  2. package/lib/APIClient.d.ts.map +1 -1
  3. package/lib/APIClient.js +24 -22
  4. package/lib/account/AccountAPI.js +16 -15
  5. package/lib/asset/AssetAPI.d.ts +0 -1
  6. package/lib/asset/AssetAPI.d.ts.map +1 -1
  7. package/lib/asset/AssetAPI.js +6 -5
  8. package/lib/auth/AccessTokenStore.d.ts +0 -1
  9. package/lib/auth/AccessTokenStore.d.ts.map +1 -1
  10. package/lib/auth/AccessTokenStore.js +8 -1
  11. package/lib/auth/AuthAPI.js +22 -27
  12. package/lib/auth/Cookie.js +2 -2
  13. package/lib/auth/CookieStore.d.ts +0 -1
  14. package/lib/auth/CookieStore.d.ts.map +1 -1
  15. package/lib/auth/CookieStore.js +3 -2
  16. package/lib/auth/parseAccessToken.js +3 -3
  17. package/lib/broadcast/BroadcastAPI.js +5 -4
  18. package/lib/client/ClientAPI.d.ts +1 -1
  19. package/lib/client/ClientAPI.js +11 -10
  20. package/lib/connection/ConnectionAPI.js +4 -3
  21. package/lib/conversation/ConversationAPI/ConversationAPI.js +34 -33
  22. package/lib/conversation/FederatedBackendsError.js +6 -5
  23. package/lib/demo/initClient.js +1 -2
  24. package/lib/generic/GenericAPI.js +1 -0
  25. package/lib/giphy/GiphyAPI.js +8 -7
  26. package/lib/http/BackendError.js +3 -0
  27. package/lib/http/HttpClient.d.ts +0 -1
  28. package/lib/http/HttpClient.d.ts.map +1 -1
  29. package/lib/http/HttpClient.js +49 -24
  30. package/lib/http/NetworkError.js +1 -0
  31. package/lib/notification/NotificationAPI/NotificationAPI.js +11 -11
  32. package/lib/notification/NotificationAPI/NotificationsAPI.mocks.d.ts +1 -1
  33. package/lib/oauth/OAuthAPI.js +8 -7
  34. package/lib/obfuscation/ObfuscationUtil.js +4 -1
  35. package/lib/self/SelfAPI.js +12 -11
  36. package/lib/serviceProvider/ServiceProviderAPI.js +8 -7
  37. package/lib/services/ServicesAPI.js +13 -11
  38. package/lib/shims/browser/cookie.d.ts.map +1 -1
  39. package/lib/shims/browser/websocket.d.ts +1 -1
  40. package/lib/shims/node/buffer.d.ts +0 -1
  41. package/lib/shims/node/buffer.d.ts.map +1 -1
  42. package/lib/shims/node/cookie.d.ts.map +1 -1
  43. package/lib/shims/node/cookie.js +1 -2
  44. package/lib/tcp/ReconnectingWebsocket.js +72 -64
  45. package/lib/tcp/WebSocketClient.d.ts +0 -1
  46. package/lib/tcp/WebSocketClient.d.ts.map +1 -1
  47. package/lib/tcp/WebSocketClient.js +68 -61
  48. package/lib/team/billing/BillingAPI.js +15 -14
  49. package/lib/team/conversation/TeamConversationAPI.js +6 -5
  50. package/lib/team/feature/FeatureAPI.js +20 -19
  51. package/lib/team/identityprovider/IdentityProviderAPI.js +6 -5
  52. package/lib/team/invitation/TeamInvitationAPI.js +9 -9
  53. package/lib/team/legalhold/LegalHoldAPI.js +6 -5
  54. package/lib/team/member/MemberAPI.js +8 -7
  55. package/lib/team/payment/PaymentAPI.js +12 -11
  56. package/lib/team/scim/ScimAPI.js +6 -5
  57. package/lib/team/search/TeamSearchAPI.js +9 -5
  58. package/lib/team/service/ServiceAPI.js +8 -7
  59. package/lib/team/team/TeamAPI.js +12 -8
  60. package/lib/user/UserAPI.js +40 -30
  61. package/lib/validation/ValidationError.js +1 -0
  62. package/package.json +3 -3
@@ -20,9 +20,17 @@
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.GiphyAPI = void 0;
22
22
  class GiphyAPI {
23
+ client;
23
24
  constructor(client) {
24
25
  this.client = client;
25
26
  }
27
+ static URL = {
28
+ GIPHY: 'giphy/v1/gifs',
29
+ PROXY: '/proxy',
30
+ RANDOM: 'random',
31
+ SEARCH: 'search',
32
+ TRENDING: 'trending',
33
+ };
26
34
  /**
27
35
  * Get multiple Giphy images by IDs.
28
36
  * @see https://developers.giphy.com/docs/api/endpoint#get-gifs-by-id
@@ -91,10 +99,3 @@ class GiphyAPI {
91
99
  }
92
100
  }
93
101
  exports.GiphyAPI = GiphyAPI;
94
- GiphyAPI.URL = {
95
- GIPHY: 'giphy/v1/gifs',
96
- PROXY: '/proxy',
97
- RANDOM: 'random',
98
- SEARCH: 'search',
99
- TRENDING: 'trending',
100
- };
@@ -21,6 +21,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.BackendError = void 0;
22
22
  const BackendErrorLabel_1 = require("./BackendErrorLabel");
23
23
  class BackendError extends Error {
24
+ code;
25
+ label;
26
+ message;
24
27
  constructor(message, label = BackendErrorLabel_1.SyntheticErrorLabel.UNKNOWN, code) {
25
28
  super(message);
26
29
  this.code = code;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios';
3
2
  import { EventEmitter } from 'events';
4
3
  import { AccessTokenData, AccessTokenStore, InvalidTokenError, MissingCookieError } from '../auth/';
@@ -1 +1 @@
1
- {"version":3,"file":"HttpClient.d.ts","sourceRoot":"","sources":["../../src/http/HttpClient.ts"],"names":[],"mappings":";AAmBA,OAAc,EAAC,UAAU,EAA+B,kBAAkB,EAAE,aAAa,EAAC,MAAM,OAAO,CAAC;AAKxG,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAC;AAKpC,OAAO,EACL,eAAe,EACf,gBAAgB,EAEhB,iBAAiB,EACjB,kBAAkB,EAEnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AACjC,OAAO,EAAC,YAAY,EAAsB,eAAe,EAA0B,MAAM,UAAU,CAAC;AAIpG,aAAK,KAAK;IACR,0BAA0B,gDAAgD;IAC1E,gBAAgB,sCAAsC;CACvD;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,0BAA0B,EAAE,Q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AC,WAAW,GAAE,MAAc,GAAG,OAAO;IASnD,kBAAkB,IAAI,OAAO,CAAC,eAAe,CAAC;IAc9C,UAAU,CAAC,kBAAkB,CAAC,EAAE,eAAe,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAoB1G;;;;OAIG;IACU,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAOtE,WAAW,CAAC,CAAC,EACxB,MAAM,EAAE,kBAAkB,EAC1B,YAAY,GAAE,OAAe,EAC7B,oBAAoB,GAAE,OAAe,GACpC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAoBrB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,kBAAkB,EAAE,oBAAoB,GAAE,OAAe,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAmBzG,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAQjE,kBAAkB,CAAC,CAAC,EACzB,MAAM,EAAE,kBAAkB,EAC1B,oBAAoB,GAAE,OAAe,GACpC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAQrB,eAAe,CAAC,CAAC,EACtB,MAAM,EAAE,kBAAkB,EAC1B,oBAAoB,GAAE,OAAe,GACpC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;CAO7B"}
@@ -63,11 +63,19 @@ var TOPIC;
63
63
  })(TOPIC || (TOPIC = {}));
64
64
  const FILE_SIZE_100_MB = 104857600;
65
65
  class HttpClient extends events_1.EventEmitter {
66
+ config;
67
+ accessTokenStore;
68
+ client;
69
+ logger;
70
+ connectionState;
71
+ requestQueue;
72
+ backOffQueue;
73
+ static TOPIC = TOPIC;
74
+ versionPrefix = '';
66
75
  constructor(config, accessTokenStore) {
67
76
  super();
68
77
  this.config = config;
69
78
  this.accessTokenStore = accessTokenStore;
70
- this.versionPrefix = '';
71
79
  this.client = axios_1.default.create({
72
80
  baseURL: this.config.urls.rest,
73
81
  });
@@ -82,7 +90,7 @@ class HttpClient extends events_1.EventEmitter {
82
90
  this.updateConnectionState(http_1.ConnectionState.DISCONNECTED);
83
91
  return true;
84
92
  }
85
- if ((response === null || response === void 0 ? void 0 : response.status) !== 401 && (response === null || response === void 0 ? void 0 : response.status) !== 403) {
93
+ if (response?.status !== 401 && response?.status !== 403) {
86
94
  // we only want to retry auth failures (access token will automatically be regenerated)
87
95
  return false;
88
96
  }
@@ -104,8 +112,7 @@ class HttpClient extends events_1.EventEmitter {
104
112
  retryDelay: 200,
105
113
  maxRetryDelay: 2000,
106
114
  shouldRetry: error => {
107
- var _a;
108
- const isTooManyRequestsError = axios_1.default.isAxiosError(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 420;
115
+ const isTooManyRequestsError = axios_1.default.isAxiosError(error) && error.response?.status === 420;
109
116
  return isTooManyRequestsError;
110
117
  },
111
118
  });
@@ -123,20 +130,29 @@ class HttpClient extends events_1.EventEmitter {
123
130
  }
124
131
  }
125
132
  async _sendRequest(config, tokenAsParam = false, isFirstTry = true) {
126
- var _a, _b;
127
133
  if (this.accessTokenStore.accessToken) {
128
134
  const { token_type, access_token } = this.accessTokenStore.accessToken;
129
135
  if (tokenAsParam) {
130
- config.params = Object.assign(Object.assign({}, config.params), { access_token });
136
+ config.params = {
137
+ ...config.params,
138
+ access_token,
139
+ };
131
140
  }
132
141
  else {
133
- config.headers = Object.assign(Object.assign({}, config.headers), { Authorization: `${token_type} ${access_token}` });
142
+ config.headers = {
143
+ ...config.headers,
144
+ Authorization: `${token_type} ${access_token}`,
145
+ };
134
146
  }
135
147
  }
136
148
  try {
137
- const response = await this.client.request(Object.assign(Object.assign({}, config), {
149
+ const response = await this.client.request({
150
+ ...config,
138
151
  // We want to prefix all urls, except the ones with cookies which are attached to unprefixed urls
139
- url: config.withCredentials ? config.url : `${this.versionPrefix}${config.url}`, maxBodyLength: FILE_SIZE_100_MB, maxContentLength: FILE_SIZE_100_MB }));
152
+ url: config.withCredentials ? config.url : `${this.versionPrefix}${config.url}`,
153
+ maxBodyLength: FILE_SIZE_100_MB,
154
+ maxContentLength: FILE_SIZE_100_MB,
155
+ });
140
156
  this.updateConnectionState(http_1.ConnectionState.CONNECTED);
141
157
  return response;
142
158
  }
@@ -149,8 +165,8 @@ class HttpClient extends events_1.EventEmitter {
149
165
  };
150
166
  return this._sendRequest(config, tokenAsParam, false);
151
167
  };
152
- const hasAccessToken = !!((_a = this.accessTokenStore) === null || _a === void 0 ? void 0 : _a.accessToken);
153
- if (axios_1.default.isAxiosError(error) && ((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) === http_1.StatusCode.UNAUTHORIZED) {
168
+ const hasAccessToken = !!this.accessTokenStore?.accessToken;
169
+ if (axios_1.default.isAxiosError(error) && error.response?.status === http_1.StatusCode.UNAUTHORIZED) {
154
170
  return retryWithTokenRefresh();
155
171
  }
156
172
  if (HttpClient.isBackendError(error)) {
@@ -176,7 +192,7 @@ class HttpClient extends events_1.EventEmitter {
176
192
  static isBackendError(errorCandidate) {
177
193
  if (errorCandidate.response) {
178
194
  const { data } = errorCandidate.response;
179
- return !!(data === null || data === void 0 ? void 0 : data.code) && !!(data === null || data === void 0 ? void 0 : data.label) && !!(data === null || data === void 0 ? void 0 : data.message);
195
+ return !!data?.code && !!data?.label && !!data?.message;
180
196
  }
181
197
  return false;
182
198
  }
@@ -194,9 +210,8 @@ class HttpClient extends events_1.EventEmitter {
194
210
  return false;
195
211
  }
196
212
  async refreshAccessToken() {
197
- var _a;
198
213
  let expiredAccessToken;
199
- if ((_a = this.accessTokenStore.accessToken) === null || _a === void 0 ? void 0 : _a.access_token) {
214
+ if (this.accessTokenStore.accessToken?.access_token) {
200
215
  expiredAccessToken = this.accessTokenStore.accessToken;
201
216
  }
202
217
  const accessToken = await this.postAccess(expiredAccessToken);
@@ -211,7 +226,7 @@ class HttpClient extends events_1.EventEmitter {
211
226
  withCredentials: true,
212
227
  params: clientId && { client_id: clientId },
213
228
  };
214
- if ((expiredAccessToken === null || expiredAccessToken === void 0 ? void 0 : expiredAccessToken.access_token) && (config === null || config === void 0 ? void 0 : config.headers)) {
229
+ if (expiredAccessToken?.access_token && config?.headers) {
215
230
  config.headers = new axios_1.AxiosHeaders(config.headers);
216
231
  config.headers.set('Authorization', `${expiredAccessToken.token_type} ${decodeURIComponent(expiredAccessToken.access_token)}`);
217
232
  }
@@ -229,7 +244,6 @@ class HttpClient extends events_1.EventEmitter {
229
244
  return this.accessTokenStore.updateToken(newToken);
230
245
  }
231
246
  async sendRequest(config, tokenAsParam = false, isSynchronousRequest = false) {
232
- var _a;
233
247
  const promise = isSynchronousRequest
234
248
  ? this.requestQueue.add(() => this._sendRequest(config, tokenAsParam))
235
249
  : this._sendRequest(config, tokenAsParam);
@@ -239,7 +253,7 @@ class HttpClient extends events_1.EventEmitter {
239
253
  catch (error) {
240
254
  // If the request failed due to too many requests, we want put it into the backoff queue
241
255
  // It will be retried after a (growing) delay
242
- const isTooManyRequestsError = axios_1.default.isAxiosError(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 420;
256
+ const isTooManyRequestsError = axios_1.default.isAxiosError(error) && error.response?.status === 420;
243
257
  if (isTooManyRequestsError) {
244
258
  return this.backOffQueue.add(() => this._sendRequest(config, tokenAsParam));
245
259
  }
@@ -247,28 +261,39 @@ class HttpClient extends events_1.EventEmitter {
247
261
  }
248
262
  }
249
263
  sendJSON(config, isSynchronousRequest = false) {
250
- var _a, _b, _c;
251
264
  const shouldGzipData = process.env.NODE_ENV !== 'test' &&
252
265
  !!config.data &&
253
- ['post', 'put', 'patch'].includes((_b = (_a = config.method) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '');
266
+ ['post', 'put', 'patch'].includes(config.method?.toLowerCase() ?? '');
254
267
  if (shouldGzipData) {
255
268
  config.data = (0, pako_1.gzip)(JSON.stringify(config.data));
256
269
  }
257
- config.headers = Object.assign(Object.assign({}, config.headers), { 'Content-Type': http_1.ContentType.APPLICATION_JSON, 'Content-Encoding': shouldGzipData ? 'gzip' : (_c = config.headers) === null || _c === void 0 ? void 0 : _c['Content-Encoding'] });
270
+ config.headers = {
271
+ ...config.headers,
272
+ 'Content-Type': http_1.ContentType.APPLICATION_JSON,
273
+ 'Content-Encoding': shouldGzipData ? 'gzip' : config.headers?.['Content-Encoding'],
274
+ };
258
275
  return this.sendRequest(config, false, isSynchronousRequest);
259
276
  }
260
277
  sendXML(config) {
261
- config.headers = Object.assign(Object.assign({}, config.headers), { 'Content-Type': http_1.ContentType.APPLICATION_XML });
278
+ config.headers = {
279
+ ...config.headers,
280
+ 'Content-Type': http_1.ContentType.APPLICATION_XML,
281
+ };
262
282
  return this.sendRequest(config, false, false);
263
283
  }
264
284
  sendProtocolBuffer(config, isSynchronousRequest = false) {
265
- config.headers = Object.assign(Object.assign({}, config.headers), { 'Content-Type': http_1.ContentType.APPLICATION_PROTOBUF });
285
+ config.headers = {
286
+ ...config.headers,
287
+ 'Content-Type': http_1.ContentType.APPLICATION_PROTOBUF,
288
+ };
266
289
  return this.sendRequest(config, false, isSynchronousRequest);
267
290
  }
268
291
  sendProtocolMls(config, isSynchronousRequest = false) {
269
- config.headers = Object.assign(Object.assign({}, config.headers), { 'Content-Type': http_1.ContentType.MESSAGES_MLS });
292
+ config.headers = {
293
+ ...config.headers,
294
+ 'Content-Type': http_1.ContentType.MESSAGES_MLS,
295
+ };
270
296
  return this.sendRequest(config, false, isSynchronousRequest);
271
297
  }
272
298
  }
273
299
  exports.HttpClient = HttpClient;
274
- HttpClient.TOPIC = TOPIC;
@@ -20,6 +20,7 @@
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.NetworkError = void 0;
22
22
  class NetworkError extends Error {
23
+ message;
23
24
  constructor(message) {
24
25
  super(message);
25
26
  this.message = message;
@@ -26,9 +26,14 @@ const axios_1 = __importDefault(require("axios"));
26
26
  const http_1 = require("../../http");
27
27
  exports.NOTIFICATION_SIZE_MAXIMUM = 10000;
28
28
  class NotificationAPI {
29
+ client;
29
30
  constructor(client) {
30
31
  this.client = client;
31
32
  }
33
+ static URL = {
34
+ LAST: 'last',
35
+ NOTIFICATION: '/notifications',
36
+ };
32
37
  /**
33
38
  * Fetch the last notification.
34
39
  * @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/push/getLastNotification
@@ -72,13 +77,12 @@ class NotificationAPI {
72
77
  */
73
78
  async getAllNotifications(clientId, lastNotificationId) {
74
79
  const getNotificationChunks = async (notificationList, currentClientId, currentNotificationId) => {
75
- var _a, _b, _c, _d;
76
80
  const defaultPayload = {
77
81
  notifications: [],
78
82
  time: '0',
79
83
  has_more: false,
80
84
  };
81
- let payload = Object.assign({}, defaultPayload);
85
+ let payload = { ...defaultPayload };
82
86
  let hasMissedNotifications = false;
83
87
  try {
84
88
  payload = await this.getNotifications(currentClientId, exports.NOTIFICATION_SIZE_MAXIMUM, currentNotificationId);
@@ -86,20 +90,20 @@ class NotificationAPI {
86
90
  catch (error) {
87
91
  const isAxiosError = axios_1.default.isAxiosError(error);
88
92
  //error with response body (before v3 API)
89
- const isErrorWithNotifications = isAxiosError && ((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.notifications);
93
+ const isErrorWithNotifications = isAxiosError && error.response?.data?.notifications;
90
94
  //uuid parsing error
91
- const isBadRequestError = isAxiosError && ((_c = error.response) === null || _c === void 0 ? void 0 : _c.status) === http_1.StatusCode.BAD_REQUEST;
95
+ const isBadRequestError = isAxiosError && error.response?.status === http_1.StatusCode.BAD_REQUEST;
92
96
  //notification was not found in the database,
93
97
  const isNotFoundError = error instanceof http_1.BackendError && error.label === http_1.BackendErrorLabel.NOT_FOUND;
94
98
  if (isBadRequestError || isNotFoundError) {
95
99
  //we need to load all the notifications from the beginning (without 'since' param)
96
100
  const payload = await getNotificationChunks(notificationList, currentClientId);
97
101
  //we have to manually add missedNotification value since it won't be included when called without 'since' param
98
- return Object.assign(Object.assign({}, payload), { missedNotification: currentNotificationId });
102
+ return { ...payload, missedNotification: currentNotificationId };
99
103
  }
100
104
  if (isErrorWithNotifications) {
101
105
  hasMissedNotifications = true;
102
- payload = Object.assign(Object.assign({}, defaultPayload), (_d = error.response) === null || _d === void 0 ? void 0 : _d.data);
106
+ payload = { ...defaultPayload, ...error.response?.data };
103
107
  }
104
108
  //throw error for other BackendError type errors
105
109
  if (!isAxiosError) {
@@ -107,7 +111,7 @@ class NotificationAPI {
107
111
  }
108
112
  }
109
113
  const { notifications, has_more } = payload;
110
- if (notifications === null || notifications === void 0 ? void 0 : notifications.length) {
114
+ if (notifications?.length) {
111
115
  notificationList = notificationList.concat(notifications);
112
116
  }
113
117
  if (has_more) {
@@ -140,7 +144,3 @@ class NotificationAPI {
140
144
  }
141
145
  }
142
146
  exports.NotificationAPI = NotificationAPI;
143
- NotificationAPI.URL = {
144
- LAST: 'last',
145
- NOTIFICATION: '/notifications',
146
- };
@@ -33,7 +33,7 @@ declare const client: HttpClient;
33
33
  declare const notificationAPI: NotificationAPI;
34
34
  declare const getAllNotificationsResult: () => Promise<{
35
35
  notifications: import("..").Notification[];
36
- missedNotification?: string | undefined;
36
+ missedNotification?: string;
37
37
  }>;
38
38
  export { client, notificationAPI, getAllNotificationsResult, mockedResultData, mockedNotificationId };
39
39
  //# sourceMappingURL=NotificationsAPI.mocks.d.ts.map
@@ -20,9 +20,17 @@
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.OAuthAPI = void 0;
22
22
  class OAuthAPI {
23
+ client;
23
24
  constructor(client) {
24
25
  this.client = client;
25
26
  }
27
+ static URL = {
28
+ APPLICATIONS: 'applications',
29
+ AUTHORIZATION: 'authorization',
30
+ CODES: 'codes',
31
+ CLIENTS: 'clients',
32
+ OAUTH: '/oauth',
33
+ };
26
34
  /**
27
35
  * Get all OAuth applications.
28
36
  */
@@ -79,10 +87,3 @@ class OAuthAPI {
79
87
  }
80
88
  }
81
89
  exports.OAuthAPI = OAuthAPI;
82
- OAuthAPI.URL = {
83
- APPLICATIONS: 'applications',
84
- AUTHORIZATION: 'authorization',
85
- CODES: 'codes',
86
- CLIENTS: 'clients',
87
- OAUTH: '/oauth',
88
- };
@@ -22,7 +22,10 @@ exports.ObfuscationUtil = void 0;
22
22
  const obfuscationLengthLimit = 20;
23
23
  const obfuscateAccessToken = (accessToken, enabled = true) => {
24
24
  if (enabled) {
25
- return Object.assign(Object.assign({}, accessToken), { access_token: `${accessToken.access_token.substr(0, obfuscationLengthLimit)}...` });
25
+ return {
26
+ ...accessToken,
27
+ access_token: `${accessToken.access_token.substr(0, obfuscationLengthLimit)}...`,
28
+ };
26
29
  }
27
30
  return accessToken;
28
31
  };
@@ -20,9 +20,21 @@
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.SelfAPI = void 0;
22
22
  class SelfAPI {
23
+ client;
23
24
  constructor(client) {
24
25
  this.client = client;
25
26
  }
27
+ static URL = {
28
+ CONSENT: 'consent',
29
+ EMAIL: 'email',
30
+ HANDLE: 'handle',
31
+ LOCALE: 'locale',
32
+ NAME: 'name',
33
+ PASSWORD: 'password',
34
+ PHONE: 'phone',
35
+ SUPPORTED_PROTOCOLS: 'supported-protocols',
36
+ SELF: '/self',
37
+ };
26
38
  /**
27
39
  * Remove your email address.
28
40
  * @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/users/removeEmail
@@ -198,14 +210,3 @@ class SelfAPI {
198
210
  }
199
211
  }
200
212
  exports.SelfAPI = SelfAPI;
201
- SelfAPI.URL = {
202
- CONSENT: 'consent',
203
- EMAIL: 'email',
204
- HANDLE: 'handle',
205
- LOCALE: 'locale',
206
- NAME: 'name',
207
- PASSWORD: 'password',
208
- PHONE: 'phone',
209
- SUPPORTED_PROTOCOLS: 'supported-protocols',
210
- SELF: '/self',
211
- };
@@ -20,9 +20,17 @@
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.ServiceProviderAPI = void 0;
22
22
  class ServiceProviderAPI {
23
+ client;
23
24
  constructor(client) {
24
25
  this.client = client;
25
26
  }
27
+ static URL = {
28
+ COMPLETE: 'complete',
29
+ LOGIN: 'login',
30
+ PASSWORD_RESET: 'password-reset',
31
+ PROVIDER: '/provider',
32
+ REGISTER: 'register',
33
+ };
26
34
  async deleteServiceProvider(data) {
27
35
  const config = {
28
36
  data,
@@ -83,10 +91,3 @@ class ServiceProviderAPI {
83
91
  }
84
92
  }
85
93
  exports.ServiceProviderAPI = ServiceProviderAPI;
86
- ServiceProviderAPI.URL = {
87
- COMPLETE: 'complete',
88
- LOGIN: 'login',
89
- PASSWORD_RESET: 'password-reset',
90
- PROVIDER: '/provider',
91
- REGISTER: 'register',
92
- };
@@ -20,10 +20,23 @@
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.ServicesAPI = void 0;
22
22
  class ServicesAPI {
23
+ client;
24
+ assetAPI;
23
25
  constructor(client, assetAPI) {
24
26
  this.client = client;
25
27
  this.assetAPI = assetAPI;
26
28
  }
29
+ static URL = {
30
+ ASSETS: 'assets',
31
+ BOT: '/bot',
32
+ CLIENT: 'client',
33
+ CLIENTS: 'clients',
34
+ CONVERSATION: 'conversation',
35
+ MESSAGES: 'messages',
36
+ PREKEYS: 'prekeys',
37
+ SELF: 'self',
38
+ USERS: 'users',
39
+ };
27
40
  /**
28
41
  * Delete the service, thereby removing it from the conversation it is in.
29
42
  *
@@ -168,14 +181,3 @@ class ServicesAPI {
168
181
  }
169
182
  }
170
183
  exports.ServicesAPI = ServicesAPI;
171
- ServicesAPI.URL = {
172
- ASSETS: 'assets',
173
- BOT: '/bot',
174
- CLIENT: 'client',
175
- CLIENTS: 'clients',
176
- CONVERSATION: 'conversation',
177
- MESSAGES: 'messages',
178
- PREKEYS: 'prekeys',
179
- SELF: 'self',
180
- USERS: 'users',
181
- };
@@ -1 +1 @@
1
- {"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../../../src/shims/browser/cookie.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,kBAAkB,EAAE,aAAa,EAAC,MAAM,OAAO,CAAC;AAExD,OAAO,EAAC,eAAe,EAAC,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AAEvC,eAAO,MAAM,cAAc,aAAc,cAAc,eAAe,CAAC,KAAG,QAAQ,eAAe,CACjE,CAAC;AAEjC,eAAO,MAAM,qBAAqB,cAAe,UAAU,UAAU,kBAAkB,KAAG,QAAQ,cAAc,CAAC,CAAC,CAClF,CAAC"}
1
+ {"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../../../src/shims/browser/cookie.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,kBAAkB,EAAE,aAAa,EAAC,MAAM,OAAO,CAAC;AAExD,OAAO,EAAC,eAAe,EAAC,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AAEvC,eAAO,MAAM,cAAc,aAAc,aAAa,CAAC,eAAe,CAAC,KAAG,OAAO,CAAC,eAAe,CACjE,CAAC;AAEjC,eAAO,MAAM,qBAAqB,GAAI,CAAC,UAAU,UAAU,UAAU,kBAAkB,KAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAClF,CAAC"}
@@ -1,5 +1,5 @@
1
1
  declare const WebSocketBrowser: {
2
- new (url: string | URL, protocols?: string | string[] | undefined): WebSocket;
2
+ new (url: string | URL, protocols?: string | string[]): WebSocket;
3
3
  prototype: WebSocket;
4
4
  readonly CONNECTING: 0;
5
5
  readonly OPEN: 1;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  export declare const bufferToString: (buffer: ArrayBuffer) => string;
3
2
  export declare const base64MD5FromBuffer: (buffer: ArrayBuffer) => string;
4
3
  export declare const concatToBuffer: (...items: any[]) => Buffer;
@@ -1 +1 @@
1
- {"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../../src/shims/node/buffer.ts"],"names":[],"mappings":";AAqBA,eAAO,MAAM,cAAc,WAAY,WAAW,KAAG,MAA8C,CAAC;AAEpG,eAAO,MAAM,mBAAmB,WAAY,WAAW,KAAG,MAEzD,CAAC;AAEF,eAAO,MAAM,cAAc,aAAc,GAAG,EAAE,WAAwD,CAAC"}
1
+ {"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../../src/shims/node/buffer.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,cAAc,WAAY,WAAW,KAAG,MAA8C,CAAC;AAEpG,eAAO,MAAM,mBAAmB,WAAY,WAAW,KAAG,MAEzD,CAAC;AAEF,eAAO,MAAM,cAAc,aAAc,GAAG,EAAE,WAAwD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../../../src/shims/node/cookie.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAe,kBAAkB,EAAE,aAAa,EAAC,MAAM,OAAO,CAAC;AAMtE,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AAQvC,eAAO,MAAM,cAAc,gBAAuB,cAAc,CAAC,CAAC,KAAG,QAAQ,CAAC,CAiB7E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,cACxB,UAAU,UACV,kBAAkB,KACzB,QAAQ,cAAc,CAAC,CAAC,CAQ1B,CAAC"}
1
+ {"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../../../src/shims/node/cookie.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAe,kBAAkB,EAAE,aAAa,EAAC,MAAM,OAAO,CAAC;AAMtE,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AAQvC,eAAO,MAAM,cAAc,GAAU,CAAC,YAAY,aAAa,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,CAiB7E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAU,CAAC,UACnC,UAAU,UACV,kBAAkB,KACzB,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAQ1B,CAAC"}
@@ -33,8 +33,7 @@ const logger = (0, logdown_1.default)('@wireapp/api-client/shims/node/cookie', {
33
33
  markdown: false,
34
34
  });
35
35
  const retrieveCookie = async (response) => {
36
- var _a;
37
- if ((_a = response.headers) === null || _a === void 0 ? void 0 : _a['set-cookie']) {
36
+ if (response.headers?.['set-cookie']) {
38
37
  const cookies = response.headers['set-cookie'].flatMap(cookieString => {
39
38
  const cookie = tough_cookie_1.Cookie.parse(cookieString);
40
39
  return cookie ? [cookie] : [];