genesys-cloud-streaming-client 14.0.1-develop.9 → 14.1.0

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.
@@ -21,6 +21,8 @@ export declare class Client {
21
21
  deadChannels: string[];
22
22
  config: IClientConfig;
23
23
  streamId: any;
24
+ backgroundAssistantMode: boolean;
25
+ isGuest: boolean;
24
26
  http: HttpClient;
25
27
  notifications: NotificationsAPI;
26
28
  _notifications: Notifications;
@@ -30,6 +32,7 @@ export declare class Client {
30
32
  _ping: Ping;
31
33
  _reconnector: Reconnector;
32
34
  constructor(options: IClientOptions);
35
+ private checkIsBackgroundAssistant;
33
36
  cleanupLeakTimer(): void;
34
37
  on(eventName: any, ...args: any[]): this;
35
38
  once(eventName: any, ...args: any[]): this;
@@ -42,5 +45,6 @@ export declare class Client {
42
45
  startServerLogging(): void;
43
46
  setAccessToken(token: string): void;
44
47
  static extend(namespace: any, extension: StreamingClientExtension | ((client: Client) => void)): void;
48
+ get version(): string;
45
49
  static get version(): string;
46
50
  }
@@ -64,6 +64,8 @@ class Client {
64
64
  this.hardReconnectCount = 0;
65
65
  this.reconnectLeakTime = 1000 * 60 * 10; // 10 minutes
66
66
  this.deadChannels = [];
67
+ this.backgroundAssistantMode = false;
68
+ this.isGuest = false;
67
69
  this.http = new http_client_1.HttpClient();
68
70
  const stanzaio = stanza_1.createClient({});
69
71
  // TODO: remove this hack when we can. basically stanza messes up the auth mechanism priority.
@@ -82,12 +84,19 @@ class Client {
82
84
  appName: options.appName,
83
85
  appVersion: options.appVersion
84
86
  };
85
- const accessToken = options.authToken || '';
87
+ this.backgroundAssistantMode = this.checkIsBackgroundAssistant();
88
+ this.isGuest = !this.backgroundAssistantMode && !options.authToken;
89
+ let loggerAccessToken = options.authToken || '';
90
+ let loggerUrl = `https://api.${this.config.apiHost}/api/v2/diagnostics/trace`;
91
+ if (this.backgroundAssistantMode) {
92
+ loggerAccessToken = options.jwt;
93
+ loggerUrl += '/backgroundassistant';
94
+ }
86
95
  this.logger = new genesys_cloud_client_logger_1.Logger({
87
- accessToken,
88
- url: `https://api.${this.config.apiHost}/api/v2/diagnostics/trace`,
96
+ accessToken: loggerAccessToken,
97
+ url: loggerUrl,
89
98
  uploadDebounceTime: 1000,
90
- initializeServerLogging: !options.optOutOfWebrtcStatsTelemetry,
99
+ initializeServerLogging: !this.isGuest && !options.optOutOfWebrtcStatsTelemetry,
91
100
  /* streaming-client logging info */
92
101
  appVersion: Client.version,
93
102
  appName: 'streaming-client',
@@ -204,6 +213,13 @@ class Client {
204
213
  this[`_${extensionName}`] = extension;
205
214
  });
206
215
  }
216
+ checkIsBackgroundAssistant() {
217
+ if (this.config.jwt) {
218
+ const jwt = utils_1.parseJwt(this.config.jwt);
219
+ return jwt && jwt.iss === 'urn:purecloud:screenrecording';
220
+ }
221
+ return false;
222
+ }
207
223
  cleanupLeakTimer() {
208
224
  clearInterval(this.leakyReconnectTimer);
209
225
  this.leakyReconnectTimer = null;
@@ -349,8 +365,11 @@ class Client {
349
365
  }
350
366
  extensions[namespace] = extension;
351
367
  }
368
+ get version() {
369
+ return Client.version;
370
+ }
352
371
  static get version() {
353
- return '14.0.1';
372
+ return '14.1.0';
354
373
  }
355
374
  }
356
375
  exports.Client = Client;
@@ -23,10 +23,9 @@ class HttpClient {
23
23
  const params = {
24
24
  method: opts.method,
25
25
  url,
26
+ data: opts.data,
26
27
  headers: {
27
- 'content-type': opts.contentType || 'application/json',
28
- // we may not need this
29
- 'accept-encoding': 'gzip, deflate'
28
+ 'content-type': opts.contentType || 'application/json'
30
29
  }
31
30
  };
32
31
  // default to include auth header
@@ -157,7 +157,7 @@ class WebrtcExtension extends events_1.EventEmitter {
157
157
  }
158
158
  this.statsArr.splice(0, statsToSend.length);
159
159
  this.statBuffer = this.statsArr.reduce((currentSize, stats) => currentSize + utils_1.calculatePayloadSize(stats), 0);
160
- if (!statsToSend.length || !this.client.config.authToken) {
160
+ if (!statsToSend.length || this.client.isGuest) {
161
161
  return;
162
162
  }
163
163
  const data = {
@@ -169,10 +169,16 @@ class WebrtcExtension extends events_1.EventEmitter {
169
169
  };
170
170
  // At least for now, we'll just fire and forget. Since this is non-critical, we'll not retry failures
171
171
  try {
172
- await this.client.http.requestApi('diagnostics/newrelic/insights', {
172
+ let authToken = this.client.config.authToken;
173
+ let url = 'diagnostics/newrelic/insights';
174
+ if (this.client.backgroundAssistantMode) {
175
+ authToken = this.client.config.jwt;
176
+ url += '/backgroundassistant';
177
+ }
178
+ await this.client.http.requestApi(url, {
173
179
  method: 'post',
174
180
  host: this.client.config.apiHost,
175
- authToken: this.client.config.authToken,
181
+ authToken,
176
182
  logger: this.client.logger,
177
183
  data
178
184
  });
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "developercenter-cdn/streaming-client",
3
- "version": "develop",
3
+ "version": "14.1.0",
4
4
  "ecosystem": "pc",
5
5
  "team": "Genesys Client Media (WebRTC)",
6
6
  "indexFiles": [
7
7
  {
8
- "file": "/v14.0.1/streaming-client.browser.ie.js"
8
+ "file": "/v14.1.0/streaming-client.browser.ie.js"
9
9
  },
10
10
  {
11
- "file": "/v14.0.1/streaming-client.browser.js"
11
+ "file": "/v14.1.0/streaming-client.browser.js"
12
12
  },
13
13
  {
14
14
  "file": "/v14/streaming-client.browser.ie.js"
@@ -17,6 +17,6 @@
17
17
  "file": "/v14/streaming-client.browser.js"
18
18
  }
19
19
  ],
20
- "build": "9",
21
- "buildDate": "2022-06-01T15:49:16.445265Z"
20
+ "build": "34",
21
+ "buildDate": "2022-06-08T13:55:21.778993Z"
22
22
  }
@@ -21,6 +21,8 @@ export declare class Client {
21
21
  deadChannels: string[];
22
22
  config: IClientConfig;
23
23
  streamId: any;
24
+ backgroundAssistantMode: boolean;
25
+ isGuest: boolean;
24
26
  http: HttpClient;
25
27
  notifications: NotificationsAPI;
26
28
  _notifications: Notifications;
@@ -30,6 +32,7 @@ export declare class Client {
30
32
  _ping: Ping;
31
33
  _reconnector: Reconnector;
32
34
  constructor(options: IClientOptions);
35
+ private checkIsBackgroundAssistant;
33
36
  cleanupLeakTimer(): void;
34
37
  on(eventName: any, ...args: any[]): this;
35
38
  once(eventName: any, ...args: any[]): this;
@@ -42,5 +45,6 @@ export declare class Client {
42
45
  startServerLogging(): void;
43
46
  setAccessToken(token: string): void;
44
47
  static extend(namespace: any, extension: StreamingClientExtension | ((client: Client) => void)): void;
48
+ get version(): string;
45
49
  static get version(): string;
46
50
  }
package/dist/es/client.js CHANGED
@@ -63,6 +63,8 @@ export class Client {
63
63
  this.hardReconnectCount = 0;
64
64
  this.reconnectLeakTime = 1000 * 60 * 10; // 10 minutes
65
65
  this.deadChannels = [];
66
+ this.backgroundAssistantMode = false;
67
+ this.isGuest = false;
66
68
  this.http = new HttpClient();
67
69
  const stanzaio = createStanzaClient({});
68
70
  // TODO: remove this hack when we can. basically stanza messes up the auth mechanism priority.
@@ -81,12 +83,19 @@ export class Client {
81
83
  appName: options.appName,
82
84
  appVersion: options.appVersion
83
85
  };
84
- const accessToken = options.authToken || '';
86
+ this.backgroundAssistantMode = this.checkIsBackgroundAssistant();
87
+ this.isGuest = !this.backgroundAssistantMode && !options.authToken;
88
+ let loggerAccessToken = options.authToken || '';
89
+ let loggerUrl = `https://api.${this.config.apiHost}/api/v2/diagnostics/trace`;
90
+ if (this.backgroundAssistantMode) {
91
+ loggerAccessToken = options.jwt;
92
+ loggerUrl += '/backgroundassistant';
93
+ }
85
94
  this.logger = new Logger({
86
- accessToken,
87
- url: `https://api.${this.config.apiHost}/api/v2/diagnostics/trace`,
95
+ accessToken: loggerAccessToken,
96
+ url: loggerUrl,
88
97
  uploadDebounceTime: 1000,
89
- initializeServerLogging: !options.optOutOfWebrtcStatsTelemetry,
98
+ initializeServerLogging: !this.isGuest && !options.optOutOfWebrtcStatsTelemetry,
90
99
  /* streaming-client logging info */
91
100
  appVersion: Client.version,
92
101
  appName: 'streaming-client',
@@ -203,6 +212,13 @@ export class Client {
203
212
  this[`_${extensionName}`] = extension;
204
213
  });
205
214
  }
215
+ checkIsBackgroundAssistant() {
216
+ if (this.config.jwt) {
217
+ const jwt = parseJwt(this.config.jwt);
218
+ return jwt && jwt.iss === 'urn:purecloud:screenrecording';
219
+ }
220
+ return false;
221
+ }
206
222
  cleanupLeakTimer() {
207
223
  clearInterval(this.leakyReconnectTimer);
208
224
  this.leakyReconnectTimer = null;
@@ -350,7 +366,10 @@ export class Client {
350
366
  }
351
367
  extensions[namespace] = extension;
352
368
  }
369
+ get version() {
370
+ return Client.version;
371
+ }
353
372
  static get version() {
354
- return '14.0.1';
373
+ return '14.1.0';
355
374
  }
356
375
  }
@@ -19,10 +19,9 @@ export class HttpClient {
19
19
  const params = {
20
20
  method: opts.method,
21
21
  url,
22
+ data: opts.data,
22
23
  headers: {
23
- 'content-type': opts.contentType || 'application/json',
24
- // we may not need this
25
- 'accept-encoding': 'gzip, deflate'
24
+ 'content-type': opts.contentType || 'application/json'
26
25
  }
27
26
  };
28
27
  // default to include auth header
@@ -41946,7 +41946,7 @@ class WebrtcExtension extends EventEmitter {
41946
41946
  }
41947
41947
  this.statsArr.splice(0, statsToSend.length);
41948
41948
  this.statBuffer = this.statsArr.reduce((currentSize, stats) => currentSize + calculatePayloadSize(stats), 0);
41949
- if (!statsToSend.length || !this.client.config.authToken) {
41949
+ if (!statsToSend.length || this.client.isGuest) {
41950
41950
  return;
41951
41951
  }
41952
41952
  const data = {
@@ -41958,10 +41958,16 @@ class WebrtcExtension extends EventEmitter {
41958
41958
  };
41959
41959
  // At least for now, we'll just fire and forget. Since this is non-critical, we'll not retry failures
41960
41960
  try {
41961
- yield this.client.http.requestApi('diagnostics/newrelic/insights', {
41961
+ let authToken = this.client.config.authToken;
41962
+ let url = 'diagnostics/newrelic/insights';
41963
+ if (this.client.backgroundAssistantMode) {
41964
+ authToken = this.client.config.jwt;
41965
+ url += '/backgroundassistant';
41966
+ }
41967
+ yield this.client.http.requestApi(url, {
41962
41968
  method: 'post',
41963
41969
  host: this.client.config.apiHost,
41964
- authToken: this.client.config.authToken,
41970
+ authToken,
41965
41971
  logger: this.client.logger,
41966
41972
  data
41967
41973
  });
@@ -42836,10 +42842,9 @@ class HttpClient {
42836
42842
  const params = {
42837
42843
  method: opts.method,
42838
42844
  url,
42845
+ data: opts.data,
42839
42846
  headers: {
42840
- 'content-type': opts.contentType || 'application/json',
42841
- // we may not need this
42842
- 'accept-encoding': 'gzip, deflate'
42847
+ 'content-type': opts.contentType || 'application/json'
42843
42848
  }
42844
42849
  };
42845
42850
  // default to include auth header
@@ -43244,6 +43249,8 @@ class Client {
43244
43249
  this.hardReconnectCount = 0;
43245
43250
  this.reconnectLeakTime = 1000 * 60 * 10; // 10 minutes
43246
43251
  this.deadChannels = [];
43252
+ this.backgroundAssistantMode = false;
43253
+ this.isGuest = false;
43247
43254
  this.http = new HttpClient();
43248
43255
  const stanzaio = createClient({});
43249
43256
  // TODO: remove this hack when we can. basically stanza messes up the auth mechanism priority.
@@ -43262,12 +43269,19 @@ class Client {
43262
43269
  appName: options.appName,
43263
43270
  appVersion: options.appVersion
43264
43271
  };
43265
- const accessToken = options.authToken || '';
43272
+ this.backgroundAssistantMode = this.checkIsBackgroundAssistant();
43273
+ this.isGuest = !this.backgroundAssistantMode && !options.authToken;
43274
+ let loggerAccessToken = options.authToken || '';
43275
+ let loggerUrl = `https://api.${this.config.apiHost}/api/v2/diagnostics/trace`;
43276
+ if (this.backgroundAssistantMode) {
43277
+ loggerAccessToken = options.jwt;
43278
+ loggerUrl += '/backgroundassistant';
43279
+ }
43266
43280
  this.logger = new Logger({
43267
- accessToken,
43268
- url: `https://api.${this.config.apiHost}/api/v2/diagnostics/trace`,
43281
+ accessToken: loggerAccessToken,
43282
+ url: loggerUrl,
43269
43283
  uploadDebounceTime: 1000,
43270
- initializeServerLogging: !options.optOutOfWebrtcStatsTelemetry,
43284
+ initializeServerLogging: !this.isGuest && !options.optOutOfWebrtcStatsTelemetry,
43271
43285
  /* streaming-client logging info */
43272
43286
  appVersion: Client.version,
43273
43287
  appName: 'streaming-client',
@@ -43384,6 +43398,13 @@ class Client {
43384
43398
  this[`_${extensionName}`] = extension;
43385
43399
  });
43386
43400
  }
43401
+ checkIsBackgroundAssistant() {
43402
+ if (this.config.jwt) {
43403
+ const jwt = parseJwt(this.config.jwt);
43404
+ return jwt && jwt.iss === 'urn:purecloud:screenrecording';
43405
+ }
43406
+ return false;
43407
+ }
43387
43408
  cleanupLeakTimer() {
43388
43409
  clearInterval(this.leakyReconnectTimer);
43389
43410
  this.leakyReconnectTimer = null;
@@ -43531,8 +43552,11 @@ class Client {
43531
43552
  }
43532
43553
  extensions[namespace] = extension;
43533
43554
  }
43555
+ get version() {
43556
+ return Client.version;
43557
+ }
43534
43558
  static get version() {
43535
- return '14.0.1';
43559
+ return '14.1.0';
43536
43560
  }
43537
43561
  }
43538
43562
 
package/dist/es/webrtc.js CHANGED
@@ -155,7 +155,7 @@ export class WebrtcExtension extends EventEmitter {
155
155
  }
156
156
  this.statsArr.splice(0, statsToSend.length);
157
157
  this.statBuffer = this.statsArr.reduce((currentSize, stats) => currentSize + calculatePayloadSize(stats), 0);
158
- if (!statsToSend.length || !this.client.config.authToken) {
158
+ if (!statsToSend.length || this.client.isGuest) {
159
159
  return;
160
160
  }
161
161
  const data = {
@@ -167,10 +167,16 @@ export class WebrtcExtension extends EventEmitter {
167
167
  };
168
168
  // At least for now, we'll just fire and forget. Since this is non-critical, we'll not retry failures
169
169
  try {
170
- yield this.client.http.requestApi('diagnostics/newrelic/insights', {
170
+ let authToken = this.client.config.authToken;
171
+ let url = 'diagnostics/newrelic/insights';
172
+ if (this.client.backgroundAssistantMode) {
173
+ authToken = this.client.config.jwt;
174
+ url += '/backgroundassistant';
175
+ }
176
+ yield this.client.http.requestApi(url, {
171
177
  method: 'post',
172
178
  host: this.client.config.apiHost,
173
- authToken: this.client.config.authToken,
179
+ authToken,
174
180
  logger: this.client.logger,
175
181
  data
176
182
  });
@@ -3,7 +3,19 @@ All notable changes to this project will be documented in this file.
3
3
 
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
- # [Unreleased](https://github.com/purecloudlabs/genesys-cloud-streaming-client/compare/v14.0.0...HEAD)
6
+ # [Unreleased](https://github.com/purecloudlabs/genesys-cloud-streaming-client/compare/v14.1.0...HEAD)
7
+
8
+ # [v14.1.0](https://github.com/purecloudlabs/genesys-cloud-streaming-client/compare/v14.0.1...v14.1.0)
9
+ ### Added
10
+ * [PCM-1819](https://inindca.atlassian.net/browse/PCM-1819) Added separate backgroundassistant endpoints that will be used when using a screen recording jwt
11
+
12
+ # [v14.0.1](https://github.com/purecloudlabs/genesys-cloud-streaming-client/compare/v14.0.0...v14.0.1)
13
+
14
+ ### Fixed
15
+ * [PCM-1926](https://inindca.atlassian.net/browse/PCM-1926) – make sure that the `data` (ie. body) is sent with HTTP post & put requests.
16
+
17
+ ### Added
18
+ * Added instance level version property. The streaming-client version can now be accessed statically or on constructed instances.
7
19
 
8
20
  # [v14.0.0](https://github.com/purecloudlabs/genesys-cloud-streaming-client/compare/v13.4.1...v14.0.0)
9
21
  ### Breaking Changes
@@ -21,6 +21,8 @@ export declare class Client {
21
21
  deadChannels: string[];
22
22
  config: IClientConfig;
23
23
  streamId: any;
24
+ backgroundAssistantMode: boolean;
25
+ isGuest: boolean;
24
26
  http: HttpClient;
25
27
  notifications: NotificationsAPI;
26
28
  _notifications: Notifications;
@@ -30,6 +32,7 @@ export declare class Client {
30
32
  _ping: Ping;
31
33
  _reconnector: Reconnector;
32
34
  constructor(options: IClientOptions);
35
+ private checkIsBackgroundAssistant;
33
36
  cleanupLeakTimer(): void;
34
37
  on(eventName: any, ...args: any[]): this;
35
38
  once(eventName: any, ...args: any[]): this;
@@ -42,5 +45,6 @@ export declare class Client {
42
45
  startServerLogging(): void;
43
46
  setAccessToken(token: string): void;
44
47
  static extend(namespace: any, extension: StreamingClientExtension | ((client: Client) => void)): void;
48
+ get version(): string;
45
49
  static get version(): string;
46
50
  }
@@ -64,6 +64,8 @@ class Client {
64
64
  this.hardReconnectCount = 0;
65
65
  this.reconnectLeakTime = 1000 * 60 * 10; // 10 minutes
66
66
  this.deadChannels = [];
67
+ this.backgroundAssistantMode = false;
68
+ this.isGuest = false;
67
69
  this.http = new http_client_1.HttpClient();
68
70
  const stanzaio = stanza_1.createClient({});
69
71
  // TODO: remove this hack when we can. basically stanza messes up the auth mechanism priority.
@@ -82,12 +84,19 @@ class Client {
82
84
  appName: options.appName,
83
85
  appVersion: options.appVersion
84
86
  };
85
- const accessToken = options.authToken || '';
87
+ this.backgroundAssistantMode = this.checkIsBackgroundAssistant();
88
+ this.isGuest = !this.backgroundAssistantMode && !options.authToken;
89
+ let loggerAccessToken = options.authToken || '';
90
+ let loggerUrl = `https://api.${this.config.apiHost}/api/v2/diagnostics/trace`;
91
+ if (this.backgroundAssistantMode) {
92
+ loggerAccessToken = options.jwt;
93
+ loggerUrl += '/backgroundassistant';
94
+ }
86
95
  this.logger = new genesys_cloud_client_logger_1.Logger({
87
- accessToken,
88
- url: `https://api.${this.config.apiHost}/api/v2/diagnostics/trace`,
96
+ accessToken: loggerAccessToken,
97
+ url: loggerUrl,
89
98
  uploadDebounceTime: 1000,
90
- initializeServerLogging: !options.optOutOfWebrtcStatsTelemetry,
99
+ initializeServerLogging: !this.isGuest && !options.optOutOfWebrtcStatsTelemetry,
91
100
  /* streaming-client logging info */
92
101
  appVersion: Client.version,
93
102
  appName: 'streaming-client',
@@ -204,6 +213,13 @@ class Client {
204
213
  this[`_${extensionName}`] = extension;
205
214
  });
206
215
  }
216
+ checkIsBackgroundAssistant() {
217
+ if (this.config.jwt) {
218
+ const jwt = utils_1.parseJwt(this.config.jwt);
219
+ return jwt && jwt.iss === 'urn:purecloud:screenrecording';
220
+ }
221
+ return false;
222
+ }
207
223
  cleanupLeakTimer() {
208
224
  clearInterval(this.leakyReconnectTimer);
209
225
  this.leakyReconnectTimer = null;
@@ -349,8 +365,11 @@ class Client {
349
365
  }
350
366
  extensions[namespace] = extension;
351
367
  }
368
+ get version() {
369
+ return Client.version;
370
+ }
352
371
  static get version() {
353
- return '14.0.1';
372
+ return '14.1.0';
354
373
  }
355
374
  }
356
375
  exports.Client = Client;
@@ -23,10 +23,9 @@ class HttpClient {
23
23
  const params = {
24
24
  method: opts.method,
25
25
  url,
26
+ data: opts.data,
26
27
  headers: {
27
- 'content-type': opts.contentType || 'application/json',
28
- // we may not need this
29
- 'accept-encoding': 'gzip, deflate'
28
+ 'content-type': opts.contentType || 'application/json'
30
29
  }
31
30
  };
32
31
  // default to include auth header
@@ -157,7 +157,7 @@ class WebrtcExtension extends events_1.EventEmitter {
157
157
  }
158
158
  this.statsArr.splice(0, statsToSend.length);
159
159
  this.statBuffer = this.statsArr.reduce((currentSize, stats) => currentSize + utils_1.calculatePayloadSize(stats), 0);
160
- if (!statsToSend.length || !this.client.config.authToken) {
160
+ if (!statsToSend.length || this.client.isGuest) {
161
161
  return;
162
162
  }
163
163
  const data = {
@@ -169,10 +169,16 @@ class WebrtcExtension extends events_1.EventEmitter {
169
169
  };
170
170
  // At least for now, we'll just fire and forget. Since this is non-critical, we'll not retry failures
171
171
  try {
172
- await this.client.http.requestApi('diagnostics/newrelic/insights', {
172
+ let authToken = this.client.config.authToken;
173
+ let url = 'diagnostics/newrelic/insights';
174
+ if (this.client.backgroundAssistantMode) {
175
+ authToken = this.client.config.jwt;
176
+ url += '/backgroundassistant';
177
+ }
178
+ await this.client.http.requestApi(url, {
173
179
  method: 'post',
174
180
  host: this.client.config.apiHost,
175
- authToken: this.client.config.authToken,
181
+ authToken,
176
182
  logger: this.client.logger,
177
183
  data
178
184
  });