genesys-cloud-streaming-client 13.5.0-develop.6 → 14.0.1-develop.9

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 (53) hide show
  1. package/dist/cjs/client.d.ts +3 -0
  2. package/dist/cjs/client.js +56 -24
  3. package/dist/cjs/http-client.js +50 -8
  4. package/dist/cjs/reconnector.d.ts +1 -1
  5. package/dist/cjs/reconnector.js +19 -7
  6. package/dist/cjs/types/retry-utils.d.ts +54 -0
  7. package/dist/cjs/types/retry-utils.js +94 -0
  8. package/dist/cjs/utils.d.ts +1 -8
  9. package/dist/cjs/utils.js +14 -50
  10. package/dist/cjs/webrtc.d.ts +1 -0
  11. package/dist/cjs/webrtc.js +8 -1
  12. package/dist/deploy-info.json +6 -6
  13. package/dist/es/client.d.ts +3 -0
  14. package/dist/es/client.js +57 -23
  15. package/dist/es/http-client.js +50 -8
  16. package/dist/es/index.bundle.js +2323 -4641
  17. package/dist/es/reconnector.d.ts +1 -1
  18. package/dist/es/reconnector.js +23 -13
  19. package/dist/es/types/retry-utils.d.ts +54 -0
  20. package/dist/es/types/retry-utils.js +91 -0
  21. package/dist/es/utils.d.ts +1 -8
  22. package/dist/es/utils.js +1 -44
  23. package/dist/es/webrtc.d.ts +1 -0
  24. package/dist/es/webrtc.js +8 -1
  25. package/dist/npm/CHANGELOG.md +25 -1
  26. package/dist/npm/client.d.ts +3 -0
  27. package/dist/npm/client.js +56 -24
  28. package/dist/npm/http-client.js +50 -8
  29. package/dist/npm/reconnector.d.ts +1 -1
  30. package/dist/npm/reconnector.js +19 -7
  31. package/dist/npm/types/retry-utils.d.ts +54 -0
  32. package/dist/npm/types/retry-utils.js +94 -0
  33. package/dist/npm/utils.d.ts +1 -8
  34. package/dist/npm/utils.js +14 -50
  35. package/dist/npm/webrtc.d.ts +1 -0
  36. package/dist/npm/webrtc.js +8 -1
  37. package/dist/streaming-client.browser.ie.js +4 -4
  38. package/dist/streaming-client.browser.js +5 -5
  39. package/dist/v14/streaming-client.browser.ie.js +11 -0
  40. package/dist/v14/streaming-client.browser.js +40 -0
  41. package/dist/v14.0.1/streaming-client.browser.ie.js +11 -0
  42. package/dist/v14.0.1/streaming-client.browser.js +40 -0
  43. package/package.json +5 -4
  44. package/dist/cjs/request-logger.d.ts +0 -1
  45. package/dist/cjs/request-logger.js +0 -24
  46. package/dist/es/request-logger.d.ts +0 -1
  47. package/dist/es/request-logger.js +0 -21
  48. package/dist/npm/request-logger.d.ts +0 -1
  49. package/dist/npm/request-logger.js +0 -24
  50. package/dist/v13/streaming-client.browser.ie.js +0 -11
  51. package/dist/v13/streaming-client.browser.js +0 -40
  52. package/dist/v13.5.0/streaming-client.browser.ie.js +0 -11
  53. package/dist/v13.5.0/streaming-client.browser.js +0 -40
