@reactoo/watchtogether-sdk-js 2.6.77 → 2.6.78

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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @reactoo/watchtogether-sdk-js
3
- * @version 2.6.77
3
+ * @version 2.6.78
4
4
  */
5
5
  (function webpackUniversalModuleDefinition(root, factory) {
6
6
  if(typeof exports === 'object' && typeof module === 'object')
@@ -8916,7 +8916,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) *
8916
8916
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
8917
8917
 
8918
8918
  "use strict";
8919
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var aws_iot_device_sdk__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! aws-iot-device-sdk */ \"./node_modules/aws-iot-device-sdk/index.js\");\n/* harmony import */ var aws_iot_device_sdk__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(aws_iot_device_sdk__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _wt_emitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./wt-emitter */ \"./src/modules/wt-emitter.js\");\n/* harmony import */ var _wt_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./wt-utils */ \"./src/modules/wt-utils.js\");\n\n\n\nclass Iot {\n constructor(enableDebugFlag) {\n Object.assign(this, Object(_wt_emitter__WEBPACK_IMPORTED_MODULE_1__[\"default\"])());\n this.device = null;\n this.decoder = new TextDecoder('utf-8');\n this.connectionActive = false;\n this.log = Iot.noop;\n this.debugFlag = enableDebugFlag;\n this.credentialsExpirationCheckIntervalId = null;\n this.currentCredentialsExpirationStamp = null;\n if (enableDebugFlag) {\n this.enableDebug();\n }\n }\n static noop() {}\n enableDebug() {\n this.log = console.log.bind(console);\n }\n startCredentialsExpirationCheck(expiration) {\n this.stopCredentialsExpirationCheck();\n this.currentCredentialsExpirationStamp = new Date(expiration).getTime();\n this.credentialsExpirationCheckIntervalId = setInterval(() => {\n const curentTimeStamp = new Date().getTime();\n if (this.currentCredentialsExpirationStamp - curentTimeStamp <= 300000) {\n this.emit('updateCredentials');\n }\n }, 5000);\n }\n stopCredentialsExpirationCheck() {\n clearInterval(this.credentialsExpirationCheckIntervalId);\n this.credentialsExpirationCheckIntervalId = null;\n }\n updateWebSocketCredentials(accessKeyId, secretAccessKey, sessionToken, expiration) {\n this.log('iot updateWebSocketCredentials');\n if (this.device) {\n this.device.updateWebSocketCredentials(accessKeyId, secretAccessKey, sessionToken);\n this.startCredentialsExpirationCheck(expiration);\n }\n }\n connect(apiMqttUrl, apiMqttClientId, region, accessKeyId, secretAccessKey, sessionToken, expiration) {\n let forceDisconnect = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;\n this.log('iot connect');\n return this.disconnect(forceDisconnect).then(() => {\n return new Promise((resolve, reject) => {\n this.device = Object(aws_iot_device_sdk__WEBPACK_IMPORTED_MODULE_0__[\"device\"])({\n protocol: 'wss',\n clientId: apiMqttClientId,\n region,\n host: apiMqttUrl,\n accessKeyId: accessKeyId,\n secretKey: secretAccessKey,\n sessionToken: sessionToken,\n keepalive: 30,\n maximumReconnectTimeMs: 8000,\n enableMetrics: false,\n debug: this.debugFlag,\n autoResubscribe: true\n });\n this.startCredentialsExpirationCheck(expiration);\n let __s = () => {\n var _this$device, _this$device2;\n (_this$device = this.device) === null || _this$device === void 0 ? void 0 : _this$device.off('connect', __s);\n (_this$device2 = this.device) === null || _this$device2 === void 0 ? void 0 : _this$device2.off('error', __e);\n resolve(this.device);\n };\n let __e = e => {\n var _this$device3, _this$device4;\n (_this$device3 = this.device) === null || _this$device3 === void 0 ? void 0 : _this$device3.off('connect', __s);\n (_this$device4 = this.device) === null || _this$device4 === void 0 ? void 0 : _this$device4.off('error', __e);\n reject(e);\n };\n this.device.once('connect', __s);\n this.device.once('error', __e);\n this.device.on('message', this.__messageCb.bind(this));\n this.device.on('connect', this.__connectCb.bind(this));\n this.device.on('reconnect', this.__reconnectCb.bind(this));\n this.device.on('error', this.__failureCb.bind(this));\n this.device.on('close', this.__closeCb.bind(this));\n this.device.on('offline', this.__offlineCb.bind(this));\n });\n });\n }\n disconnect() {\n let force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n this.stopCredentialsExpirationCheck();\n return new Promise((resolve, reject) => {\n if (!this.device) {\n resolve();\n return;\n }\n let __i = null;\n let __c = () => {\n clearTimeout(__i);\n this.device = null;\n resolve();\n };\n __i = setTimeout(__c, 4000);\n this.device.off('message', this.__messageCb.bind(this));\n this.device.off('connect', this.__connectCb.bind(this));\n this.device.off('reconnect', this.__reconnectCb.bind(this));\n this.device.off('error', this.__failureCb.bind(this));\n this.device.off('close', this.__closeCb.bind(this));\n this.device.off('offline', this.__offlineCb.bind(this));\n this.device.end(force, __c);\n });\n }\n isConnected() {\n return this.connectionActive;\n }\n subscribe(topic) {\n this.log('iot subscribe', topic);\n return this.device && this.device.subscribe(topic);\n }\n unsubscribe(topic) {\n this.log('iot unsubscribe', topic);\n return this.device && this.device.unsubscribe(topic);\n }\n send(topic, message) {\n this.log('iot send', topic, message);\n let msg = typeof message === 'object' ? JSON.stringify(message) : message;\n return this.device && this.device.publish(topic, msg);\n }\n __reconnectCb() {\n this.log('iot reconnect');\n this.emit('reconnect');\n }\n __connectCb() {\n this.log('iot connect');\n this.connectionActive = true;\n this.emit('connect');\n }\n __failureCb(err) {\n this.log('iot failure');\n this.emit('error', err);\n }\n __closeCb(responseObject) {\n this.log('iot close');\n this.connectionActive = false;\n this.emit('close');\n }\n __offlineCb(responseObject) {\n this.log('iot offline');\n this.emit('offline');\n }\n __messageCb(t, message, packet) {\n const topic = t.split('/');\n let payload = JSON.parse(this.decoder.decode(message));\n if (payload.display) {\n const decodedDisplay = Object(_wt_utils__WEBPACK_IMPORTED_MODULE_2__[\"decodeJanusDisplay\"])(payload.display);\n if (decodedDisplay.userId) {\n payload = {\n ...payload,\n userId: decodedDisplay.userId,\n role: decodedDisplay.role,\n start: decodedDisplay.start\n };\n }\n }\n if (topic[0] === 'user') {\n // user\n const userId = topic[1].replace(\"_\", ':');\n this.emit('message', {\n userId,\n ...payload,\n event: payload.event ? `user:${payload.event}` : 'user'\n });\n } else if (topic[0] === 'wt') {\n const event = payload.event;\n const roomId = topic[2];\n if (topic[1] === 'room') {\n // room\n if (event === 'message' || event === 'template_updated' || event === 'record_start' || event === 'record_stop' || event === 'record_configured' || event === 'record_livestream_available' || event === 'record_livestream_kick' || event === 'user_update_displayname' || event === 'user_update_avatar' || event === 'user_update_bio' || event === 'user_update_customattributes' || event === 'user_update_privateattributes' || event === 'channel_changed' || event === \"instance_homepage_changed\" || event === \"instance_settings_changed\" || event === \"externalmix_changed\" || event === \"video_uploaded\" || event === \"change_user_devices\" || event === \"queue\" || event === \"title_changed\") {\n this.emit('message', {\n event,\n ...payload,\n roomId\n });\n } else if (event === 'joined' || event === 'leaving') {\n this.emit('message', {\n event,\n ...payload,\n isObserver: !!payload.isObserver,\n roomId\n });\n } else if (event === 'left' ||\n //user removed room a.k.a. left the room\n event === 'kicked' || event === 'banned' || event === 'unbanned' || event === 'approved' || event === 'muted' || event === 'unmuted' || event === 'messageRemoved' || event === 'messageReported' || event === 'chatClear' || event === 'handRaised' || event === 'handLowered' || event === 'handsCleared') {\n this.emit('message', {\n event,\n ...payload\n });\n } else if (event === 'volume_set') {\n this.emit('message', {\n event,\n ...payload\n });\n }\n } else if (topic[1] === 'instanceroom') {\n // instance\n if (event === 'add_room' || event === 'remove_room' || event === 'set_room' || event === \"instance_homepage_changed\" || event === 'instance_settings_changed') {\n this.emit('message', {\n event,\n ...payload\n });\n }\n } else if (topic[1] === 'externalmix') {\n const event = payload.event;\n this.emit('message', {\n event,\n ...payload\n });\n } else if (topic[1] === 'asset') {\n this.emit('message', {\n event: 'asset',\n assetId: topic[2],\n ...payload\n });\n }\n } else if (topic[0] === 'wtr' || topic[0] === 'gwtr') {\n const recorderId = topic[1];\n const sessionId = topic[2];\n if (topic[3] === 'control') {\n this.emit('message', {\n event: 'recorder_control',\n ...payload,\n recorderId,\n sessionId\n });\n } // recorder control\n else if (topic[3] === 'monitor') {\n this.emit('message', {\n event: 'recorder_monitor',\n ...payload,\n recorderId,\n sessionId\n });\n } // recorder monitor\n }\n }\n}\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Iot);\n\n//# sourceURL=webpack://WatchTogetherSDK/./src/modules/wt-iot.js?");
8919
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var aws_iot_device_sdk__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! aws-iot-device-sdk */ \"./node_modules/aws-iot-device-sdk/index.js\");\n/* harmony import */ var aws_iot_device_sdk__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(aws_iot_device_sdk__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _wt_emitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./wt-emitter */ \"./src/modules/wt-emitter.js\");\n/* harmony import */ var _wt_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./wt-utils */ \"./src/modules/wt-utils.js\");\n\n\n\nclass Iot {\n constructor(enableDebugFlag) {\n Object.assign(this, Object(_wt_emitter__WEBPACK_IMPORTED_MODULE_1__[\"default\"])());\n this.device = null;\n this.decoder = new TextDecoder('utf-8');\n this.connectionActive = false;\n this.log = Iot.noop;\n this.debugFlag = enableDebugFlag;\n this.credentialsExpirationCheckIntervalId = null;\n this.currentCredentialsExpirationStamp = null;\n if (enableDebugFlag) {\n this.enableDebug();\n }\n }\n static noop() {}\n enableDebug() {\n this.log = console.log.bind(console);\n }\n startCredentialsExpirationCheck(expiration) {\n this.stopCredentialsExpirationCheck();\n this.currentCredentialsExpirationStamp = new Date(expiration).getTime();\n this.credentialsExpirationCheckIntervalId = setInterval(() => {\n const curentTimeStamp = new Date().getTime();\n if (this.currentCredentialsExpirationStamp - curentTimeStamp <= 300000) {\n this.emit('updateCredentials');\n }\n }, 5000);\n }\n stopCredentialsExpirationCheck() {\n clearInterval(this.credentialsExpirationCheckIntervalId);\n this.credentialsExpirationCheckIntervalId = null;\n }\n updateWebSocketCredentials(accessKeyId, secretAccessKey, sessionToken, expiration) {\n this.log('iot updateWebSocketCredentials');\n if (this.device) {\n this.device.updateWebSocketCredentials(accessKeyId, secretAccessKey, sessionToken);\n this.startCredentialsExpirationCheck(expiration);\n }\n }\n connect(apiMqttUrl, apiMqttClientId, region, accessKeyId, secretAccessKey, sessionToken, expiration) {\n let forceDisconnect = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;\n this.log('iot connect');\n return this.disconnect(forceDisconnect).then(() => {\n return new Promise((resolve, reject) => {\n this.device = Object(aws_iot_device_sdk__WEBPACK_IMPORTED_MODULE_0__[\"device\"])({\n protocol: 'wss',\n clientId: apiMqttClientId,\n region,\n host: apiMqttUrl,\n accessKeyId: accessKeyId,\n secretKey: secretAccessKey,\n sessionToken: sessionToken,\n keepalive: 30,\n maximumReconnectTimeMs: 8000,\n enableMetrics: false,\n debug: this.debugFlag,\n autoResubscribe: true\n });\n this.startCredentialsExpirationCheck(expiration);\n let __s = () => {\n var _this$device, _this$device2;\n (_this$device = this.device) === null || _this$device === void 0 ? void 0 : _this$device.off('connect', __s);\n (_this$device2 = this.device) === null || _this$device2 === void 0 ? void 0 : _this$device2.off('error', __e);\n resolve(this.device);\n };\n let __e = e => {\n var _this$device3, _this$device4;\n (_this$device3 = this.device) === null || _this$device3 === void 0 ? void 0 : _this$device3.off('connect', __s);\n (_this$device4 = this.device) === null || _this$device4 === void 0 ? void 0 : _this$device4.off('error', __e);\n reject(e);\n };\n this.device.once('connect', __s);\n this.device.once('error', __e);\n this.device.on('message', this.__messageCb.bind(this));\n this.device.on('connect', this.__connectCb.bind(this));\n this.device.on('reconnect', this.__reconnectCb.bind(this));\n this.device.on('error', this.__failureCb.bind(this));\n this.device.on('close', this.__closeCb.bind(this));\n this.device.on('offline', this.__offlineCb.bind(this));\n });\n });\n }\n disconnect() {\n let force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n this.stopCredentialsExpirationCheck();\n return new Promise((resolve, reject) => {\n if (!this.device) {\n resolve();\n return;\n }\n let __i = null;\n let __c = () => {\n clearTimeout(__i);\n this.device = null;\n resolve();\n };\n __i = setTimeout(__c, 4000);\n this.device.off('message', this.__messageCb.bind(this));\n this.device.off('connect', this.__connectCb.bind(this));\n this.device.off('reconnect', this.__reconnectCb.bind(this));\n this.device.off('error', this.__failureCb.bind(this));\n this.device.off('close', this.__closeCb.bind(this));\n this.device.off('offline', this.__offlineCb.bind(this));\n this.device.end(force, __c);\n });\n }\n isConnected() {\n return this.connectionActive;\n }\n subscribe(topic) {\n this.log('iot subscribe', topic);\n return this.device && this.device.subscribe(topic);\n }\n unsubscribe(topic) {\n this.log('iot unsubscribe', topic);\n return this.device && this.device.unsubscribe(topic);\n }\n send(topic, message) {\n this.log('iot send', topic, message);\n let msg = typeof message === 'object' ? JSON.stringify(message) : message;\n return this.device && this.device.publish(topic, msg);\n }\n __reconnectCb() {\n this.log('iot reconnect');\n this.emit('reconnect');\n }\n __connectCb() {\n this.log('iot connect');\n this.connectionActive = true;\n this.emit('connect');\n }\n __failureCb(err) {\n this.log('iot failure');\n this.emit('error', err);\n }\n __closeCb(responseObject) {\n this.log('iot close');\n this.connectionActive = false;\n this.emit('close');\n }\n __offlineCb(responseObject) {\n this.log('iot offline');\n this.emit('offline');\n }\n __messageCb(t, message, packet) {\n const topic = t.split('/');\n let payload = JSON.parse(this.decoder.decode(message));\n if (payload.display) {\n const decodedDisplay = Object(_wt_utils__WEBPACK_IMPORTED_MODULE_2__[\"decodeJanusDisplay\"])(payload.display);\n if (decodedDisplay.userId) {\n payload = {\n ...payload,\n userId: decodedDisplay.userId,\n role: decodedDisplay.role,\n start: decodedDisplay.start\n };\n }\n }\n if (topic[0] === 'user') {\n // user\n const userId = topic[1].replace(\"_\", ':');\n this.emit('message', {\n userId,\n ...payload,\n event: payload.event ? `user:${payload.event}` : 'user'\n });\n } else if (topic[0] === 'wt') {\n const event = payload.event;\n const roomId = topic[2];\n if (topic[1] === 'room') {\n // room\n if (event === 'message' || event === 'template_updated' || event === 'record_start' || event === 'record_stop' || event === 'record_configured' || event === 'record_livestream_available' || event === 'record_livestream_kick' || event === 'user_update_displayname' || event === 'user_update_avatar' || event === 'user_update_bio' || event === 'user_update_customattributes' || event === 'user_update_privateattributes' || event === 'channel_changed' || event === \"instance_homepage_changed\" || event === \"instance_settings_changed\" || event === \"externalmix_changed\" || event === \"video_uploaded\" || event === \"change_user_devices\" || event === \"queue\" || event === \"title_changed\" || event === \"videowall_changed\" || event === 'left' ||\n //user removed room a.k.a. left the room\n event === 'kicked' || event === 'banned' || event === 'unbanned' || event === 'approved' || event === 'muted' || event === 'unmuted' || event === 'messageRemoved' || event === 'messageReported' || event === 'chatClear' || event === 'handRaised' || event === 'handLowered' || event === 'handsCleared' || event === 'volume_set') {\n this.emit('message', {\n event,\n ...payload,\n roomId\n });\n } else if (event === 'joined' || event === 'leaving') {\n this.emit('message', {\n event,\n ...payload,\n isObserver: !!payload.isObserver,\n roomId\n });\n }\n } else if (topic[1] === 'instanceroom') {\n // instance\n if (event === 'add_room' || event === 'remove_room' || event === 'set_room' || event === \"instance_homepage_changed\" || event === 'instance_settings_changed') {\n this.emit('message', {\n event,\n ...payload\n });\n }\n } else if (topic[1] === 'externalmix') {\n const event = payload.event;\n this.emit('message', {\n event,\n ...payload\n });\n } else if (topic[1] === 'asset') {\n this.emit('message', {\n event: 'asset',\n assetId: topic[2],\n ...payload\n });\n }\n } else if (topic[0] === 'wtr' || topic[0] === 'gwtr') {\n const recorderId = topic[1];\n const sessionId = topic[2];\n if (topic[3] === 'control') {\n this.emit('message', {\n event: 'recorder_control',\n ...payload,\n recorderId,\n sessionId\n });\n } // recorder control\n else if (topic[3] === 'monitor') {\n this.emit('message', {\n event: 'recorder_monitor',\n ...payload,\n recorderId,\n sessionId\n });\n } // recorder monitor\n }\n }\n}\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Iot);\n\n//# sourceURL=webpack://WatchTogetherSDK/./src/modules/wt-iot.js?");
8920
8920
 
8921
8921
  /***/ }),
8922
8922