@openfin/cloud-notification-core-api 0.0.1-alpha.9a2ca93 → 0.0.1-alpha.9ac8c3d

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 (3) hide show
  1. package/index.cjs +6 -4
  2. package/index.mjs +6 -4
  3. package/package.json +1 -1
package/index.cjs CHANGED
@@ -337,7 +337,7 @@ class CloudNotificationAPI {
337
337
  async connect(parameters) {
338
338
  validateConnectParameters(parameters);
339
339
  this.#connectionParams = parameters;
340
- this.#logger('info', `Connecting to Cloud Notification service: ${this.#cloudNotificationSettings.url}`);
340
+ this.#logger('info', 'Creating Notification service session');
341
341
  if (this.#timeDifferenceTracker) {
342
342
  this.#timeDifferenceTracker.stop();
343
343
  this.#timeDifferenceTracker = undefined;
@@ -362,6 +362,8 @@ class CloudNotificationAPI {
362
362
  throw new CloudNotificationAPIError(`Failed to connect to the Cloud Notification service: ${this.#cloudNotificationSettings.url}`, 'ERR_CONNECT', new Error(createSessionResponse.statusText));
363
363
  }
364
364
  this.#sessionDetails = (await createSessionResponse.json());
365
+ const { mqtt: _, ...sessionDetailsWithoutMQTT } = this.#sessionDetails;
366
+ this.#logger('info', `Notification service session created: ${JSON.stringify(sessionDetailsWithoutMQTT, null, 2)}`);
365
367
  // Now have the details from the server about where to connect to and a token to connect with
366
368
  // we can go ahead and connect to the MQTT server
367
369
  await this.#connectToMQTT();
@@ -612,6 +614,8 @@ class CloudNotificationAPI {
612
614
  this.#logger('error', 'Invalid Session');
613
615
  throw new SessionNotConnectedError();
614
616
  }
617
+ const { token: _, ...mqttDetailsWithoutToken } = this.#sessionDetails.mqtt;
618
+ this.#logger('info', `Connecting to MQTT server: ${JSON.stringify(mqttDetailsWithoutToken, null, 2)}`);
615
619
  const clientOptions = {
616
620
  keepalive: this.#keepAliveIntervalSeconds,
617
621
  clientId: this.#sessionDetails.sessionId,
@@ -627,7 +631,6 @@ class CloudNotificationAPI {
627
631
  username: this.#sessionDetails.mqtt.token,
628
632
  };
629
633
  this.#mqttClient = await mqtt.connectAsync(this.#sessionDetails.mqtt.url, clientOptions);
630
- this.#logger('debug', `Cloud Notifications successfully connected to notification backbone`);
631
634
  this.#mqttClient.on('error', async (error) => this.#mqttErrorHandler(error));
632
635
  this.#mqttClient.on('reconnect', () => this.#mqttReconnectionHandler());
633
636
  // Does not fire on initial connection, only successful reconnection attempts
@@ -635,8 +638,7 @@ class CloudNotificationAPI {
635
638
  this.#mqttClient.on('message', (topic, message) => this.#mqttMessageHandler(topic, message));
636
639
  // Subscribe any session specific topics
637
640
  this.#mqttClient.subscribe(`${this.#sessionDetails.mqtt.sessionRootTopic}/#`);
638
- // NOTE: uncomment this to debug session details
639
- // this.#logger('info', `Cloud Notifications session created: ${JSON.stringify(this.#sessionDetails, null, 2)}`);
641
+ this.#logger('info', 'Successfully connected to MQTT server');
640
642
  // Subscribe to the user notification delivery topics for groups and users
641
643
  await this.#subscribeToNotificationTopics();
642
644
  }
package/index.mjs CHANGED
@@ -335,7 +335,7 @@ class CloudNotificationAPI {
335
335
  async connect(parameters) {
336
336
  validateConnectParameters(parameters);
337
337
  this.#connectionParams = parameters;
338
- this.#logger('info', `Connecting to Cloud Notification service: ${this.#cloudNotificationSettings.url}`);
338
+ this.#logger('info', 'Creating Notification service session');
339
339
  if (this.#timeDifferenceTracker) {
340
340
  this.#timeDifferenceTracker.stop();
341
341
  this.#timeDifferenceTracker = undefined;
@@ -360,6 +360,8 @@ class CloudNotificationAPI {
360
360
  throw new CloudNotificationAPIError(`Failed to connect to the Cloud Notification service: ${this.#cloudNotificationSettings.url}`, 'ERR_CONNECT', new Error(createSessionResponse.statusText));
361
361
  }
362
362
  this.#sessionDetails = (await createSessionResponse.json());
363
+ const { mqtt: _, ...sessionDetailsWithoutMQTT } = this.#sessionDetails;
364
+ this.#logger('info', `Notification service session created: ${JSON.stringify(sessionDetailsWithoutMQTT, null, 2)}`);
363
365
  // Now have the details from the server about where to connect to and a token to connect with
364
366
  // we can go ahead and connect to the MQTT server
365
367
  await this.#connectToMQTT();
@@ -610,6 +612,8 @@ class CloudNotificationAPI {
610
612
  this.#logger('error', 'Invalid Session');
611
613
  throw new SessionNotConnectedError();
612
614
  }
615
+ const { token: _, ...mqttDetailsWithoutToken } = this.#sessionDetails.mqtt;
616
+ this.#logger('info', `Connecting to MQTT server: ${JSON.stringify(mqttDetailsWithoutToken, null, 2)}`);
613
617
  const clientOptions = {
614
618
  keepalive: this.#keepAliveIntervalSeconds,
615
619
  clientId: this.#sessionDetails.sessionId,
@@ -625,7 +629,6 @@ class CloudNotificationAPI {
625
629
  username: this.#sessionDetails.mqtt.token,
626
630
  };
627
631
  this.#mqttClient = await mqtt.connectAsync(this.#sessionDetails.mqtt.url, clientOptions);
628
- this.#logger('debug', `Cloud Notifications successfully connected to notification backbone`);
629
632
  this.#mqttClient.on('error', async (error) => this.#mqttErrorHandler(error));
630
633
  this.#mqttClient.on('reconnect', () => this.#mqttReconnectionHandler());
631
634
  // Does not fire on initial connection, only successful reconnection attempts
@@ -633,8 +636,7 @@ class CloudNotificationAPI {
633
636
  this.#mqttClient.on('message', (topic, message) => this.#mqttMessageHandler(topic, message));
634
637
  // Subscribe any session specific topics
635
638
  this.#mqttClient.subscribe(`${this.#sessionDetails.mqtt.sessionRootTopic}/#`);
636
- // NOTE: uncomment this to debug session details
637
- // this.#logger('info', `Cloud Notifications session created: ${JSON.stringify(this.#sessionDetails, null, 2)}`);
639
+ this.#logger('info', 'Successfully connected to MQTT server');
638
640
  // Subscribe to the user notification delivery topics for groups and users
639
641
  await this.#subscribeToNotificationTopics();
640
642
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/cloud-notification-core-api",
3
- "version": "0.0.1-alpha.9a2ca93",
3
+ "version": "0.0.1-alpha.9ac8c3d",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "./index.cjs",