@jibb-open/jssdk 3.7.1 → 3.9.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.
- package/api/eventbus.js +1 -1
- package/api/recording.js +1 -1
- package/api/superadmin.js +1 -1
- package/api/user.js +1 -1
- package/package.json +1 -1
- package/types/exceptions.js +1 -1
- package/ws/connection_base.js +1 -1
- package/ws/eventbus.js +1 -1
- package/ws/ipsa.js +1 -1
- package/ws/meeting.js +1 -1
- package/ws/observable_connection.js +1 -1
- package/ws/retry_connection.js +1 -1
package/api/eventbus.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getCameraList=getCameraList,exports.getCameraPreview=getCameraPreview,exports.getClientStatusList=getClientStatusList,exports.sendMessage=sendMessage,exports.setRuntimeConfig=setRuntimeConfig,exports.startStream=startStream,exports.stopStream=stopStream,require("core-js/modules/es.promise.js");var _auth=require("./auth.js"),_config=require("../config.js"),_index=require("../utils/http/index.js");async function getCameraList(a){let b=await _index.http.get("".concat(_config.Config.apiBaseURL,"/v1/eventbus/clients/").concat(a,"/cameras"),await _prepareRequestHeaders());return b.data.items}async function getCameraPreview(a){let{cameraId:b,clientId:c}=a,d=await _index.http.post("".concat(_config.Config.apiBaseURL,"/v1/eventbus/").concat(c,"/preview"),{source:{id:b}},await _prepareRequestHeaders());return d.data.image}async function startStream(a){let{
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getCameraList=getCameraList,exports.getCameraPreview=getCameraPreview,exports.getClientStatusList=getClientStatusList,exports.sendMessage=sendMessage,exports.setRuntimeConfig=setRuntimeConfig,exports.startStream=startStream,exports.stopStream=stopStream,require("core-js/modules/es.promise.js");var _auth=require("./auth.js"),_config=require("../config.js"),_index=require("../utils/http/index.js");async function getCameraList(a){let b=await _index.http.get("".concat(_config.Config.apiBaseURL,"/v1/eventbus/clients/").concat(a,"/cameras"),await _prepareRequestHeaders());return b.data.items}async function getCameraPreview(a){let{cameraId:b,clientId:c}=a,d=await _index.http.post("".concat(_config.Config.apiBaseURL,"/v1/eventbus/").concat(c,"/preview"),{source:{id:b}},await _prepareRequestHeaders());return d.data.image}async function startStream(a){let{meetingToken:b,surfaceType:c,cameraId:d,sipUri:e,flipLeftRight:f,flipUpDown:g,rotation:h,fixedCorners:i,clientId:j,customCorners:k,enableColor:l,enableEstimation:m}=a,n={config:{surface_type:c},runtime_config:_makeRuntimeConfig({fixedCorners:i,flipLeftRight:f,flipUpDown:g,rotation:h,customCorners:k,enableColor:l,enableEstimation:m}),meeting_token:b};if(!d&&!e)return Promise.reject("Invalid request: either sipUri or cameraId should be specified");if(d&&e)return Promise.reject("Invalid request: both sipUri (".concat(e,") and cameraId (").concat(e,") are specified"));e?n.sip_uri=e:n.camera={id:d};return _index.http.post("".concat(_config.Config.apiBaseURL,"/v1/eventbus/clients/").concat(j,"/start"),{start_request:n},await _prepareRequestHeaders())}async function stopStream(a){return _index.http.post("".concat(_config.Config.apiBaseURL,"/v1/eventbus/").concat(a,"/stop"),{},await _prepareRequestHeaders())}async function sendMessage(a){return _index.http.post("".concat(_config.Config.apiBaseURL,"/v1/eventbus"),a,await _prepareRequestHeaders())}async function setRuntimeConfig(a){let{flipLeftRight:b,flipUpDown:c,rotation:d,fixedCorners:e,customCorners:f,clientId:g,enableColor:h,enableEstimation:i}=a,j={runtime_config_request:{runtime_config:_makeRuntimeConfig({fixedCorners:e,flipLeftRight:b,flipUpDown:c,rotation:d,customCorners:f,enableColor:h,enableEstimation:i})}};return _index.http.post("".concat(_config.Config.apiBaseURL,"/v1/eventbus/").concat(g,"/runtime_config"),j,await _prepareRequestHeaders())}async function getClientStatusList(){let a=await _index.http.get("".concat(_config.Config.apiBaseURL,"/v1/eventbus/clients"),await _prepareRequestHeaders());return a.data.clients}async function _prepareRequestHeaders(){return{"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()}}function _makeRuntimeConfig(a){let{fixedCorners:b,flipLeftRight:c,flipUpDown:d,rotation:e,customCorners:f,enableColor:g,enableEstimation:h}=a;switch(e){case 90:e="1";break;case 180:case-180:e="2";break;case-90:case 270:e="3";break;case 0:case 360:default:e="0";}return{custom_corners:f||[],rotation:e,enable_color:g||!1,fixed_corners:b,enable_estimation:h||!1,flip_up_down:d||!1,flip_left_right:c||!1}}
|
package/api/recording.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.startRecording=startRecording,exports.stopRecording=stopRecording,exports.takeSnapshot=takeSnapshot,require("core-js/modules/es.promise.js");var _config=require("../config.js"),_auth=require("./auth.js"),_index=require("../utils/http/index.js");async function startRecording(){let a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.startRecording=startRecording,exports.stopRecording=stopRecording,exports.takeSnapshot=takeSnapshot,require("core-js/modules/es.promise.js");var _config=require("../config.js"),_auth=require("./auth.js"),_index=require("../utils/http/index.js");async function startRecording(){let a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{meetingToken,interval,sensivityLevel};return async function(){let b=a.meetingToken,c=(null===a||void 0===a?void 0:a.interval)||0,d=(null===a||void 0===a?void 0:a.sensivityLevel)||0,e={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)(),"x-jibb-meeting-jwt":b},f=await _index.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings/recordings/start"),{write_interval:c,level:d},e);return f.data}()}async function stopRecording(){let a={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()},b=await _index.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings/recordings/stop"),{},a);return b.data}async function takeSnapshot(){let a={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()},b=await _index.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings/recordings/snapshot"),{},a);return b.data}
|
package/api/superadmin.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createOrganization=createOrganization,exports.deleteOrganization=deleteOrganization,exports.getOrganization=getOrganization,exports.getOrganizationList=getOrganizationList,require("core-js/modules/es.promise.js");var _config=require("../config.js"),_index=require("../utils/http/index.js"),_types=require("../types/types.js"),_auth=require("./auth.js");let accessLevel=_types.AccessLevel.SUPERADMIN;async function getOrganizationList(){let a={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createOrganization=createOrganization,exports.deleteOrganization=deleteOrganization,exports.getOrganization=getOrganization,exports.getOrganizationList=getOrganizationList,require("core-js/modules/es.promise.js");var _config=require("../config.js"),_index=require("../utils/http/index.js"),_types=require("../types/types.js"),_auth=require("./auth.js");let accessLevel=_types.AccessLevel.SUPERADMIN;async function getOrganizationList(){let a={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)({accessLevel:accessLevel})},b=await _index.http.get("".concat(_config.Config.apiBaseURL,"/v1/superadmin/organizations"),a);return b.data.organizations}async function getOrganization(a){if(""===a)throw new Error("organization ID can not be empty");let b={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)({accessLevel:accessLevel})},c=await _index.http.get("".concat(_config.Config.apiBaseURL,"/v1/superadmin/organizations/").concat(a),b);return c.data}async function createOrganization(a){let{organizationName:b,ownerEmail:c,level:d,licenseCount:e,expiryDate:f}=a,g={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)({accessLevel:accessLevel})};return _index.http.post("".concat(_config.Config.apiBaseURL,"/v1/superadmin/organizations/"),{name:b,owner_email:c,level:d,license_count:e,expiry_date:f},g)}async function deleteOrganization(a){let b={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)({accessLevel:accessLevel})};return _index.http.delete("".concat(_config.Config.apiBaseURL,"/v1/superadmin/organizations/").concat(a),b)}
|
package/api/user.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.activateUser=activateUser,exports.getUserInfo=getUserInfo,require("core-js/modules/es.promise.js");var _config=require("../config.js"),_auth=require("./auth.js"),_index=require("../utils/http/index.js");async function getUserInfo(){let a={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.activateUser=activateUser,exports.getUserInfo=getUserInfo,require("core-js/modules/es.promise.js");var _config=require("../config.js"),_auth=require("./auth.js"),_index=require("../utils/http/index.js");async function getUserInfo(){let a={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()},b=await _index.http.get("".concat(_config.Config.apiBaseURL,"/v1/users/me"),a);return b.data}async function activateUser(a){let b={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()};return _index.http.post("".concat(_config.Config.apiBaseURL,"/v1/users/activate"),{organizationId:a},b)}
|
package/package.json
CHANGED
package/types/exceptions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PermissionDeniedError=exports.NotStartedError=exports.NotFoundError=exports.NotConnectedError=exports.InvalidArgumentError=exports.AlreadyStartedError=exports.AlreadyConnectedError=void 0;class NotFoundError extends Error{constructor(a){super(a),this.name="NotFoundError"}}exports.NotFoundError=NotFoundError;class NotStartedError extends Error{constructor(a){super(a),this.name="NotStartedError"}}exports.NotStartedError=NotStartedError;class NotConnectedError extends Error{constructor(a){super(a),this.name="NotConnectedError"}}exports.NotConnectedError=NotConnectedError;class AlreadyStartedError extends Error{constructor(a){super(a),this.name="AlreadyStartedError"}}exports.AlreadyStartedError=AlreadyStartedError;class AlreadyConnectedError extends Error{constructor(a){super(a),this.name="AlreadyConnectedError"}}exports.AlreadyConnectedError=AlreadyConnectedError;class PermissionDeniedError extends Error{constructor(a){super(a),this.name="PermissionDeniedError"}}exports.PermissionDeniedError=PermissionDeniedError;class InvalidArgumentError extends Error{constructor(a){super(a),this.name="InvalidArgumentError"}}exports.InvalidArgumentError=InvalidArgumentError;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TooManyConnectionsError=exports.SessionTimeoutError=exports.PermissionDeniedError=exports.NotStartedError=exports.NotFoundError=exports.NotConnectedError=exports.InvalidArgumentError=exports.GenericError=exports.AlreadyStartedError=exports.AlreadyConnectedError=void 0;class NotFoundError extends Error{constructor(a){super(a),this.name="NotFoundError"}}exports.NotFoundError=NotFoundError;class NotStartedError extends Error{constructor(a){super(a),this.name="NotStartedError"}}exports.NotStartedError=NotStartedError;class NotConnectedError extends Error{constructor(a){super(a),this.name="NotConnectedError"}}exports.NotConnectedError=NotConnectedError;class AlreadyStartedError extends Error{constructor(a){super(a),this.name="AlreadyStartedError"}}exports.AlreadyStartedError=AlreadyStartedError;class AlreadyConnectedError extends Error{constructor(a){super(a),this.name="AlreadyConnectedError"}}exports.AlreadyConnectedError=AlreadyConnectedError;class PermissionDeniedError extends Error{constructor(a){super(a),this.name="PermissionDeniedError"}}exports.PermissionDeniedError=PermissionDeniedError;class InvalidArgumentError extends Error{constructor(a){super(a),this.name="InvalidArgumentError"}}exports.InvalidArgumentError=InvalidArgumentError;class SessionTimeoutError extends Error{constructor(a){super(a),this.name="SessionTimeoutError"}}exports.SessionTimeoutError=SessionTimeoutError;class TooManyConnectionsError extends Error{constructor(a){super(a),this.name="TooManyConnectionsError"}}exports.TooManyConnectionsError=TooManyConnectionsError;class GenericError extends Error{constructor(a,b){super(b),this.code=a,this.name="GenericError"}}exports.GenericError=GenericError;
|
package/ws/connection_base.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConnectionStatus=exports.ConnectionBase=void 0,require("core-js/modules/web.dom-collections.iterator.js");var _index=require("../utils/logger/index.js"),_future=require("../utils/future.js");function _classPrivateFieldInitSpec(a,b,c){_checkPrivateRedeclaration(a,b),b.set(a,c)}function _checkPrivateRedeclaration(a,b){if(b.has(a))throw new TypeError("Cannot initialize the same private elements twice on an object")}function _classPrivateFieldGet(a,b){var c=_classExtractFieldDescriptor(a,b,"get");return _classApplyDescriptorGet(a,c)}function _classApplyDescriptorGet(a,b){return b.get?b.get.call(a):b.value}function _classPrivateFieldSet(a,b,c){var d=_classExtractFieldDescriptor(a,b,"set");return _classApplyDescriptorSet(a,d,c),c}function _classExtractFieldDescriptor(a,b,c){if(!b.has(a))throw new TypeError("attempted to "+c+" private field on non-instance");return b.get(a)}function _classApplyDescriptorSet(a,b,c){if(b.set)b.set.call(a,c);else{if(!b.writable)throw new TypeError("attempted to set read only private field");b.value=c}}const ConnectionStatus={CONNECTED:"CONNECTED",DISCONNECTED:"DISCONNECTED",CONNECTING:"CONNECTING"};exports.ConnectionStatus=ConnectionStatus;var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConnectionStatus=exports.ConnectionBase=void 0,require("core-js/modules/es.promise.js"),require("core-js/modules/web.dom-collections.iterator.js");var _index=require("../utils/logger/index.js"),_future=require("../utils/future.js"),_proto=require("../types/proto.js"),_exceptions=require("../types/exceptions.js");function _classPrivateFieldInitSpec(a,b,c){_checkPrivateRedeclaration(a,b),b.set(a,c)}function _checkPrivateRedeclaration(a,b){if(b.has(a))throw new TypeError("Cannot initialize the same private elements twice on an object")}function _classPrivateFieldGet(a,b){var c=_classExtractFieldDescriptor(a,b,"get");return _classApplyDescriptorGet(a,c)}function _classApplyDescriptorGet(a,b){return b.get?b.get.call(a):b.value}function _classPrivateFieldSet(a,b,c){var d=_classExtractFieldDescriptor(a,b,"set");return _classApplyDescriptorSet(a,d,c),c}function _classExtractFieldDescriptor(a,b,c){if(!b.has(a))throw new TypeError("attempted to "+c+" private field on non-instance");return b.get(a)}function _classApplyDescriptorSet(a,b,c){if(b.set)b.set.call(a,c);else{if(!b.writable)throw new TypeError("attempted to set read only private field");b.value=c}}const ErrorCode=_proto.types.Code,ConnectionStatus={CONNECTED:"CONNECTED",DISCONNECTED:"DISCONNECTED",CONNECTING:"CONNECTING"};exports.ConnectionStatus=ConnectionStatus;var _connectionStatus=/*#__PURE__*/new WeakMap,_connectionFuture=/*#__PURE__*/new WeakMap,_socket=/*#__PURE__*/new WeakMap;class ConnectionBase{constructor(a){_classPrivateFieldInitSpec(this,_connectionStatus,{writable:!0,value:void 0}),_classPrivateFieldInitSpec(this,_connectionFuture,{writable:!0,value:void 0}),_classPrivateFieldInitSpec(this,_socket,{writable:!0,value:void 0}),this.name=a,_classPrivateFieldSet(this,_connectionStatus,ConnectionStatus.DISCONNECTED),_classPrivateFieldSet(this,_connectionFuture,new _future.Future),_classPrivateFieldGet(this,_connectionFuture).reject("disconnected"),_classPrivateFieldSet(this,_socket,null)}async connect(){switch(_classPrivateFieldGet(this,_connectionStatus)){case ConnectionStatus.CONNECTED:throw new Error("".concat(this.name,": already connected"));case ConnectionStatus.CONNECTING:throw new Error("".concat(this.name,": connection already in progress"));case ConnectionStatus.DISCONNECTED:break;default:throw new Error("".concat(this.name,": unknown connection status"));}_index.logger.info("".concat(this.name,": connecting ...")),_classPrivateFieldSet(this,_connectionStatus,ConnectionStatus.CONNECTING),_classPrivateFieldSet(this,_connectionFuture,new _future.Future);let a=await this.getURI();_classPrivateFieldSet(this,_socket,new WebSocket(a)),_classPrivateFieldGet(this,_socket).binaryType="arraybuffer",_classPrivateFieldGet(this,_socket).addEventListener("open",()=>{this.onConnected()}),_classPrivateFieldGet(this,_socket).addEventListener("close",()=>{this.onDisconnected()}),_classPrivateFieldGet(this,_socket).addEventListener("message",a=>{this.onData(a.data)}),_classPrivateFieldGet(this,_socket).addEventListener("error",a=>{this.onError(a)})}async getURI(){throw new Error("connection.getURI is not implemented")}disconnect(){null!=_classPrivateFieldGet(this,_socket)&&(_classPrivateFieldGet(this,_socket).close(),_classPrivateFieldSet(this,_socket,null),_index.logger.info("connection disconnected: ",this.name),this.onDisconnected())}async write(a){await this.waitForConnection(),_classPrivateFieldGet(this,_socket).send(a)}parseJSONResponse(a){try{let{code:b,reason:c}=JSON.parse(a);return b===ErrorCode.ERR_TOO_MANY_CONNECTIONS?this.onError(new _exceptions.TooManyConnectionsError(c)):b===ErrorCode.ERR_UNAUTHORIZED?this.onError(new _exceptions.PermissionDeniedError(c)):b===ErrorCode.ERR_BAD_REQUEST?(this.stop(),this.onError(new _exceptions.InvalidArgumentError(c))):b===ErrorCode.ERR_TIMEOUT?this.onErrror(new _exceptions.SessionTimeoutError(c)):this.onError(new _exceptions.GenericError(b,c))}catch(a){this.onError(a)}}getBufferedAmount(){return _classPrivateFieldGet(this,_socket)?_classPrivateFieldGet(this,_socket).bufferedAmount:0}onConnected(){_index.logger.info("".concat(this.name,": connected")),_classPrivateFieldSet(this,_connectionStatus,ConnectionStatus.CONNECTED),_classPrivateFieldGet(this,_connectionFuture).set("connected")}onDisconnected(){_index.logger.warn("".concat(this.name,": disconnected")),_classPrivateFieldSet(this,_connectionStatus,ConnectionStatus.DISCONNECTED),_classPrivateFieldGet(this,_connectionFuture).reject("disconnected")}isConnected(){return _classPrivateFieldGet(this,_connectionStatus)==ConnectionStatus.CONNECTED}waitForConnection(){return _classPrivateFieldGet(this,_connectionFuture).get()}getConnectionStatus(){return _classPrivateFieldGet(this,_connectionStatus)}onData(){}onError(a){_index.logger.warn("".concat(this.name,": onError: ").concat(a))}}exports.ConnectionBase=ConnectionBase;
|
package/ws/eventbus.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EventBusConnection=void 0,require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/es.promise.js"),require("core-js/modules/web.url.js"),require("core-js/modules/web.url-search-params.js"),require("core-js/modules/es.array-buffer.constructor.js"),require("core-js/modules/es.array-buffer.slice.js"),require("core-js/modules/es.typed-array.uint8-array.js"),require("core-js/modules/es.typed-array.fill.js"),require("core-js/modules/es.typed-array.set.js"),require("core-js/modules/es.typed-array.sort.js"),require("core-js/modules/es.typed-array.to-locale-string.js");var _config=require("../config.js"),_index=require("../utils/logger/index.js"),_exceptions=require("../types/exceptions.js"),_retry_connection=require("./retry_connection.js"),_connection_base=require("./connection_base.js"),_types=require("../types/types.js"),_proto=require("../types/proto.js"),_auth=require("../api/auth.js");function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _classPrivateMethodInitSpec(a,b){_checkPrivateRedeclaration(a,b),b.add(a)}function _classPrivateFieldInitSpec(a,b,c){_checkPrivateRedeclaration(a,b),b.set(a,c)}function _checkPrivateRedeclaration(a,b){if(b.has(a))throw new TypeError("Cannot initialize the same private elements twice on an object")}function _classPrivateMethodGet(a,b,c){if(!b.has(a))throw new TypeError("attempted to get private field on non-instance");return c}function _classPrivateFieldGet(a,b){var c=_classExtractFieldDescriptor(a,b,"get");return _classApplyDescriptorGet(a,c)}function _classApplyDescriptorGet(a,b){return b.get?b.get.call(a):b.value}function _classPrivateFieldSet(a,b,c){var d=_classExtractFieldDescriptor(a,b,"set");return _classApplyDescriptorSet(a,d,c),c}function _classExtractFieldDescriptor(a,b,c){if(!b.has(a))throw new TypeError("attempted to "+c+" private field on non-instance");return b.get(a)}function _classApplyDescriptorSet(a,b,c){if(b.set)b.set.call(a,c);else{if(!b.writable)throw new TypeError("attempted to set read only private field");b.value=c}}const ClientType=_proto.types.ClientType,ErrorCode=_proto.types.Code,BusMessage=_proto.cilix.BusMessage;function getClientNameByType(a){let b=Object.entries(ClientType).find(b=>{let[c,d]=b;return d==a});if(!b)throw new _exceptions.InvalidArgumentError("Invalid client type: ".concat(a));let c=b[0].toLowerCase();return c}var _expiryTimer=/*#__PURE__*/new WeakMap,_handleMessage=/*#__PURE__*/new WeakSet;class WSConnection extends _retry_connection.RetryConnection{constructor(a,b){let c=getClientNameByType(a).toLowerCase();super("eventbus-".concat(c)),_classPrivateMethodInitSpec(this,_handleMessage),_classPrivateFieldInitSpec(this,_expiryTimer,{writable:!0,value:void 0}),this.clientType=a,this.socket=null,this.userToken=null,this.clientName=c,this.name=b,_classPrivateFieldSet(this,_expiryTimer,null)}async start(){this.userToken=await(0,_auth.getUserToken)(),this.userClaims=new _types.UserClaims(this.userToken);let a=this.userClaims.getSecondsUntilExpiry();return 0>=a?void this.onErrorMessage(ErrorCode.ERR_TIMEOUT,"token expired"):void(_classPrivateFieldSet(this,_expiryTimer,setTimeout(()=>{this.stop(),this.onErrorMessage(ErrorCode.ERR_TIMEOUT,"token expired")},a)),super.start())}async stop(){clearTimeout(_classPrivateFieldGet(this,_expiryTimer)),super.stop()}disconnect(){null!=this.socket&&(this.socket.close(),this.socket=null,_index.logger.info("eventbus disconnect ",this.clientName)),super.disconnect()}async write(a){await super.waitForConnection(),_index.logger.debug("".concat(this.getName(),".write: "),BusMessage.toObject(a));let b=BusMessage.encode(a).finish();this.socket.send(b)}writeObject(a){let b=BusMessage.verify(a);if(b)throw new Error(b);let c=BusMessage.fromObject(a);return this.write(c)}async connect(){if(this.getConnectionStatus()!=_connection_base.ConnectionStatus.DISCONNECTED)return;super.connect();let a=this;try{let b=new _types.UserClaims(this.userToken);if(b.isExpired())return void a.onErrorMessage(ErrorCode.ERR_TIMEOUT,"token expired")}catch(b){return _index.logger.error(e),void a.onErrorMessage(ErrorCode.ERR_UNAUTHORIZED,"unauthorized")}let b=new URL(_config.Config.apiBaseURL),c="wss://".concat(b.hostname,"/ws/eventbus/").concat(this.clientName,"?user_token=").concat(this.userToken,"&name=").concat(this.name);this.socket=new WebSocket(c),this.socket.binaryType="arraybuffer",this.socket.addEventListener("open",()=>{a.onConnected()}),this.socket.addEventListener("close",()=>{a.onDisconnected()}),this.socket.addEventListener("message",b=>{_classPrivateMethodGet(a,_handleMessage,_handleMessage2).call(a,b.data)}),this.socket.addEventListener("error",b=>{a.onWarningMessage(ErrorCode.ERR_IO,b)})}onMessage(a){_index.logger.debug(a)}}async function _handleMessage2(a){try{if(a instanceof ArrayBuffer){let b=new Uint8Array(a),c=BusMessage.decode(b);return b=null,_index.logger.debug("".concat(this.getName(),".read: "),c),void this.onMessage(c)}}catch(a){_index.logger.error(a)}try{let b=JSON.parse(a);switch(b.code){case ErrorCode.ERR_TOO_MANY_CONNECTIONS:case ErrorCode.ERR_UNAUTHORIZED:case ErrorCode.ERR_BAD_REQUEST:case ErrorCode.ERR_TIMEOUT:this.onErrorMessage(b.code,b.reason);break;default:this.onInfoMessage(b.code,b.reason);}}catch(a){this.onWarningMessage(ErrorCode.ERR_IO,a)}}var _sendPreview=/*#__PURE__*/new WeakSet,_onCameraListRequest=/*#__PURE__*/new WeakSet,_onCameraListResponse=/*#__PURE__*/new WeakSet,_onClientConnected=/*#__PURE__*/new WeakSet,_onClientDisconnected=/*#__PURE__*/new WeakSet,_onRuntimeConfigRequest=/*#__PURE__*/new WeakSet,_onStopRequest=/*#__PURE__*/new WeakSet,_onPreviewRequest=/*#__PURE__*/new WeakSet,_onPreviewResponse=/*#__PURE__*/new WeakSet,_onStartRequest=/*#__PURE__*/new WeakSet,_onCornersReceived=/*#__PURE__*/new WeakSet,_onIPSAResponse=/*#__PURE__*/new WeakSet,_onTooManyPublishers=/*#__PURE__*/new WeakSet,_onRecordingStarted=/*#__PURE__*/new WeakSet,_onRecordingStopped=/*#__PURE__*/new WeakSet;class EventBusConnection extends WSConnection{static getInstance(){let a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:ClientType.WEBAPP,b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",d=EventBusConnection.instances.get(a);return d||(d=new EventBusConnection(a,b),EventBusConnection.instances.set(a,d)),d}constructor(){let a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:ClientType.WEBAPP,b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:"";super(a,b),_classPrivateMethodInitSpec(this,_onRecordingStopped),_classPrivateMethodInitSpec(this,_onRecordingStarted),_classPrivateMethodInitSpec(this,_onTooManyPublishers),_classPrivateMethodInitSpec(this,_onIPSAResponse),_classPrivateMethodInitSpec(this,_onCornersReceived),_classPrivateMethodInitSpec(this,_onStartRequest),_classPrivateMethodInitSpec(this,_onPreviewResponse),_classPrivateMethodInitSpec(this,_onPreviewRequest),_classPrivateMethodInitSpec(this,_onStopRequest),_classPrivateMethodInitSpec(this,_onRuntimeConfigRequest),_classPrivateMethodInitSpec(this,_onClientDisconnected),_classPrivateMethodInitSpec(this,_onClientConnected),_classPrivateMethodInitSpec(this,_onCameraListResponse),_classPrivateMethodInitSpec(this,_onCameraListRequest),_classPrivateMethodInitSpec(this,_sendPreview)}async onMessage(a){if(a&&"object"==typeof a)try{a.clientConnected&&_classPrivateMethodGet(this,_onClientConnected,_onClientConnected2).call(this,a),a.clientDisconnected&&_classPrivateMethodGet(this,_onClientDisconnected,_onClientDisconnected2).call(this,a),a.cameraListRequest&&_classPrivateMethodGet(this,_onCameraListRequest,_onCameraListRequest2).call(this,a),a.cameraListResponse&&_classPrivateMethodGet(this,_onCameraListResponse,_onCameraListResponse2).call(this,a),a.runtimeConfigRequest&&_classPrivateMethodGet(this,_onRuntimeConfigRequest,_onRuntimeConfigRequest2).call(this,a),a.startRequest&&_classPrivateMethodGet(this,_onStartRequest,_onStartRequest2).call(this,a),a.stopRequest&&_classPrivateMethodGet(this,_onStopRequest,_onStopRequest2).call(this,a),a.previewRequest&&_classPrivateMethodGet(this,_onPreviewRequest,_onPreviewRequest2).call(this,a),a.previewResponse&&_classPrivateMethodGet(this,_onPreviewResponse,_onPreviewResponse2).call(this,a),a.ipsaResponse&&_classPrivateMethodGet(this,_onIPSAResponse,_onIPSAResponse2).call(this,a),a.tooManyPublishers&&_classPrivateMethodGet(this,_onTooManyPublishers,_onTooManyPublishers2).call(this,a),a.recordingStarted&&_classPrivateMethodGet(this,_onRecordingStarted,_onRecordingStarted2).call(this,a),a.recordingStopped&&_classPrivateMethodGet(this,_onRecordingStopped,_onRecordingStopped2).call(this,a)}catch(a){_index.logger.error(a)}}stopStream(a){return this.writeObject({stopRequest:{},dst:{id:a}})}stopAllStreams(){return this.writeObject({stopRequest:{}})}startStream(a){let{config:b,runtimeConfig:c,camera:d,clientId:f,meetingToken:g}=a;return this.writeObject({startRequest:{config:b,runtimeConfig:c,camera:d,meetingToken:g},dst:{id:f}})}requestCameraPreview(a,b){return this.writeObject({previewRequest:{source:{id:b}},dst:{id:a}})}setRuntimeConfig(a,b){return this.writeObject({runtimeConfigRequest:b,dst:{id:a}})}getCameraList(a){return this.write({cameraListRequest:{},dst:{id:a}})}sendCameraList(a,b,c){return this.writeObject({cameraListResponse:{items:a},src:b,dst:c})}getClientStatusList(){return this.writeObject({clientStatusRequest:{}})}}exports.EventBusConnection=EventBusConnection;function _sendPreview2(a,b){return this.write({previewResponse:{image:a},dst:b})}async function _onCameraListRequest2(a){let b=await this.callSubscribers("onCameraListRequest",a.cameraListRequest);this.sendCameraList(b,a.dst,a.src)}function _onCameraListResponse2(a){this.notify("onCameraListResponse",a.cameraListResponse)}function _onClientConnected2(a){_index.logger.info("".concat(this.getName(),": client connected: "),a.src),this.notify("onClientConnected",a.src)}function _onClientDisconnected2(a){_index.logger.warn("".concat(this.getName(),": client disconnected: "),a.src),this.notify("onClientDisconnected",a.src)}function _onRuntimeConfigRequest2(a){this.notify("onRuntimeConfigRequest",a.runtimeConfigRequest)}function _onStopRequest2(a){this.notify("onStopRequest",a.stopRequest)}async function _onPreviewRequest2(a){let b=await this.callSubscribers("onPreviewRequest",a.previewRequest);_classPrivateMethodGet(this,_sendPreview,_sendPreview2).call(this,b,a.src)}function _onPreviewResponse2(a){this.notify("onPreviewResponse",a.previewResponse)}function _onStartRequest2(a){var b,c;let d=a.startRequest;!(null!==d&&void 0!==d&&null!==(b=d.camera)&&void 0!==b&&b.id)&&null!==d&&void 0!==d&&null!==(c=d.inputSource)&&void 0!==c&&c.id&&(d.camera={id:d.inputSource.id}),this.notify("onStartRequest",d)}function _onCornersReceived2(a){this.notify("onCornersReceived",a.corners.corners)}function _onIPSAResponse2(a){a&&this.notify("onIPSAResponse",a.ipsaResponse)}function _onTooManyPublishers2(a){this.notify("onTooManyPublishers",a.tooManyPublishers)}function _onRecordingStarted2(a){this.notify("onRecordingStarted",a.recordingStarted)}function _onRecordingStopped2(a){this.notify("onRecordingStopped",a.recordingStopped)}_defineProperty(EventBusConnection,"instances",new Map);
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EventBusConnection=void 0,require("core-js/modules/es.promise.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/web.url.js"),require("core-js/modules/web.url-search-params.js"),require("core-js/modules/es.array-buffer.constructor.js"),require("core-js/modules/es.array-buffer.slice.js"),require("core-js/modules/es.typed-array.uint8-array.js"),require("core-js/modules/es.typed-array.fill.js"),require("core-js/modules/es.typed-array.set.js"),require("core-js/modules/es.typed-array.sort.js"),require("core-js/modules/es.typed-array.to-locale-string.js"),require("core-js/modules/esnext.aggregate-error.js"),require("core-js/modules/esnext.promise.any.js");var _config=require("../config.js"),_index=require("../utils/logger/index.js"),_exceptions=require("../types/exceptions.js"),_types=require("../types/types.js"),_proto=require("../types/proto.js"),_auth=require("../api/auth.js"),_observable_connection=require("./observable_connection.js");function _classPrivateMethodInitSpec(a,b){_checkPrivateRedeclaration(a,b),b.add(a)}function _classPrivateFieldInitSpec(a,b,c){_checkPrivateRedeclaration(a,b),b.set(a,c)}function _checkPrivateRedeclaration(a,b){if(b.has(a))throw new TypeError("Cannot initialize the same private elements twice on an object")}function _classPrivateMethodGet(a,b,c){if(!b.has(a))throw new TypeError("attempted to get private field on non-instance");return c}function _classPrivateFieldGet(a,b){var c=_classExtractFieldDescriptor(a,b,"get");return _classApplyDescriptorGet(a,c)}function _classApplyDescriptorGet(a,b){return b.get?b.get.call(a):b.value}function _classPrivateFieldSet(a,b,c){var d=_classExtractFieldDescriptor(a,b,"set");return _classApplyDescriptorSet(a,d,c),c}function _classExtractFieldDescriptor(a,b,c){if(!b.has(a))throw new TypeError("attempted to "+c+" private field on non-instance");return b.get(a)}function _classApplyDescriptorSet(a,b,c){if(b.set)b.set.call(a,c);else{if(!b.writable)throw new TypeError("attempted to set read only private field");b.value=c}}const ClientType=_proto.types.ClientType,BusMessage=_proto.cilix.BusMessage;let instance,clientType=ClientType.WEBAPP,clientName="client";const observable=new _observable_connection.Observable;var _expiryTimer=/*#__PURE__*/new WeakMap,_onMessage=/*#__PURE__*/new WeakSet,_getClientTypeAsString=/*#__PURE__*/new WeakSet,_sendPreview=/*#__PURE__*/new WeakSet,_onCameraListRequest=/*#__PURE__*/new WeakSet,_onCameraListResponse=/*#__PURE__*/new WeakSet,_onClientConnected=/*#__PURE__*/new WeakSet,_onClientDisconnected=/*#__PURE__*/new WeakSet,_onRuntimeConfigRequest=/*#__PURE__*/new WeakSet,_onStopRequest=/*#__PURE__*/new WeakSet,_onPreviewRequest=/*#__PURE__*/new WeakSet,_onPreviewResponse=/*#__PURE__*/new WeakSet,_onStartRequest=/*#__PURE__*/new WeakSet,_onCornersReceived=/*#__PURE__*/new WeakSet,_onIPSAResponse=/*#__PURE__*/new WeakSet,_onTooManyPublishers=/*#__PURE__*/new WeakSet,_onRecordingStarted=/*#__PURE__*/new WeakSet,_onRecordingStopped=/*#__PURE__*/new WeakSet,_callSubscribers=/*#__PURE__*/new WeakSet;class EventBusConnection extends _observable_connection.ObservableRetryConnection{static getInstance(){return instance||(instance=new EventBusConnection),instance}static subscribe(a,b){observable.subscribe(a,b)}static unsubscribe(a){observable.unsubscribe(a)}static setClientName(a){clientName=a}static setClientType(a){clientType=a}constructor(){super("eventbus-".concat(clientName)),_classPrivateMethodInitSpec(this,_callSubscribers),_classPrivateMethodInitSpec(this,_onRecordingStopped),_classPrivateMethodInitSpec(this,_onRecordingStarted),_classPrivateMethodInitSpec(this,_onTooManyPublishers),_classPrivateMethodInitSpec(this,_onIPSAResponse),_classPrivateMethodInitSpec(this,_onCornersReceived),_classPrivateMethodInitSpec(this,_onStartRequest),_classPrivateMethodInitSpec(this,_onPreviewResponse),_classPrivateMethodInitSpec(this,_onPreviewRequest),_classPrivateMethodInitSpec(this,_onStopRequest),_classPrivateMethodInitSpec(this,_onRuntimeConfigRequest),_classPrivateMethodInitSpec(this,_onClientDisconnected),_classPrivateMethodInitSpec(this,_onClientConnected),_classPrivateMethodInitSpec(this,_onCameraListResponse),_classPrivateMethodInitSpec(this,_onCameraListRequest),_classPrivateMethodInitSpec(this,_sendPreview),_classPrivateMethodInitSpec(this,_getClientTypeAsString),_classPrivateMethodInitSpec(this,_onMessage),_classPrivateFieldInitSpec(this,_expiryTimer,{writable:!0,value:void 0}),this.observable=observable,this.userToken=null,_classPrivateFieldSet(this,_expiryTimer,null)}async stop(){clearTimeout(_classPrivateFieldGet(this,_expiryTimer)),super.stop()}async write(a){_index.logger.debug("".concat(this.name,".write: "),BusMessage.toObject(a));let b=BusMessage.encode(a).finish();return super.write(b)}writeObject(a){let b=BusMessage.verify(a);if(b)throw new Error(b);let c=BusMessage.fromObject(a);return this.write(c)}async getURI(){try{this.userToken=await(0,_auth.getUserToken)(),this.userClaims=new _types.UserClaims(this.userToken);let a=this.userClaims.getSecondsUntilExpiry();if(0>=a){let a=new _exceptions.PermissionDeniedError("user token expired");throw this.onError(a),a}_classPrivateFieldSet(this,_expiryTimer,setTimeout(()=>{this.onError(new _exceptions.SessionTimeoutError("user token expired"))},a))}catch(a){let b=new _exceptions.PermissionDeniedError(a);throw this.onError(b),b}let a=new URL(_config.Config.apiBaseURL),b=_classPrivateMethodGet(this,_getClientTypeAsString,_getClientTypeAsString2).call(this,clientType);return"wss://".concat(a.hostname,"/ws/eventbus/").concat(b,"?user_token=").concat(this.userToken,"&name=").concat(clientName)}onData(a){try{if(a instanceof ArrayBuffer){let b=new Uint8Array(a),c=BusMessage.decode(b);return b=null,_index.logger.debug("".concat(this.name,".read: "),c),void _classPrivateMethodGet(this,_onMessage,_onMessage2).call(this,c)}}catch(a){_index.logger.error(a)}this.parseJSONResponse(a)}stopStream(a){return this.writeObject({stopRequest:{},dst:{id:a}})}stopAllStreams(){return this.writeObject({stopRequest:{}})}startStream(a){let{config:b,runtimeConfig:c,camera:d,clientId:e,meetingToken:f}=a;return this.writeObject({startRequest:{config:b,runtimeConfig:c,camera:d,meetingToken:f},dst:{id:e}})}requestCameraPreview(a,b){return this.writeObject({previewRequest:{source:{id:b}},dst:{id:a}})}setRuntimeConfig(a,b){return this.writeObject({runtimeConfigRequest:b,dst:{id:a}})}getCameraList(a){return this.writeObject({cameraListRequest:{},dst:{id:a}})}sendCameraList(a,b,c){return this.writeObject({cameraListResponse:{items:a},src:b,dst:c})}getClientStatusList(){return this.writeObject({clientStatusRequest:{}})}}exports.EventBusConnection=EventBusConnection;async function _onMessage2(a){if(a&&"object"==typeof a)try{a.clientConnected&&_classPrivateMethodGet(this,_onClientConnected,_onClientConnected2).call(this,a),a.clientDisconnected&&_classPrivateMethodGet(this,_onClientDisconnected,_onClientDisconnected2).call(this,a),a.cameraListRequest&&_classPrivateMethodGet(this,_onCameraListRequest,_onCameraListRequest2).call(this,a),a.cameraListResponse&&_classPrivateMethodGet(this,_onCameraListResponse,_onCameraListResponse2).call(this,a),a.runtimeConfigRequest&&_classPrivateMethodGet(this,_onRuntimeConfigRequest,_onRuntimeConfigRequest2).call(this,a),a.startRequest&&_classPrivateMethodGet(this,_onStartRequest,_onStartRequest2).call(this,a),a.stopRequest&&_classPrivateMethodGet(this,_onStopRequest,_onStopRequest2).call(this,a),a.previewRequest&&_classPrivateMethodGet(this,_onPreviewRequest,_onPreviewRequest2).call(this,a),a.previewResponse&&_classPrivateMethodGet(this,_onPreviewResponse,_onPreviewResponse2).call(this,a),a.ipsaResponse&&_classPrivateMethodGet(this,_onIPSAResponse,_onIPSAResponse2).call(this,a),a.tooManyPublishers&&_classPrivateMethodGet(this,_onTooManyPublishers,_onTooManyPublishers2).call(this,a),a.recordingStarted&&_classPrivateMethodGet(this,_onRecordingStarted,_onRecordingStarted2).call(this,a),a.recordingStopped&&_classPrivateMethodGet(this,_onRecordingStopped,_onRecordingStopped2).call(this,a)}catch(a){_index.logger.error(a)}}function _getClientTypeAsString2(a){let b=Object.entries(ClientType).find(b=>{let[c,d]=b;return d==a});if(!b)throw new _exceptions.InvalidArgumentError("Invalid client type: ".concat(a));let c=b[0].toLowerCase();return c}function _sendPreview2(a,b){this.writeObject({previewResponse:{image:a},dst:b})}async function _onCameraListRequest2(a){let b=await _classPrivateMethodGet(this,_callSubscribers,_callSubscribers2).call(this,"onCameraListRequest",a.cameraListRequest);this.sendCameraList(b,a.dst,a.src)}function _onCameraListResponse2(a){observable.notify("onCameraListResponse",a.cameraListResponse)}function _onClientConnected2(a){_index.logger.info("".concat(this.name,": client connected: "),a.src),observable.notify("onClientConnected",a.src)}function _onClientDisconnected2(a){_index.logger.warn("".concat(this.name,": client disconnected: "),a.src),observable.notify("onClientDisconnected",a.src)}function _onRuntimeConfigRequest2(a){observable.notify("onRuntimeConfigRequest",a.runtimeConfigRequest)}function _onStopRequest2(a){observable.notify("onStopRequest",a.stopRequest)}async function _onPreviewRequest2(a){let b=await _classPrivateMethodGet(this,_callSubscribers,_callSubscribers2).call(this,"onPreviewRequest",a.previewRequest);_classPrivateMethodGet(this,_sendPreview,_sendPreview2).call(this,b,a.src)}function _onPreviewResponse2(a){observable.notify("onPreviewResponse",a.previewResponse)}function _onStartRequest2(a){var b,c;let d=a.startRequest;!(null!==d&&void 0!==d&&null!==(b=d.camera)&&void 0!==b&&b.id)&&null!==d&&void 0!==d&&null!==(c=d.inputSource)&&void 0!==c&&c.id&&(d.camera={id:d.inputSource.id}),observable.notify("onStartRequest",d)}function _onCornersReceived2(a){observable.notify("onCornersReceived",a.corners.corners)}function _onIPSAResponse2(a){a&&observable.notify("onIPSAResponse",a.ipsaResponse)}function _onTooManyPublishers2(a){observable.notify("onTooManyPublishers",a.tooManyPublishers)}function _onRecordingStarted2(a){observable.notify("onRecordingStarted",a.recordingStarted)}function _onRecordingStopped2(a){observable.notify("onRecordingStopped",a.recordingStopped)}function _callSubscribers2(a){for(var b=arguments.length,c=Array(1<b?b-1:0),d=1;d<b;d++)c[d-1]=arguments[d];let e=[...observable.observers].map(b=>{let[c,d]=b;return d[a]}).filter(a=>a!==void 0).map(a=>a(...c));return Promise.any(e)}
|
package/ws/ipsa.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.IPSA=void 0,require("core-js/modules/es.promise.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/web.url.js"),require("core-js/modules/web.url-search-params.js"),require("core-js/modules/es.array
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.IPSA=void 0,require("core-js/modules/es.promise.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/web.url.js"),require("core-js/modules/web.url-search-params.js"),require("core-js/modules/es.array-buffer.constructor.js"),require("core-js/modules/es.array-buffer.slice.js"),require("core-js/modules/es.typed-array.uint8-array.js"),require("core-js/modules/es.typed-array.fill.js"),require("core-js/modules/es.typed-array.set.js"),require("core-js/modules/es.typed-array.sort.js"),require("core-js/modules/es.typed-array.to-locale-string.js");var _config=require("../config.js"),_index=require("../utils/logger/index.js"),_types=require("../types/types.js"),_proto=require("../types/proto.js"),_auth=require("../api/auth.js"),_observable_connection=require("./observable_connection.js"),_exceptions=require("../types/exceptions.js");function _classPrivateMethodInitSpec(a,b){_checkPrivateRedeclaration(a,b),b.add(a)}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(a,b,c){var d=_superPropBase(a,b);if(d){var e=Object.getOwnPropertyDescriptor(d,b);return e.get?e.get.call(3>arguments.length?a:c):e.value}},_get.apply(this,arguments)}function _superPropBase(a,b){for(;!Object.prototype.hasOwnProperty.call(a,b)&&(a=_getPrototypeOf(a),null!==a););return a}function _getPrototypeOf(a){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},_getPrototypeOf(a)}function _classPrivateFieldInitSpec(a,b,c){_checkPrivateRedeclaration(a,b),b.set(a,c)}function _checkPrivateRedeclaration(a,b){if(b.has(a))throw new TypeError("Cannot initialize the same private elements twice on an object")}function _classPrivateFieldGet(a,b){var c=_classExtractFieldDescriptor(a,b,"get");return _classApplyDescriptorGet(a,c)}function _classApplyDescriptorGet(a,b){return b.get?b.get.call(a):b.value}function _classPrivateMethodGet(a,b,c){if(!b.has(a))throw new TypeError("attempted to get private field on non-instance");return c}function _classPrivateFieldSet(a,b,c){var d=_classExtractFieldDescriptor(a,b,"set");return _classApplyDescriptorSet(a,d,c),c}function _classExtractFieldDescriptor(a,b,c){if(!b.has(a))throw new TypeError("attempted to "+c+" private field on non-instance");return b.get(a)}function _classApplyDescriptorSet(a,b,c){if(b.set)b.set.call(a,c);else{if(!b.writable)throw new TypeError("attempted to set read only private field");b.value=c}}var _meetingExpiryTimer=/*#__PURE__*/new WeakMap,_write=/*#__PURE__*/new WeakSet,_setConfig=/*#__PURE__*/new WeakSet;class IPSAClass extends _observable_connection.ObservableRetryConnection{constructor(a){super("ipsa",a),_classPrivateMethodInitSpec(this,_setConfig),_classPrivateMethodInitSpec(this,_write),_classPrivateFieldInitSpec(this,_meetingExpiryTimer,{writable:!0,value:void 0}),this.socket=null,_classPrivateFieldSet(this,_meetingExpiryTimer,null),this.meetingToken=null,this.meetingClaims=null}async start(a){let{meetingToken:b,request:c}=a;if(this.isStarted())throw new Error("already started");this.setRuntimeConfig(c.runtimeConfig),_classPrivateMethodGet(this,_setConfig,_setConfig2).call(this,c.config),this.meetingToken=b,this.meetingClaims=new _types.MeetingClaims(this.meetingToken);let d=this.meetingClaims.getSecondsUntilExpiry();if(0>=d){let a=new _exceptions.PermissionDeniedError("meeting token expired");throw this.onError(a),a}else clearTimeout(_classPrivateFieldGet(this,_meetingExpiryTimer)),_classPrivateFieldSet(this,_meetingExpiryTimer,setTimeout(()=>{let a=new _exceptions.SessionTimeoutError("meeting token expired");this.onError(a)},d));super.start()}stop(){clearTimeout(_classPrivateFieldGet(this,_meetingExpiryTimer)),this.configRequest=null,this.runtimeConfigRequest=null,super.stop()}async getURI(){let a;try{a=await(0,_auth.getUserToken)({minExpiry:3600});let b=new _types.UserClaims(a),c=b.getSecondsUntilExpiry();if(0>=c){let a=new _exceptions.PermissionDeniedError("user token expired");throw this.onError(a),a}}catch(a){let b=new _exceptions.PermissionDeniedError(a);throw this.onError(b),b}let b=this.meetingClaims.meetindId;_index.logger.info("Starting IPSA...");let c=new URL(_config.Config.apiBaseURL);return"wss://".concat(c.hostname,"/ws/ipsa/").concat(b,"?user_token=").concat(a,"&meeting_token=").concat(this.meetingToken)}onData(a){try{if(a instanceof ArrayBuffer){let b=new Uint8Array(a),c=_proto.ipsa.Response.decode(b);return void this.notify("onResponse",c)}}catch(a){_index.logger.error(a)}this.parseJSONResponse(a)}writeData(a){if(!this.isStarted())throw new Error("not started");let b=this.getBufferedAmount();0<b&&_index.logger.warn("ipsa: low internet speed connection. [buffer size: ".concat(b,"]"));let c=_proto.ipsa.Request.create({ipsa:{data:a}});return _classPrivateMethodGet(this,_write,_write2).call(this,c)}onConnected(){_classPrivateMethodGet(this,_write,_write2).call(this,this.configRequest),_classPrivateMethodGet(this,_write,_write2).call(this,this.runtimeConfigRequest),super.onConnected()}setRuntimeConfig(a){if(!a)throw(0,_exceptions.InvalidArgumentError)("bad request");let b=_proto.ipsa.Request.create({runtimeConfig:a});this.runtimeConfigRequest=b,this.isConnected()&&_classPrivateMethodGet(this,_write,_write2).call(this,b)}}async function _write2(a){let b=_proto.ipsa.Request.verify(a);if(b)throw new Error("invalid message: "+b);if(a){let b=_proto.ipsa.Request.encode(a).finish();_get(_getPrototypeOf(IPSAClass.prototype),"write",this).call(this,b)}}function _setConfig2(a){if(!a)throw(0,_exceptions.InvalidArgumentError)("bad request");let b=_proto.ipsa.Request.create({config:a});this.configRequest=b}let IPSA=new IPSAClass({maxRetryCount:10,minRetryIntervalMs:500,maxRetryIntervalMs:4e3});exports.IPSA=IPSA;
|
package/ws/meeting.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MeetingConnection=void 0,require("core-js/modules/es.global-this.js"),require("core-js/modules/es.promise.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/web.url.js"),require("core-js/modules/web.url-search-params.js"),require("core-js/modules/es.array-buffer.constructor.js"),require("core-js/modules/es.array-buffer.slice.js"),require("core-js/modules/es.typed-array.uint8-array.js"),require("core-js/modules/es.typed-array.fill.js"),require("core-js/modules/es.typed-array.set.js"),require("core-js/modules/es.typed-array.sort.js"),require("core-js/modules/es.typed-array.to-locale-string.js");var _auth=require("../api/auth.js"),_config=require("../config.js"),_index=require("../utils/logger/index.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MeetingConnection=void 0,require("core-js/modules/es.global-this.js"),require("core-js/modules/es.promise.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/web.url.js"),require("core-js/modules/web.url-search-params.js"),require("core-js/modules/es.array-buffer.constructor.js"),require("core-js/modules/es.array-buffer.slice.js"),require("core-js/modules/es.typed-array.uint8-array.js"),require("core-js/modules/es.typed-array.fill.js"),require("core-js/modules/es.typed-array.set.js"),require("core-js/modules/es.typed-array.sort.js"),require("core-js/modules/es.typed-array.to-locale-string.js");var _auth=require("../api/auth.js"),_config=require("../config.js"),_index=require("../utils/logger/index.js"),_types=require("../types/types.js"),_proto=require("../types/proto.js"),_exceptions=require("../types/exceptions.js"),_observable_connection=require("./observable_connection.js");function _classPrivateFieldInitSpec(a,b,c){_checkPrivateRedeclaration(a,b),b.set(a,c)}function _checkPrivateRedeclaration(a,b){if(b.has(a))throw new TypeError("Cannot initialize the same private elements twice on an object")}function _classPrivateFieldGet(a,b){var c=_classExtractFieldDescriptor(a,b,"get");return _classApplyDescriptorGet(a,c)}function _classApplyDescriptorGet(a,b){return b.get?b.get.call(a):b.value}function _classPrivateFieldSet(a,b,c){var d=_classExtractFieldDescriptor(a,b,"set");return _classApplyDescriptorSet(a,d,c),c}function _classExtractFieldDescriptor(a,b,c){if(!b.has(a))throw new TypeError("attempted to "+c+" private field on non-instance");return b.get(a)}function _classApplyDescriptorSet(a,b,c){if(b.set)b.set.call(a,c);else{if(!b.writable)throw new TypeError("attempted to set read only private field");b.value=c}}function _getRequireWildcardCache(a){if("function"!=typeof WeakMap)return null;var b=new WeakMap,c=new WeakMap;return(_getRequireWildcardCache=function(a){return a?c:b})(a)}function _interopRequireWildcard(a,b){if(!b&&a&&a.__esModule)return a;if(null===a||"object"!=typeof a&&"function"!=typeof a)return{default:a};var c=_getRequireWildcardCache(b);if(c&&c.has(a))return c.get(a);var d={},e=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in a)if("default"!=f&&Object.prototype.hasOwnProperty.call(a,f)){var g=e?Object.getOwnPropertyDescriptor(a,f):null;g&&(g.get||g.set)?Object.defineProperty(d,f,g):d[f]=a[f]}return d.default=a,c&&c.set(a,d),d}let Message=_proto.meeting.Message,ErrorCode=_proto.types.Code;(null===globalThis||void 0===globalThis?void 0:globalThis.WebSocket)==null&&Promise.resolve().then(()=>_interopRequireWildcard(require("isomorphic-ws"))).then(a=>{globalThis.WebSocket=a.default});var _expiryTimer=/*#__PURE__*/new WeakMap;class MeetingConnectionImp extends _observable_connection.ObservableRetryConnection{constructor(){let a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{maxRetryCount:10,minRetryIntervalMs:500,maxRetryIntervalMs:32e3};super("meeting",a),_classPrivateFieldInitSpec(this,_expiryTimer,{writable:!0,value:void 0}),this.meetingId=null,this.meetingToken=null,_classPrivateFieldSet(this,_expiryTimer,null)}start(a){this.meetingToken=a,this.meetingClaims=new _types.MeetingClaims(a),this.meetingId=this.meetingClaims.meetindId,this.name="meeting-".concat(this.meetingId);let b=this.meetingClaims.getSecondsUntilExpiry();if(0>=b){let a=new _exceptions.PermissionDeniedError("meeting token expired");throw this.onError(a),a}_classPrivateFieldSet(this,_expiryTimer,setTimeout(()=>{this.stop(),this.onError(new _exceptions.SessionTimeoutError("meeting token expired"))},b)),super.start()}stop(){clearTimeout(_classPrivateFieldGet(this,_expiryTimer)),super.stop()}async getURI(){try{if(this.meetingClaims.isExpired()){let a=new _exceptions.PermissionDeniedError("meeting token expired");throw this.onError(a),a}}catch(a){let b=new _exceptions.PermissionDeniedError(a);throw b}let a=new URL(_config.Config.apiBaseURL);return"wss://"+a.hostname+"/ws/meetings/"+this.meetingId+"?meeting_token="+this.meetingToken}async onData(a){try{if(a instanceof ArrayBuffer){let b=new Uint8Array(a),c=Message.decode(b);return null!==c&&void 0!==c&&c.update&&this.notify("onMeetingUpdate",c.update),null!==c&&void 0!==c&&c.drawing&&this.notify("onDrawing",c.drawing),void(null!==c&&void 0!==c&&c.pointer?this.notify("onPointer",c):null!==c&&void 0!==c&&c.join?this.notify("onMeetingJoin",c.join):null!==c&&void 0!==c&&c.leave&&this.notify("onMeetingLeave",c.leave))}}catch(a){_index.logger.error(a)}this.parseJSONResponse(a)}async sendPointer(a,b){let c=await(0,_auth.getUserClaims)(),d=Message.fromObject({pointer:{email:c.email,x:a,y:b}}),e=Message.encode(d).finish();this.write(e)}async sendDrawing(a){let{email:b,data:c}=a,d=Message.fromObject({drawing:{email:b,data:c}});_index.logger.debug("".concat(this.name,".Drawing: "),Message.toObject(d));let e=Message.encode(d).finish();this.write(e)}}let MeetingConnection=new MeetingConnectionImp({maxRetryCount:10,minRetryIntervalMs:500,maxRetryIntervalMs:8e3});exports.MeetingConnection=MeetingConnection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ObservableRetryConnection=exports.Observable=void 0,require("core-js/modules/web.dom-collections.iterator.js");var _index=require("../utils/logger/index.js"),_retry_connection=require("./retry_connection.js");class Observable{constructor(){this.observers=new Map}subscribe(a,b){this.observers.set(a,b)}unsubscribeAll(){this.observers=new Map}unsubscribe(a){try{this.observers.delete(a)}catch(a){_index.logger.error(a)}}notify(a){for(var b=arguments.length,c=Array(1<b?b-1:0),d=1;d<b;d++)c[d-1]=arguments[d];this.observers.forEach(b=>{try{let d=b[a];d&&d(...c)}catch(b){_index.logger.error("Error occured notifying event ".concat(a),b)}})}}exports.Observable=Observable;class ObservableRetryConnection extends _retry_connection.RetryConnection{constructor(a){let b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{maxRetryCount:10,minRetryIntervalMs:500,maxRetryIntervalMs:32e3};super(a,b),this.observable=new Observable}subscribe(a,b){this.observable.subscribe(a,b)}unsubscribeAll(){this.observable.unsubscribeAll()}unsubscribe(a){this.observable.unsubscribe(a)}notify(a){for(var b=arguments.length,c=Array(1<b?b-1:0),d=1;d<b;d++)c[d-1]=arguments[d];this.observable.notify(a,...c)}onDisconnected(){super.onDisconnected(),this.observable.notify("onDisconnected")}onConnected(){super.onConnected(),this.observable.notify("onConnected")}onStarted(){super.onStarted(),this.observable.notify("onStarted")}onStopped(){super.onStopped(),this.observable.notify("onStopped")}onError(a){super.onError(a),this.observable.notify("onError",a)}}exports.ObservableRetryConnection=ObservableRetryConnection;
|
package/ws/retry_connection.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RetryConnection=void 0,require("core-js/modules/web.dom-collections.iterator.js");var _index=require("../utils/logger/index.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RetryConnection=void 0,require("core-js/modules/web.dom-collections.iterator.js");var _exceptions=require("../types/exceptions.js"),_index=require("../utils/logger/index.js"),_connection_base=require("./connection_base.js");function _classPrivateMethodInitSpec(a,b){_checkPrivateRedeclaration(a,b),b.add(a)}function _classPrivateFieldInitSpec(a,b,c){_checkPrivateRedeclaration(a,b),b.set(a,c)}function _checkPrivateRedeclaration(a,b){if(b.has(a))throw new TypeError("Cannot initialize the same private elements twice on an object")}function _classPrivateFieldGet(a,b){var c=_classExtractFieldDescriptor(a,b,"get");return _classApplyDescriptorGet(a,c)}function _classApplyDescriptorGet(a,b){return b.get?b.get.call(a):b.value}function _classPrivateMethodGet(a,b,c){if(!b.has(a))throw new TypeError("attempted to get private field on non-instance");return c}function _classPrivateFieldSet(a,b,c){var d=_classExtractFieldDescriptor(a,b,"set");return _classApplyDescriptorSet(a,d,c),c}function _classExtractFieldDescriptor(a,b,c){if(!b.has(a))throw new TypeError("attempted to "+c+" private field on non-instance");return b.get(a)}function _classApplyDescriptorSet(a,b,c){if(b.set)b.set.call(a,c);else{if(!b.writable)throw new TypeError("attempted to set read only private field");b.value=c}}var _started=/*#__PURE__*/new WeakMap,_connectionTimer=/*#__PURE__*/new WeakMap,_resetCountersTimer=/*#__PURE__*/new WeakMap,_reconnect=/*#__PURE__*/new WeakSet,_resetCounters=/*#__PURE__*/new WeakSet;class RetryConnection extends _connection_base.ConnectionBase{constructor(a){let b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{maxRetryCount:10,minRetryIntervalMs:500,maxRetryIntervalMs:32e3};super(a),_classPrivateMethodInitSpec(this,_resetCounters),_classPrivateMethodInitSpec(this,_reconnect),_classPrivateFieldInitSpec(this,_started,{writable:!0,value:void 0}),_classPrivateFieldInitSpec(this,_connectionTimer,{writable:!0,value:void 0}),_classPrivateFieldInitSpec(this,_resetCountersTimer,{writable:!0,value:void 0}),this.maxRetryCount=b.maxRetryCount||10,this.minRetryIntervalMs=b.minRetryIntervalMs||500,this.maxRetryIntervalMs=b.maxRetryIntervalMs||32e3,_classPrivateFieldSet(this,_connectionTimer,null),_classPrivateFieldSet(this,_resetCountersTimer,null),_classPrivateFieldSet(this,_started,!1),_classPrivateMethodGet(this,_resetCounters,_resetCounters2).call(this)}start(){this.isStarted()||(_index.logger.info("".concat(this.name,": starting...")),_classPrivateFieldSet(this,_started,!0),_classPrivateMethodGet(this,_resetCounters,_resetCounters2).call(this),_classPrivateMethodGet(this,_reconnect,_reconnect2).call(this),this.onStarted())}stop(){this.isStarted()&&(_index.logger.info("".concat(this.name,": stopping...")),_classPrivateFieldSet(this,_started,!1),this.disconnect(),this.onStopped())}isStarted(){return _classPrivateFieldGet(this,_started)}onDisconnected(){super.onDisconnected(),_classPrivateMethodGet(this,_reconnect,_reconnect2).call(this)}onStarted(){}onStopped(){}onError(a){super.onError(a),(a instanceof _exceptions.TooManyConnectionsError||a instanceof _exceptions.PermissionDeniedError||a instanceof _exceptions.SessionTimeoutError)&&this.stop()}disconnect(){clearTimeout(_classPrivateFieldGet(this,_connectionTimer)),clearTimeout(_classPrivateFieldGet(this,_resetCountersTimer)),super.disconnect()}}exports.RetryConnection=RetryConnection;function _reconnect2(){if(this.isStarted()){if(this.retryCount>this.maxRetryCount)return void this.stop();let a=Math.max(this.nexRetryTime-Date.now(),0);0<a&&(_index.logger.debug(this),_index.logger.info("".concat(this.name,": retrying connection in ").concat(this.retryIntervalMs,"ms]"))),clearTimeout(_classPrivateFieldGet(this,_resetCountersTimer)),this.retryIntervalMs=Math.min(2*this.retryIntervalMs,this.maxRetryIntervalMs),++this.retryCount,this.nexRetryTime=Date.now()+this.retryIntervalMs,_classPrivateFieldSet(this,_connectionTimer,setTimeout(()=>{this.connect().catch(a=>{this.onError(a)})},a)),_classPrivateFieldSet(this,_resetCountersTimer,setTimeout(()=>{_classPrivateMethodGet(this,_resetCounters,_resetCounters2).call(this)},6e4))}}function _resetCounters2(){this.retryCount=0,this.retryIntervalMs=this.minRetryIntervalMs,this.nexRetryTime=Date.now()}
|