@@ -37,6 +37,9 @@ export declare class Client {
37
37
  disconnect(): Promise<void>;
38
38
  reconnect(): Promise<void>;
39
39
  connect(): Promise<void>;
40
+ _connectStanza(): Promise<void>;
41
+ stopServerLogging(): void;
42
+ startServerLogging(): void;
40
43
  setAccessToken(token: string): void;
41
44
  static extend(namespace: any, extension: StreamingClientExtension | ((client: Client) => void)): void;
42
45
  static get version(): string;
@@ -60,7 +60,7 @@ class Client {
60
60
  constructor(options) {
61
61
  this.connected = false;
62
62
  this.connecting = false;
63
- this.autoReconnect = true;
63
+ this.autoReconnect = false;
64
64
  this.hardReconnectCount = 0;
65
65
  this.reconnectLeakTime = 1000 * 60 * 10; // 10 minutes
66
66
  this.deadChannels = [];
@@ -117,8 +117,9 @@ class Client {
117
117
  this.on('connected', async (event) => {
118
118
  this.streamId = event.resource;
119
119
  this._ping.start();
120
- this.connected = true;
121
120
  this._reconnector.stop();
121
+ this.autoReconnect = true;
122
+ this.connected = true;
122
123
  this.connecting = false;
123
124
  });
124
125
  // remapped session:end
@@ -236,6 +237,7 @@ class Client {
236
237
  }
237
238
  disconnect() {
238
239
  this.logger.info('streamingClient.disconnect was called');
240
+ this.stopServerLogging();
239
241
  return utils_1.timeoutPromise(resolve => {
240
242
  this._stanzaio.once('disconnected', resolve);
241
243
  this.autoReconnect = false;
@@ -254,19 +256,11 @@ class Client {
254
256
  }, 10 * 1000, 'reconnecting streaming service');
255
257
  }
256
258
  connect() {
259
+ this.startServerLogging();
257
260
  this.logger.info('streamingClient.connect was called');
258
261
  this.connecting = true;
259
262
  if (this.config.jwt) {
260
- return utils_1.timeoutPromise(resolve => {
261
- this.once('connected', resolve);
262
- const options = stanzaOptionsJwt(this.config);
263
- this._stanzaio.updateConfig(options);
264
- this._stanzaio.connect();
265
- }, 10 * 1000, 'connecting to streaming service with jwt')
266
- .catch((err) => {
267
- this.connecting = false;
268
- return Promise.reject(err);
269
- });
263
+ return this._connectStanza();
270
264
  }
271
265
  let jidPromise;
272
266
  if (this.config.jid) {
@@ -280,7 +274,7 @@ class Client {
280
274
  logger: this.logger
281
275
  };
282
276
  jidPromise = this.http.requestApiWithRetry('users/me', opts).promise
283
- .then(res => res.body.chat.jabberId);
277
+ .then(res => res.data.chat.jabberId);
284
278
  }
285
279
  const opts = {
286
280
  method: 'post',
@@ -289,24 +283,62 @@ class Client {
289
283
  logger: this.logger
290
284
  };
291
285
  const channelPromise = this.http.requestApiWithRetry('notifications/channels?connectionType=streaming', opts).promise
292
- .then(res => res.body.id);
286
+ .then(res => res.data.id);
293
287
  return Promise.all([jidPromise, channelPromise])
294
288
  .then(([jid, channelId]) => {
295
289
  this.config.jid = jid;
296
290
  this.config.channelId = channelId;
297
- this.autoReconnect = true;
298
- return utils_1.timeoutPromise(resolve => {
299
- this.once('connected', resolve);
300
- const options = stanzaioOptions(this.config);
301
- this._stanzaio.updateConfig(options);
302
- this._stanzaio.connect();
303
- }, 10 * 1000, 'connecting to streaming service', { jid, channelId });
304
- })
291
+ return this._connectStanza();
292
+ });
293
+ }
294
+ async _connectStanza() {
295
+ const guestConnection = !!this.config.jwt;
296
+ const timeoutMsg = 'connecting to streaming service';
297
+ const options = guestConnection ? stanzaOptionsJwt(this.config) : stanzaioOptions(this.config);
298
+ const timeoutDetails = guestConnection
299
+ ? { usingJwt: true }
300
+ : { channelId: this.config.channelId, jidResource: this.config.jidResource };
301
+ /* if we already have a WS, we need to wait for the 2nd disconnect */
302
+ let skipDisconnectEvent = !!this._stanzaio.transport;
303
+ let rejectCallback;
304
+ return utils_1.timeoutPromise((resolve, reject) => {
305
+ rejectCallback = () => {
306
+ if (skipDisconnectEvent) {
307
+ this.logger.debug('received a --transport-disconnected event from existing WS. Not rejecting new attempt to connect WS.');
308
+ skipDisconnectEvent = false;
309
+ }
310
+ else {
311
+ this.logger.debug('received a --transport-disconnected event while attempting to connect new WS. rejecting new attempt to connect WS.');
312
+ reject(new Error('unexpected disconnect from the WebSocket connecting streaming service'));
313
+ }
314
+ };
315
+ /* if stanza runs into an error, we want to reject right away. There is no reason to wait for our timeout */
316
+ this._stanzaio.on('--transport-disconnected', rejectCallback);
317
+ this.once('connected', resolve);
318
+ this._stanzaio.updateConfig(options);
319
+ this._stanzaio.connect();
320
+ }, 10 * 1000, timeoutMsg, timeoutDetails)
305
321
  .catch((err) => {
306
322
  this.connecting = false;
307
- return Promise.reject(err);
323
+ /* if _we_ timed out but stanza is still trying to connect, we need to stop stanza's WS */
324
+ if (err.message === `Timeout: ${timeoutMsg}` && this._stanzaio.transport) {
325
+ this._stanzaio.disconnect();
326
+ this.logger.debug('timing out WS connect(), calling through to stanza to disconnect');
327
+ }
328
+ throw err;
329
+ }).finally(() => {
330
+ this._stanzaio.off('--transport-disconnected', rejectCallback);
308
331
  });
309
332
  }
333
+ stopServerLogging() {
334
+ /* flush all pending logs and webrtc stats – then turn off the logger */
335
+ this.logger.sendAllLogsInstantly();
336
+ this.logger.stopServerLogging();
337
+ this._webrtcSessions.flushStats();
338
+ }
339
+ startServerLogging() {
340
+ this.logger.startServerLogging();
341
+ }
310
342
  setAccessToken(token) {
311
343
  this.config.authToken = token;
312
344
  this.logger.setAccessToken(token);
@@ -318,7 +350,7 @@ class Client {
318
350
  extensions[namespace] = extension;
319
351
  }
320
352
  static get version() {
321
- return '13.5.0';
353
+ return '14.0.1';
322
354
  }
323
355
  }
324
356
  exports.Client = Client;
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HttpClient = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const superagent_1 = tslib_1.__importDefault(require("superagent"));
6
- const request_logger_1 = tslib_1.__importDefault(require("./request-logger"));
5
+ const axios_1 = tslib_1.__importStar(require("axios"));
7
6
  const utils_1 = require("./utils");
7
+ const correlationIdHeaderName = 'inin-correlation-id';
8
8
  class HttpClient {
9
9
  constructor() {
10
10
  this._httpRetryingRequests = new Map();
@@ -17,14 +17,56 @@ class HttpClient {
17
17
  return retry;
18
18
  }
19
19
  requestApi(path, opts) {
20
- let response = superagent_1.default[opts.method](this._buildUri(opts.host, path, opts.version))
21
- .use(request_logger_1.default.bind(this, opts.logger, opts.data))
22
- .type(opts.contentType || 'json');
20
+ const logger = opts.logger || console;
21
+ const start = new Date().getTime();
22
+ const url = this._buildUri(opts.host, path, opts.version);
23
+ const params = {
24
+ method: opts.method,
25
+ url,
26
+ headers: {
27
+ 'content-type': opts.contentType || 'application/json',
28
+ // we may not need this
29
+ 'accept-encoding': 'gzip, deflate'
30
+ }
31
+ };
23
32
  // default to include auth header
24
33
  if (!opts.noAuthHeader) {
25
- response.set('Authorization', `Bearer ${opts.authToken}`);
34
+ params.headers['Authorization'] = `Bearer ${opts.authToken}`;
26
35
  }
27
- return response.send(opts.data); // trigger request
36
+ const handleResponse = function (res) {
37
+ var _a;
38
+ let now = new Date().getTime();
39
+ let elapsed = (now - start) + 'ms';
40
+ if (res instanceof axios_1.AxiosError) {
41
+ /* istanbul ignore next */
42
+ const response = res.response || {};
43
+ let status = response.status;
44
+ let correlationId = (_a = response.headers) === null || _a === void 0 ? void 0 : _a[correlationIdHeaderName];
45
+ let body = response.data;
46
+ logger.debug(`request error: ${params.url}`, {
47
+ message: res.message,
48
+ now,
49
+ elapsed,
50
+ status,
51
+ correlationId,
52
+ body
53
+ }, true);
54
+ return Promise.reject(res);
55
+ }
56
+ let status = res.status;
57
+ let correlationId = res.headers[correlationIdHeaderName];
58
+ let body = JSON.stringify(res.data);
59
+ logger.debug(`response: ${opts.method.toUpperCase()} ${params.url}`, {
60
+ now,
61
+ status,
62
+ elapsed,
63
+ correlationId,
64
+ body
65
+ }, true);
66
+ return Promise.resolve(res);
67
+ };
68
+ return axios_1.default(params)
69
+ .then(handleResponse.bind(this), handleResponse.bind(this));
28
70
  }
29
71
  stopAllRetries() {
30
72
  Array.from(this._httpRetryingRequests.keys())
@@ -34,7 +76,7 @@ class HttpClient {
34
76
  const value = this._httpRetryingRequests.get(retryId);
35
77
  if (value) {
36
78
  /* if the promise has already completed, this will do nothing. Still need to remove it from the map */
37
- value.cancel(new Error('Retry request cancelled'));
79
+ value.reject(new Error('Retry request cancelled'));
38
80
  this._httpRetryingRequests.delete(retryId);
39
81
  }
40
82
  return true;
@@ -10,7 +10,7 @@ export declare class Reconnector {
10
10
  _backoffActive: boolean;
11
11
  _hardReconnectRetryInfo: null | RetryPromise<void>;
12
12
  constructor(client: any);
13
- hardReconnect(): Promise<void>;
13
+ hardReconnect(maxAttempts?: number, interval?: number): Promise<void>;
14
14
  cleanupReconnect(): void;
15
15
  start(): void;
16
16
  stop(error?: Error | string): void;
@@ -95,13 +95,15 @@ class Reconnector {
95
95
  });
96
96
  this._backoffActive = false;
97
97
  }
98
- async hardReconnect() {
98
+ async hardReconnect(maxAttempts, interval = HARD_RECONNECT_RETRY_MS) {
99
99
  if (this._hardReconnectRetryInfo) {
100
100
  return this._hardReconnectRetryInfo.promise;
101
101
  }
102
102
  this.cleanupReconnect();
103
103
  this._hasConnected = false;
104
- this._hardReconnectRetryInfo = utils_1.retryPromise(this._attemptHardReconnect.bind(this), this._shouldRetryError.bind(this), HARD_RECONNECT_RETRY_MS, this.client.logger);
104
+ this._hardReconnectRetryInfo = utils_1.retryPromise(this._attemptHardReconnect.bind(this), (error, retryCount) => {
105
+ return this._shouldRetryError(error, retryCount, maxAttempts);
106
+ }, interval, this.client.logger);
105
107
  try {
106
108
  await this._hardReconnectRetryInfo.promise;
107
109
  this._stopHardReconnect();
@@ -136,22 +138,32 @@ class Reconnector {
136
138
  if (typeof error === 'string') {
137
139
  error = new Error(error);
138
140
  }
139
- this._hardReconnectRetryInfo.cancel(error);
141
+ this._hardReconnectRetryInfo.reject(error);
140
142
  }
141
143
  else {
142
- this._hardReconnectRetryInfo.complete();
144
+ this._hardReconnectRetryInfo.resolve();
143
145
  }
144
146
  this._hardReconnectRetryInfo = null;
145
147
  }
146
- async _attemptHardReconnect() {
148
+ _attemptHardReconnect() {
147
149
  /* if we aren't online, don't retry the new channel */
148
150
  if (!navigator.onLine) {
149
151
  throw new Error(OFFLINE_ERROR);
150
152
  }
151
153
  this.client.logger.info('Attempting to reconnect with new channel.');
152
- await this.client.connect();
154
+ return this.client.connect();
153
155
  }
154
- _shouldRetryError(error) {
156
+ _shouldRetryError(error, attemptNumber, maxAttempts) {
157
+ if (typeof maxAttempts === 'number' && typeof attemptNumber === 'number') {
158
+ if (attemptNumber > maxAttempts) {
159
+ this.client.logger.debug('Max retry attempts reached trying to connect to new channel. Stopping retry', { attemptNumber, maxAttempts });
160
+ return false;
161
+ }
162
+ else {
163
+ this.client.logger.debug('Max retry attempts NOT reached trying to connect to new channel. Retrying', { attemptNumber, maxAttempts });
164
+ return true;
165
+ }
166
+ }
155
167
  /* we throw this is we are offline */
156
168
  if (error.message === OFFLINE_ERROR) {
157
169
  this.client.logger.debug('Browser is offline. Not attempting to reconnect with new channel.');
@@ -0,0 +1,54 @@
1
+ import WildEmitter from 'wildemitter';
2
+ export interface IRetryConfig<T = any> {
3
+ /**
4
+ * Function to attempt until it completes or rejects based on the
5
+ * criteria for retrying.
6
+ */
7
+ promiseFn: () => Promise<T>;
8
+ /**
9
+ * Retry criteria to retry the promise function on failure. Available options:
10
+ * - `boolean`: if `true`, it will _always_ be retried. if `false`, it will _never_
11
+ * be retried.
12
+ * - `number`: max attempts to retry
13
+ * - `function`: a function that accepts the error thrown and determines if it
14
+ * should be retried. It will be passed the `Error` and the `attemptCount`.
15
+ *
16
+ * Default: `false`
17
+ */
18
+ retry?: boolean | number | ((error?: Error | any, attemptCount?: number) => boolean);
19
+ /**
20
+ * Milliseconds to wait inbetween next retry of the promise function on failure.
21
+ *
22
+ * Default: `15000`
23
+ */
24
+ retryInterval?: number;
25
+ }
26
+ export declare class RetryPromise<T = any> extends WildEmitter {
27
+ promise: Promise<T>;
28
+ _id: string;
29
+ private _reject;
30
+ private _resolve;
31
+ private _hasCompleted;
32
+ private _attemptCount;
33
+ private _timeout;
34
+ private _config;
35
+ constructor(config: IRetryConfig);
36
+ /**
37
+ * @deprecated use `reject(reason)`
38
+ * @param reason value to reject the promise with
39
+ * @returns void
40
+ */
41
+ cancel(reason?: string | Error | any): void;
42
+ reject(reason?: string | Error | any): void;
43
+ /**
44
+ * @deprecated use `resolve(reason)`
45
+ * @param value to resolve the promise with
46
+ * @returns void
47
+ */
48
+ complete(value: T | PromiseLike<T>): void;
49
+ resolve(value: T | PromiseLike<T>): void;
50
+ hasCompleted(): boolean;
51
+ attemptCount(): number;
52
+ private _tryPromiseFn;
53
+ }
54
+ export declare function retryPromise<T = any>(promiseFn: () => Promise<T>, retry?: boolean | number | ((error?: Error | any, attemptCount?: number) => boolean), retryInterval?: number, _logger?: any): RetryPromise<T>;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.retryPromise = exports.RetryPromise = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const uuid_1 = require("uuid");
6
+ const wildemitter_1 = tslib_1.__importDefault(require("wildemitter"));
7
+ class RetryPromise extends wildemitter_1.default {
8
+ constructor(config) {
9
+ super();
10
+ this._id = uuid_1.v4();
11
+ this._hasCompleted = false;
12
+ this._attemptCount = 0;
13
+ this.promise = new Promise((resolve, reject) => {
14
+ this._resolve = resolve;
15
+ this._reject = reject;
16
+ });
17
+ this._config = {
18
+ promiseFn: config.promiseFn,
19
+ retry: config.retry || false,
20
+ retryInterval: config.retryInterval !== undefined && config.retryInterval > -1 ? config.retryInterval : 15000
21
+ };
22
+ /* tslint:disable:no-floating-promises */
23
+ this._tryPromiseFn();
24
+ }
25
+ /**
26
+ * @deprecated use `reject(reason)`
27
+ * @param reason value to reject the promise with
28
+ * @returns void
29
+ */
30
+ cancel(reason) {
31
+ return this.reject(reason);
32
+ }
33
+ reject(reason) {
34
+ this._reject(reason);
35
+ clearTimeout(this._timeout);
36
+ this._hasCompleted = true;
37
+ this.emit('rejected', reason);
38
+ }
39
+ /**
40
+ * @deprecated use `resolve(reason)`
41
+ * @param value to resolve the promise with
42
+ * @returns void
43
+ */
44
+ complete(value) {
45
+ return this.resolve(value);
46
+ }
47
+ resolve(value) {
48
+ this._resolve(value);
49
+ clearTimeout(this._timeout);
50
+ this._hasCompleted = true;
51
+ this.emit('resolved', value);
52
+ }
53
+ hasCompleted() {
54
+ return this._hasCompleted;
55
+ }
56
+ attemptCount() {
57
+ return this._attemptCount;
58
+ }
59
+ async _tryPromiseFn() {
60
+ const { retry, retryInterval } = this._config;
61
+ try {
62
+ this._attemptCount++;
63
+ this.emit('trying', {
64
+ attemptCount: this._attemptCount,
65
+ promise: this.promise
66
+ });
67
+ const val = await this._config.promiseFn();
68
+ this.resolve(val);
69
+ }
70
+ catch (error) {
71
+ if (
72
+ /* always retry */
73
+ retry === true ||
74
+ /* retry if under max retry attempts */
75
+ typeof retry === 'number' && this._attemptCount <= retry ||
76
+ /* retry if retry function returns true */
77
+ typeof retry === 'function' && retry(error, this._attemptCount + 1)) {
78
+ this.emit('retrying', {
79
+ error,
80
+ attemptCount: this._attemptCount,
81
+ retryInterval
82
+ });
83
+ this._timeout = setTimeout(this._tryPromiseFn.bind(this), retryInterval);
84
+ return;
85
+ }
86
+ this.reject(error);
87
+ }
88
+ }
89
+ }
90
+ exports.RetryPromise = RetryPromise;
91
+ function retryPromise(promiseFn, retry, retryInterval = 15000, _logger = console) {
92
+ return new RetryPromise({ promiseFn, retry, retryInterval });
93
+ }
94
+ exports.retryPromise = retryPromise;
@@ -1,16 +1,9 @@
1
+ export { retryPromise, RetryPromise } from './types/retry-utils';
1
2
  export declare function timeoutPromise(fn: Function, timeoutMs: number, msg: string, details?: any): Promise<void>;
2
3
  export declare function splitIntoIndividualTopics(topicString: string): string[];
3
4
  export declare const isAcdJid: (jid: string) => boolean;
4
5
  export declare const isScreenRecordingJid: (jid: string) => boolean;
5
6
  export declare const isSoftphoneJid: (jid: string) => boolean;
6
7
  export declare const isVideoJid: (jid: string) => boolean;
7
- export declare type RetryPromise<T = any> = {
8
- promise: Promise<T>;
9
- cancel: (reason?: string | Error) => void;
10
- complete: (value?: T) => void;
11
- hasCompleted: () => boolean;
12
- _id: string;
13
- };
14
- export declare function retryPromise<T = any>(promiseFn: () => Promise<T>, retryFn: (error?: Error | any) => boolean, retryInterval?: number, logger?: any): RetryPromise<T>;
15
8
  export declare const parseJwt: (token: string) => any;
16
9
  export declare function calculatePayloadSize(trace: any): number;
package/dist/cjs/utils.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculatePayloadSize = exports.parseJwt = exports.retryPromise = exports.isVideoJid = exports.isSoftphoneJid = exports.isScreenRecordingJid = exports.isAcdJid = exports.splitIntoIndividualTopics = exports.timeoutPromise = void 0;
4
- const uuid_1 = require("uuid");
3
+ exports.calculatePayloadSize = exports.parseJwt = exports.isVideoJid = exports.isSoftphoneJid = exports.isScreenRecordingJid = exports.isAcdJid = exports.splitIntoIndividualTopics = exports.timeoutPromise = exports.RetryPromise = exports.retryPromise = void 0;
4
+ var retry_utils_1 = require("./types/retry-utils");
5
+ Object.defineProperty(exports, "retryPromise", { enumerable: true, get: function () { return retry_utils_1.retryPromise; } });
6
+ Object.defineProperty(exports, "RetryPromise", { enumerable: true, get: function () { return retry_utils_1.RetryPromise; } });
5
7
  function timeoutPromise(fn, timeoutMs, msg, details) {
6
8
  return new Promise(function (resolve, reject) {
7
9
  const timeout = setTimeout(function () {
@@ -35,66 +37,27 @@ function splitIntoIndividualTopics(topicString) {
35
37
  return topics;
36
38
  }
37
39
  exports.splitIntoIndividualTopics = splitIntoIndividualTopics;
38
- exports.isAcdJid = function (jid) {
40
+ const isAcdJid = function (jid) {
39
41
  return jid.startsWith('acd-');
40
42
  };
41
- exports.isScreenRecordingJid = function (jid) {
43
+ exports.isAcdJid = isAcdJid;
44
+ const isScreenRecordingJid = function (jid) {
42
45
  return jid.startsWith('screenrecording-');
43
46
  };
44
- exports.isSoftphoneJid = function (jid) {
47
+ exports.isScreenRecordingJid = isScreenRecordingJid;
48
+ const isSoftphoneJid = function (jid) {
45
49
  if (!jid) {
46
50
  return false;
47
51
  }
48
52
  return !!jid.match(/.*@.*gjoll.*/i);
49
53
  };
50
- exports.isVideoJid = function (jid) {
54
+ exports.isSoftphoneJid = isSoftphoneJid;
55
+ const isVideoJid = function (jid) {
51
56
  return !!(jid && jid.match(/@conference/) && !exports.isAcdJid(jid));
52
57
  };
53
- function retryPromise(promiseFn, retryFn, retryInterval = 15000, logger = console) {
54
- let timeout;
55
- let cancel;
56
- let complete;
57
- let tryPromiseFn;
58
- let _hasCompleted = false;
59
- const promise = new Promise((resolve, reject) => {
60
- tryPromiseFn = async () => {
61
- try {
62
- const val = await promiseFn();
63
- complete(val);
64
- }
65
- catch (error) {
66
- if (retryFn(error)) {
67
- logger.debug('Retrying promise', error);
68
- timeout = setTimeout(tryPromiseFn, retryInterval);
69
- }
70
- else {
71
- cancel(error);
72
- }
73
- }
74
- };
75
- complete = (value) => {
76
- clearTimeout(timeout);
77
- _hasCompleted = true;
78
- resolve(value);
79
- };
80
- cancel = (reason) => {
81
- clearTimeout(timeout);
82
- _hasCompleted = true;
83
- reject(reason);
84
- };
85
- tryPromiseFn();
86
- });
87
- return {
88
- promise,
89
- cancel,
90
- complete,
91
- _id: uuid_1.v4(),
92
- hasCompleted: () => _hasCompleted
93
- };
94
- }
95
- exports.retryPromise = retryPromise;
58
+ exports.isVideoJid = isVideoJid;
96
59
  // from https://stackoverflow.com/questions/38552003/how-to-decode-jwt-token-in-javascript
97
- exports.parseJwt = (token) => {
60
+ const parseJwt = (token) => {
98
61
  const base64Url = token.split('.')[1];
99
62
  const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
100
63
  const jsonPayload = decodeURIComponent(window.atob(base64).split('').map(function (c) {
@@ -102,6 +65,7 @@ exports.parseJwt = (token) => {
102
65
  }).join(''));
103
66
  return JSON.parse(jsonPayload);
104
67
  };
68
+ exports.parseJwt = parseJwt;
105
69
  function calculatePayloadSize(trace) {
106
70
  const str = JSON.stringify(trace);
107
71
  // http://stackoverflow.com/questions/5515869/string-length-in-bytes-in-javascript
@@ -46,6 +46,7 @@ export declare class WebrtcExtension extends EventEmitter {
46
46
  sessionId: string;
47
47
  sessionType?: SessionTypes;
48
48
  };
49
+ flushStats(): void;
49
50
  sendStats(): Promise<void>;
50
51
  addEventListeners(): void;
51
52
  proxyEvents(): void;
@@ -102,6 +102,10 @@ class WebrtcExtension extends events_1.EventEmitter {
102
102
  // This should be moved when the sdk is the primary consumer
103
103
  proxyStatsForSession(session) {
104
104
  session.on('stats', (statsEvent) => {
105
+ /* if our logger was stopped, we need to stop stats logging too */
106
+ if (this.client.logger['stopReason']) {
107
+ return;
108
+ }
105
109
  const statsCopy = JSON.parse(JSON.stringify(statsEvent));
106
110
  const extraDetails = {
107
111
  conference: session.conversationId,
@@ -117,7 +121,7 @@ class WebrtcExtension extends events_1.EventEmitter {
117
121
  this.statBuffer += currentEventSize;
118
122
  // If it exceeds max size, don't append just send current payload.
119
123
  if (exceedsMaxStatSize) {
120
- this.throttledSendStats.flush();
124
+ this.flushStats();
121
125
  }
122
126
  else {
123
127
  this.throttledSendStats();
@@ -135,6 +139,9 @@ class WebrtcExtension extends events_1.EventEmitter {
135
139
  }
136
140
  return logDetails;
137
141
  }
142
+ flushStats() {
143
+ this.throttledSendStats.flush();
144
+ }
138
145
  async sendStats() {
139
146
  const statsToSend = [];
140
147
  let currentSize = 0;
@@ -5,18 +5,18 @@
5
5
  "team": "Genesys Client Media (WebRTC)",
6
6
  "indexFiles": [
7
7
  {
8
- "file": "/v13.5.0/streaming-client.browser.ie.js"
8
+ "file": "/v14.0.1/streaming-client.browser.ie.js"
9
9
  },
10
10
  {
11
- "file": "/v13.5.0/streaming-client.browser.js"
11
+ "file": "/v14.0.1/streaming-client.browser.js"
12
12
  },
13
13
  {
14
- "file": "/v13/streaming-client.browser.ie.js"
14
+ "file": "/v14/streaming-client.browser.ie.js"
15
15
  },
16
16
  {
17
- "file": "/v13/streaming-client.browser.js"
17
+ "file": "/v14/streaming-client.browser.js"
18
18
  }
19
19
  ],
20
- "build": "6",
21
- "buildDate": "2022-05-28T00:07:49.984882Z"
20
+ "build": "9",
21
+ "buildDate": "2022-06-01T15:49:16.445265Z"
22
22
  }
@@ -37,6 +37,9 @@ export declare class Client {
37
37
  disconnect(): Promise<void>;
38
38
  reconnect(): Promise<void>;
39
39
  connect(): Promise<void>;
40
+ _connectStanza(): Promise<void>;
41
+ stopServerLogging(): void;
42
+ startServerLogging(): void;
40
43
  setAccessToken(token: string): void;
41
44
  static extend(namespace: any, extension: StreamingClientExtension | ((client: Client) => void)): void;
42
45
  static get version(): string;