@jibb-open/jssdk 3.5.21 → 3.6.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/meeting.js +1 -1
- package/package.json +1 -1
- package/types/jibb.pb.js +1 -1
- package/ws/eventbus.js +1 -1
- package/ws/ipsa.js +1 -1
package/api/meeting.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createMeeting=createMeeting,exports.createShare=createShare,exports.createTemporaryShare=createTemporaryShare,exports.deleteMeeting=deleteMeeting,exports.deleteMeetingImages=deleteMeetingImages,exports.deleteShare=deleteShare,exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createMeeting=createMeeting,exports.createShare=createShare,exports.createTemporaryShare=createTemporaryShare,exports.deleteMeeting=deleteMeeting,exports.deleteMeetingImages=deleteMeetingImages,exports.deleteShare=deleteShare,exports.endMeeting=endMeeting,exports.getIncomingShares=getIncomingShares,exports.getMeetingDetails=getMeetingDetails,exports.getMeetingImage=getMeetingImage,exports.getMeetingImages=getMeetingImages,exports.getMeetingList=getMeetingList,exports.getMeetingToken=getMeetingToken,exports.getMeetingTokenFromTempShareId=getMeetingTokenFromTempShareId,exports.getOutgoingShares=getOutgoingShares,exports.isMeetingOwner=isMeetingOwner,exports.startMeeting=startMeeting,exports.updateMeeting=updateMeeting,exports.updateShare=updateShare,require("core-js/modules/es.promise.js"),require("core-js/modules/es.json.stringify.js");var _config=require("../config.js"),_auth=require("./auth.js"),_index=require("../utils/logger/index.js"),_exceptions=require("../types/exceptions.js"),_index2=require("../utils/http/index.js"),_types=require("../types/types.js");async function createMeeting(a){let{title:b,isTemporary:c,capacity:d,meetingType:e}=a,f={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await _auth.Auth.getUserToken()},g={title:b||"",isTemporary:c||!1,capacity:d||2,meetingType:e||_types.MeetingTypes.DEFAULT},h=await _index2.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings"),g,f);return h.data.meetingId}async function createTemporaryShare(a){let{meetingId:b,permission:c,expiry:d,auxData:e}=a,f={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await _auth.Auth.getUserToken()},g=await _index2.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b,"/temp-shares"),{permission:c,expiry:{seconds:d||3600},auxilary:e||{}},f);return g.data.shareId}async function getMeetingTokenFromTempShareId(a){let{meetingId:b,shareId:c}=a,d=await _index2.http.get("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b,"/temp-shares/").concat(c),{"Content-Type":"application/json",Accept:"application/json"});return d.data.token}async function deleteMeetingImages(a){let{meetingId:b,mtoken:c}=a,d={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await _auth.Auth.getUserToken(),"x-jibb-meeting-jwt":c};return _index2.http.delete("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b,"/images"),d)}async function getMeetingImages(a){let{meetingId:b,meetingToken:c}=a,d={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await _auth.Auth.getUserToken(),"x-jibb-meeting-jwt":c},e=await _index2.http.get("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b,"/images"),d);return e.data}async function getMeetingImage(a){let{meetingId:b,meetingToken:c,imageId:d}=a,e={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await _auth.Auth.getUserToken(),"x-jibb-meeting-jwt":c},f=await _index2.http.get("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b,"/images/").concat(d),e);return f.data}async function startMeeting(a){let{meetingId:b,meetingToken:c}=a;try{return await _index2.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b,"/actions/start"),{},{"Content-Type":"application/json",Accept:"application/json","x-jibb-meeting-jwt":c})}catch(a){var d;if(404==(null===a||void 0===a||null===(d=a.response)||void 0===d?void 0:d.status))throw new _exceptions.NotFoundError;else throw a}}async function endMeeting(a){let{meetingId:b,meetingToken:c}=a;return _index2.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b,"/actions/end"),{},{"Content-Type":"application/json",Accept:"application/json","x-jibb-meeting-jwt":c})}async function deleteMeeting(a){let b={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await _auth.Auth.getUserToken()};return _index2.http.delete("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(a),b)}async function getMeetingToken(a){let b,{meetingId:c,permission:d,expiry:e=3600}=a;try{b=await _auth.Auth.getUserToken()}catch(a){throw _index.logger.error({err:a}),new _exceptions.PermissionDeniedError("user is not authenticated")}try{let a={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":b},f=await _index2.http.get("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(c,"/token/").concat(d,"?expiry.seconds=").concat(e),a);return f.data.token}catch(a){var f;if(404==(null===a||void 0===a||null===(f=a.response)||void 0===f?void 0:f.status))throw new _exceptions.NotFoundError("meeting not found");else throw a}}async function getMeetingList(a){let b={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await _auth.Auth.getUserToken()};void 0!==a&&(b["x-jibb-pagination"]=JSON.stringify(a));let c=await _index2.http.get("".concat(_config.Config.apiBaseURL,"/v1/meetings"),b);return a=c.headers["x-jibb-pagination"],a=a&&JSON.parse(a),{meetings:c.data.meetings,pagination:a}}async function getMeetingDetails(a){let b={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await _auth.Auth.getUserToken()},c=await _index2.http.get("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(a),b);return c.data}async function updateMeeting(a){let{meetingId:b,title:c,capacity:d}=a,e={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await _auth.Auth.getUserToken()},f={};return c&&(f.title=c),d&&(f.capacity=d),_index2.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b),f,e)}async function isMeetingOwner(a){try{let b=new _types.MeetingClaims(a),c=new _types.UserClaims(await _auth.Auth.getUserToken());return c.email===b.owner}catch(a){return!1}}async function createShare(a){let{email:b,meetingId:c,permission:d,meetingToken:e}=a,f={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await _auth.Auth.getUserToken(),"x-jibb-meeting-jwt":e},g=await _index2.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(c,"/shares"),{email:b,permission:d},f);return g.data}async function getIncomingShares(){let a={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await _auth.Auth.getUserToken()},b=await _index2.http.get("".concat(_config.Config.apiBaseURL,"/v1/meetings/shares?incoming=true"),a);return b.data.shares}async function getOutgoingShares(){let a={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await _auth.Auth.getUserToken()},b=await _index2.http.get("".concat(_config.Config.apiBaseURL,"/v1/meetings/shares?outgoing=true"),a);return b.data.shares}async function deleteShare(a){let b={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await _auth.Auth.getUserToken()};return _index2.http.delete("".concat(_config.Config.apiBaseURL,"/v1/meetings/shares/").concat(a),b)}async function updateShare(a){let{shareId:b,permission:c}=a,d={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await _auth.Auth.getUserToken()};return _index2.http.patch("".concat(_config.Config.apiBaseURL,"/v1/meetings/shares/").concat(b),{permission:c},d)}
|
package/package.json
CHANGED
package/types/jibb.pb.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var $protobuf=require("protobufjs/light"),$root=($protobuf.roots["default"]||($protobuf.roots["default"]=new $protobuf.Root)).addJSON({types:{options:{go_package:"github.com/Inkerz/jibbapis/sdk/go/types"},nested:{Code:{values:{SUCCESS:0,ERR_IO:4e3,ERR_CLOSED:4001,ERR_TIMEOUT:4002,ERR_BAD_REQUEST:4003,ERR_UNAUTHORIZED:4004,ERR_INTERNAL:4005,ERR_TOO_MANY_CONNECTIONS:4006,ERR_OUT_OF_LICENSE:4008}},ErrorLevel:{values:{DEBUG:0,INFO:1,WARNING:2,ERROR:3,CRITICAL:4}},Error:{fields:{level:{type:"ErrorLevel",id:1},code:{type:"Code",id:2},reason:{type:"string",id:3}}},TriState:{values:{DEFAULT:0,ENABLE:1,DISABLE:2}},SurfaceType:{values:{UNKNOWN:0,PAPER:1,WHITEBOARD:2}},ClientType:{options:{allow_alias:!0},values:{UNKNOWN_CLIENT_TYPE:0,ANY:0,IPSA:1,MOBILE:2,WEBAPP:3,COMPANION:4,ipsa:1,mobile:2,webapp:3,companion:4}},ClientDetails:{fields:{clientType:{type:"ClientType",id:1},id:{type:"string",id:2},name:{type:"string",id:3}}},ContentType:{values:{UNKNOWN_TYPE:0,IMAGE_JPEG:1,IMAGE_WEBP:2}}}},jibb:{nested:{ipsa:{nested:{v1:{options:{java_package:"ai.jibb.ipsa",java_outer_classname:"IPSA",go_package:"github.com/Inkerz/jibbapis/sdk/go/ipsa"},nested:{StatusCode:{values:{SUCCESS:0,INVALID_INPUT:3,SESSION_BUSY:6,SURFACE_DETECTED:110,SURFACE_NOT_DETECTED:100,SURFACE_NOT_STABILIZED:101,SURFACE_CHANGED:103,SURFACE_TOO_LEFT:104,SURFACE_TOO_RIGHT:105,SURFACE_TOO_CLOSE:106,SURFACE_TOO_FAR:109,SURFACE_TOO_DARK:107,SURFACE_TOO_BRIGHT:108,INTERNAL_ERROR:200}},Rotation:{values:{ROTATE_0:0,ROTATE_90_CLOCKWISE:1,ROTATE_180:2,ROTATE_90_COUNTERCLOCKWISE:3}},Config:{fields:{surfaceType:{type:"types.SurfaceType",id:1},enableStabilization:{type:"types.TriState",id:3},enableTransformation:{type:"types.TriState",id:4}}},VersionRequest:{fields:{}},VersionResponse:{fields:{version:{type:"string",id:1}}},SurfaceTransformationRequest:{fields:{surfaceType:{type:"types.SurfaceType",id:1},img:{type:"bytes",id:2}}},SurfaceTransformationResponse:{fields:{img:{type:"bytes",id:1}}},SurfaceSegmentationRequest:{fields:{surfaceType:{type:"types.SurfaceType",id:1},overlay:{type:"bool",id:2},img:{type:"bytes",id:3}}},SurfaceSegmentationResponse:{fields:{img:{type:"bytes",id:1}}},SurfaceDetectionRequest:{fields:{surfaceType:{type:"types.SurfaceType",id:1},img:{type:"bytes",id:2},overlay:{type:"bool",id:3}}},SurfaceDetectionResponse:{fields:{img:{type:"bytes",id:1},corners:{rule:"repeated",type:"sint32",id:2}}},ObjectRemovalRequest:{fields:{surfaceType:{type:"types.SurfaceType",id:1},overlay:{type:"bool",id:2},enableTransformation:{type:"bool",id:3},img:{type:"bytes",id:4}}},ObjectRemovalResponse:{fields:{img:{type:"bytes",id:1}}},ContentExtractionRequest:{fields:{surfaceType:{type:"types.SurfaceType",id:1},enableTransformation:{type:"bool",id:2},enableColor:{type:"bool",id:4},img:{type:"bytes",id:3}}},ContentExtractionResponse:{fields:{img:{type:"bytes",id:1},transformedImg:{type:"bytes",id:2}}},GetSimilarityRequest:{fields:{newImage:{type:"bytes",id:1},prevImage:{type:"bytes",id:2}}},GetSimilarityResponse:{fields:{similarity:{type:"double",id:1}}},Ipsa:{fields:{data:{type:"bytes",id:1}}},ResetSession:{fields:{}},Recalibrate:{fields:{}},RuntimeConfig:{fields:{customCorners:{rule:"repeated",type:"sint32",id:1},fixedCorners:{type:"bool",id:2},enableColor:{type:"bool",id:3},rotation:{type:"Rotation",id:4},flipUpDown:{type:"bool",id:5},flipLeftRight:{type:"bool",id:6},enableEstimation:{type:"bool",id:7}}},AppConfig:{fields:{title:{type:"string",id:1},enableResponseImage:{type:"bool",id:2},meetingId:{type:"string",id:3},meetingToken:{type:"string",id:4}}},Request:{oneofs:{Command:{oneof:["config","ipsa","resetSession","recalibrate","runtimeConfig","appConfig"]}},fields:{id:{type:"int32",id:1},config:{type:"Config",id:2},ipsa:{type:"Ipsa",id:3},resetSession:{type:"ResetSession",id:4},recalibrate:{type:"Recalibrate",id:5},runtimeConfig:{type:"RuntimeConfig",id:6},appConfig:{type:"AppConfig",id:7}}},Status:{fields:{corners:{rule:"repeated",type:"float",id:1},codes:{rule:"repeated",type:"StatusCode",id:2},processingTime:{type:"int32",id:3},upsampling:{type:"float",id:4},paperDetectionConfidence:{type:"int32",id:5}}},Response:{fields:{id:{type:"int32",id:1},image:{type:"bytes",id:5},status:{type:"Status",id:8}}}}}}}}},user:{options:{go_package:"github.com/Inkerz/jibbapis/sdk/go/user"},nested:{Level:{values:{FREE:0,BASIC:1,STUDENT:2,PRO:3,BUSINESS:4,ENTERPRISE:5,EDUCATION:6}},UserType:{values:{UNKNOWN:0,LIMITED:1,MEMBER:2,ADMIN:3,OWNER:4}},UserDetails:{fields:{organizationName:{type:"string",id:2},level:{type:"Level",id:3},firstName:{type:"string",id:4},lastName:{type:"string",id:5},organizationId:{type:"int32",id:6},userType:{type:"UserType",id:7},activated:{type:"bool",id:8},userId:{type:"int32",id:9},email:{type:"string",id:10}}},UserList:{fields:{users:{rule:"repeated",type:"UserDetails",id:1}}},CreateOrganizationUserRequest:{fields:{organizationId:{type:"int32",id:1},users:{rule:"repeated",type:"User",id:2}},nested:{User:{fields:{email:{type:"string",id:2},firstName:{type:"string",id:3},lastName:{type:"string",id:4},userType:{type:"UserType",id:5}}}}},CreateOrganizationUserResponse:{fields:{failedUsers:{rule:"repeated",type:"string",id:1}}},DeleteOrganizationUserRequest:{fields:{organizationId:{type:"int32",id:1},userId:{type:"int32",id:2}}},ChangeOrganizationUserTypeRequest:{fields:{organizationId:{type:"int32",id:1},userId:{type:"int32",id:2},userType:{type:"UserType",id:3}}},GetOrganizationUsersListRequest:{fields:{organizationId:{type:"int32",id:1}}},GetOrganizationUserRequest:{fields:{organizationId:{type:"int32",id:1},userId:{type:"int32",id:2}}},CreateOrganizationRequest:{fields:{name:{type:"string",id:1},ownerEmail:{type:"string",id:2},level:{type:"Level",id:3},licenseCount:{type:"int32",id:4},expiryDate:{type:"google.protobuf.Timestamp",id:5},subdomainName:{type:"string",id:6}}},DeleteOrganizationRequest:{fields:{organizationId:{type:"int32",id:1}}},DeleteSAMLRequest:{fields:{organizationId:{type:"int32",id:1}}},GetSAMLRequest:{fields:{organizationId:{type:"int32",id:1}}},GetOrganizationSettingsRequest:{fields:{organizationId:{type:"int32",id:1}}},SAMLDetails:{fields:{organizationId:{type:"int32",id:1},metadata:{type:"string",id:3},autoAddUsers:{type:"bool",id:4},defaultUserType:{type:"UserType",id:5},enabled:{type:"bool",id:6}}},GetOrganizationRequest:{fields:{organizationId:{type:"int32",id:1}}},OrganizationDetails:{fields:{name:{type:"string",id:1},ownerEmail:{type:"string",id:2},level:{type:"Level",id:3},licenseCount:{type:"int32",id:4},usersCount:{type:"int32",id:5},creationDate:{type:"google.protobuf.Timestamp",id:6},expiryDate:{type:"google.protobuf.Timestamp",id:7},organizationId:{type:"int32",id:8},subdomainName:{type:"string",id:9}}},OrganizationList:{fields:{organizations:{rule:"repeated",type:"OrganizationDetails",id:1}}},UserClaims:{fields:{level:{type:"Level",id:2},organizationIds:{rule:"repeated",type:"int32",id:3},email:{type:"string",id:4}}},GetUserTokenRequest:{fields:{expiry:{type:"google.protobuf.Duration",id:1},apiKey:{type:"string",id:2}}},GetUserTokenResponse:{fields:{token:{type:"string",id:1}}},GenerateAPIKeyResponse:{fields:{apiKey:{type:"string",id:1}}},GenerateCustomAuthResponse:{fields:{password:{type:"string",id:1}}},VerifyCustomAuthRequest:{fields:{username:{type:"string",id:1},password:{type:"string",id:2}}},VerifyCustomAuthResponse:{fields:{verified:{type:"bool",id:1}}},GetOrganizationIdRequest:{fields:{organizationName:{type:"string",id:1},subdomainName:{type:"string",id:2},domainName:{type:"string",id:3},userEmail:{type:"string",id:4}}},GetOrganizationIdResponse:{fields:{organizationId:{type:"int32",id:1}}},CreateDomainRequest:{fields:{organizationId:{type:"int32",id:1},domainName:{type:"string",id:2}}},DeleteDomainRequest:{fields:{organizationId:{type:"int32",id:1},domainId:{type:"int32",id:2}}},VerifyDomainRequest:{fields:{organizationId:{type:"int32",id:1},domainId:{type:"int32",id:2}}},GetDomainListRequest:{fields:{organizationId:{type:"int32",id:1}}},GetDomainListResponse:{fields:{domains:{rule:"repeated",type:"DomainDetails",id:1}}},GetDomainRequest:{fields:{organizationId:{type:"int32",id:1},domainId:{type:"int32",id:2}}},DomainDetails:{fields:{organizationId:{type:"int32",id:1},domainId:{type:"int32",id:2},domainName:{type:"string",id:3},verificationCode:{type:"string",id:4},verified:{type:"bool",id:5}}},ActivateUserRequest:{fields:{organizationId:{type:"int32",id:1}}},SendUserActivationEmailRequest:{fields:{organizationId:{type:"int32",id:1},userIds:{rule:"repeated",type:"int32",id:2}}},GetUserIdRequest:{fields:{email:{type:"string",id:1},createIfNotExists:{type:"bool",id:2}}},GetUserIdResponse:{fields:{userId:{type:"int32",id:1}}}}},meeting:{options:{go_package:"github.com/Inkerz/jibbapis/sdk/go/meeting"},nested:{Participant:{fields:{id:{type:"int32",id:1},userId:{type:"int32",id:2},email:{type:"string",id:3}}},Update:{fields:{id:{type:"int32",id:1},userId:{type:"int32",id:2},email:{type:"string",id:3},title:{type:"string",id:4},image:{type:"bytes",id:5}}},Drawing:{fields:{id:{type:"int32",id:1},userId:{type:"int32",id:2},email:{type:"string",id:3},data:{type:"string",id:4}}},Pointer:{fields:{id:{type:"int32",id:1},userId:{type:"int32",id:2},email:{type:"string",id:3},x:{type:"int32",id:4},y:{type:"int32",id:5}}},Message:{oneofs:{event:{oneof:["join","leave","update","drawing","pointer"]}},fields:{join:{type:"Participant",id:1},leave:{type:"Participant",id:2},update:{type:"Update",id:3},drawing:{type:"Drawing",id:6},pointer:{type:"Pointer",id:7}}}}},cilix:{options:{go_package:"github.com/Inkerz/jibbapis/sdk/go/cilix"},nested:{CameraDescription:{fields:{id:{type:"string",id:1},name:{type:"string",id:2}}},StartRequest:{fields:{config:{type:"jibb.ipsa.v1.Config",id:2},appConfig:{type:"jibb.ipsa.v1.AppConfig",id:3},runtimeConfig:{type:"jibb.ipsa.v1.RuntimeConfig",id:4},camera:{type:"CameraDescription",id:5}}},PreviewRequest:{fields:{source:{type:"CameraDescription",id:2}}},PreviewResponse:{fields:{image:{type:"bytes",id:1}}},GetCameraListResponse:{fields:{items:{rule:"repeated",type:"CameraDescription",id:1}}},GetClientStatusListResponse:{fields:{clients:{rule:"repeated",type:"types.ClientDetails",id:1}}},BusMessage:{oneofs:{messageType:{oneof:["clientConnected","clientDisconnected","tooManyPublishers","ipsaResponse","startRequest","stopRequest","newPageRequest","previewRequest","previewResponse","cameraListRequest","cameraListResponse","runtimeConfigRequest","clientStatusRequest","recordingStarted","recordingStopped","error"]}},fields:{clientConnected:{type:"google.protobuf.Empty",id:2},clientDisconnected:{type:"google.protobuf.Empty",id:3},tooManyPublishers:{type:"google.protobuf.Empty",id:4},ipsaResponse:{type:"jibb.ipsa.v1.Response",id:6},startRequest:{type:"StartRequest",id:50},stopRequest:{type:"google.protobuf.Empty",id:51},newPageRequest:{type:"google.protobuf.Empty",id:52},previewRequest:{type:"PreviewRequest",id:53},previewResponse:{type:"PreviewResponse",id:54},cameraListRequest:{type:"google.protobuf.Empty",id:55},cameraListResponse:{type:"GetCameraListResponse",id:56},runtimeConfigRequest:{type:"jibb.ipsa.v1.RuntimeConfig",id:57},clientStatusRequest:{type:"google.protobuf.Empty",id:58},recordingStarted:{type:"google.protobuf.Empty",id:59},recordingStopped:{type:"google.protobuf.Empty",id:60},error:{type:"types.Code",id:100},src:{type:"types.ClientDetails",id:30},dst:{type:"types.ClientDetails",id:31}}}}},google:{nested:{protobuf:{nested:{Duration:{fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}},Timestamp:{fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}},Empty:{fields:{}}}}}}});module.exports=$root;
|
|
1
|
+
"use strict";var $protobuf=require("protobufjs/light"),$root=($protobuf.roots["default"]||($protobuf.roots["default"]=new $protobuf.Root)).addJSON({types:{options:{go_package:"github.com/Inkerz/jibbapis/sdk/go/types"},nested:{Code:{values:{SUCCESS:0,ERR_IO:4e3,ERR_CLOSED:4001,ERR_TIMEOUT:4002,ERR_BAD_REQUEST:4003,ERR_UNAUTHORIZED:4004,ERR_INTERNAL:4005,ERR_TOO_MANY_CONNECTIONS:4006,ERR_OUT_OF_LICENSE:4008}},ErrorLevel:{values:{DEBUG:0,INFO:1,WARNING:2,ERROR:3,CRITICAL:4}},Error:{fields:{level:{type:"ErrorLevel",id:1},code:{type:"Code",id:2},reason:{type:"string",id:3}}},TriState:{values:{DEFAULT:0,ENABLE:1,DISABLE:2}},SurfaceType:{values:{UNKNOWN:0,PAPER:1,WHITEBOARD:2}},ClientType:{options:{allow_alias:!0},values:{UNKNOWN_CLIENT_TYPE:0,ANY:0,IPSA:1,MOBILE:2,WEBAPP:3,COMPANION:4,ipsa:1,mobile:2,webapp:3,companion:4}},ClientDetails:{fields:{clientType:{type:"ClientType",id:1},id:{type:"string",id:2},name:{type:"string",id:3}}},ContentType:{values:{UNKNOWN_TYPE:0,IMAGE_JPEG:1,IMAGE_WEBP:2}}}},jibb:{nested:{ipsa:{nested:{v1:{options:{java_package:"ai.jibb.ipsa",java_outer_classname:"IPSA",go_package:"github.com/Inkerz/jibbapis/sdk/go/ipsa"},nested:{StatusCode:{values:{SUCCESS:0,INVALID_INPUT:3,SESSION_BUSY:6,SURFACE_DETECTED:110,SURFACE_NOT_DETECTED:100,SURFACE_NOT_STABILIZED:101,SURFACE_CHANGED:103,SURFACE_TOO_LEFT:104,SURFACE_TOO_RIGHT:105,SURFACE_TOO_CLOSE:106,SURFACE_TOO_FAR:109,SURFACE_TOO_DARK:107,SURFACE_TOO_BRIGHT:108,INTERNAL_ERROR:200}},Rotation:{values:{ROTATE_0:0,ROTATE_90_CLOCKWISE:1,ROTATE_180:2,ROTATE_90_COUNTERCLOCKWISE:3}},Config:{fields:{surfaceType:{type:"types.SurfaceType",id:1},enableStabilization:{type:"types.TriState",id:3},enableTransformation:{type:"types.TriState",id:4},userId:{type:"int32",id:5},meetingToken:{type:"string",id:6},mbusTopicStatus:{type:"string",id:7},mbusTopicImage:{type:"string",id:8}}},RuntimeConfig:{fields:{customCorners:{rule:"repeated",type:"sint32",id:1},fixedCorners:{type:"bool",id:2},enableColor:{type:"bool",id:3},rotation:{type:"Rotation",id:4},flipUpDown:{type:"bool",id:5},flipLeftRight:{type:"bool",id:6},enableEstimation:{type:"bool",id:7}}},VersionResponse:{fields:{version:{type:"string",id:1}}},SurfaceTransformationRequest:{fields:{surfaceType:{type:"types.SurfaceType",id:1},img:{type:"bytes",id:2}}},SurfaceTransformationResponse:{fields:{img:{type:"bytes",id:1}}},SurfaceSegmentationRequest:{fields:{surfaceType:{type:"types.SurfaceType",id:1},overlay:{type:"bool",id:2},img:{type:"bytes",id:3}}},SurfaceSegmentationResponse:{fields:{img:{type:"bytes",id:1}}},SurfaceDetectionRequest:{fields:{surfaceType:{type:"types.SurfaceType",id:1},img:{type:"bytes",id:2},overlay:{type:"bool",id:3}}},SurfaceDetectionResponse:{fields:{img:{type:"bytes",id:1},corners:{rule:"repeated",type:"sint32",id:2}}},ObjectRemovalRequest:{fields:{surfaceType:{type:"types.SurfaceType",id:1},overlay:{type:"bool",id:2},enableTransformation:{type:"bool",id:3},img:{type:"bytes",id:4}}},ObjectRemovalResponse:{fields:{img:{type:"bytes",id:1}}},ContentExtractionRequest:{fields:{surfaceType:{type:"types.SurfaceType",id:1},enableTransformation:{type:"bool",id:2},enableColor:{type:"bool",id:4},img:{type:"bytes",id:3}}},ContentExtractionResponse:{fields:{img:{type:"bytes",id:1},transformedImg:{type:"bytes",id:2}}},GetSimilarityRequest:{fields:{newImage:{type:"bytes",id:1},prevImage:{type:"bytes",id:2}}},GetSimilarityResponse:{fields:{similarity:{type:"double",id:1}}},Ipsa:{fields:{data:{type:"bytes",id:1}}},Request:{oneofs:{Command:{oneof:["config","ipsa","resetSession","recalibrate","runtimeConfig"]}},fields:{id:{type:"int32",id:1},config:{type:"Config",id:2},ipsa:{type:"Ipsa",id:3},resetSession:{type:"google.protobuf.Empty",id:4},recalibrate:{type:"google.protobuf.Empty",id:5},runtimeConfig:{type:"RuntimeConfig",id:6}}},Status:{fields:{userId:{type:"int32",id:1},corners:{rule:"repeated",type:"float",id:2},codes:{rule:"repeated",type:"StatusCode",id:3},processingTime:{type:"int32",id:4},upsampling:{type:"float",id:5},paperDetectionConfidence:{type:"int32",id:6}}},Image:{fields:{userId:{type:"int32",id:1},data:{type:"bytes",id:2}}},Response:{fields:{id:{type:"int32",id:1},image:{type:"bytes",id:5},status:{type:"Status",id:8}}}}}}}}},user:{options:{go_package:"github.com/Inkerz/jibbapis/sdk/go/user"},nested:{Level:{values:{FREE:0,BASIC:1,STUDENT:2,PRO:3,BUSINESS:4,ENTERPRISE:5,EDUCATION:6}},UserType:{values:{UNKNOWN:0,LIMITED:1,MEMBER:2,ADMIN:3,OWNER:4}},UserDetails:{fields:{organizationName:{type:"string",id:2},level:{type:"Level",id:3},firstName:{type:"string",id:4},lastName:{type:"string",id:5},organizationId:{type:"int32",id:6},userType:{type:"UserType",id:7},activated:{type:"bool",id:8},userId:{type:"int32",id:9},email:{type:"string",id:10}}},UserList:{fields:{users:{rule:"repeated",type:"UserDetails",id:1}}},CreateOrganizationUserRequest:{fields:{organizationId:{type:"int32",id:1},users:{rule:"repeated",type:"User",id:2}},nested:{User:{fields:{email:{type:"string",id:2},firstName:{type:"string",id:3},lastName:{type:"string",id:4},userType:{type:"UserType",id:5}}}}},CreateOrganizationUserResponse:{fields:{failedUsers:{rule:"repeated",type:"string",id:1}}},DeleteOrganizationUserRequest:{fields:{organizationId:{type:"int32",id:1},userId:{type:"int32",id:2}}},ChangeOrganizationUserTypeRequest:{fields:{organizationId:{type:"int32",id:1},userId:{type:"int32",id:2},userType:{type:"UserType",id:3}}},GetOrganizationUsersListRequest:{fields:{organizationId:{type:"int32",id:1}}},GetOrganizationUserRequest:{fields:{organizationId:{type:"int32",id:1},userId:{type:"int32",id:2}}},CreateOrganizationRequest:{fields:{name:{type:"string",id:1},ownerEmail:{type:"string",id:2},level:{type:"Level",id:3},licenseCount:{type:"int32",id:4},expiryDate:{type:"google.protobuf.Timestamp",id:5},subdomainName:{type:"string",id:6}}},DeleteOrganizationRequest:{fields:{organizationId:{type:"int32",id:1}}},DeleteSAMLRequest:{fields:{organizationId:{type:"int32",id:1}}},GetSAMLRequest:{fields:{organizationId:{type:"int32",id:1}}},GetOrganizationSettingsRequest:{fields:{organizationId:{type:"int32",id:1}}},SAMLDetails:{fields:{organizationId:{type:"int32",id:1},metadata:{type:"string",id:3},autoAddUsers:{type:"bool",id:4},defaultUserType:{type:"UserType",id:5},enabled:{type:"bool",id:6}}},GetOrganizationRequest:{fields:{organizationId:{type:"int32",id:1}}},OrganizationDetails:{fields:{name:{type:"string",id:1},ownerEmail:{type:"string",id:2},level:{type:"Level",id:3},licenseCount:{type:"int32",id:4},usersCount:{type:"int32",id:5},creationDate:{type:"google.protobuf.Timestamp",id:6},expiryDate:{type:"google.protobuf.Timestamp",id:7},organizationId:{type:"int32",id:8},subdomainName:{type:"string",id:9}}},OrganizationList:{fields:{organizations:{rule:"repeated",type:"OrganizationDetails",id:1}}},UserClaims:{fields:{level:{type:"Level",id:2},organizationIds:{rule:"repeated",type:"int32",id:3},email:{type:"string",id:4}}},GetUserTokenRequest:{fields:{expiry:{type:"google.protobuf.Duration",id:1},apiKey:{type:"string",id:2}}},GetUserTokenResponse:{fields:{token:{type:"string",id:1}}},GenerateAPIKeyResponse:{fields:{apiKey:{type:"string",id:1}}},GenerateCustomAuthResponse:{fields:{password:{type:"string",id:1}}},VerifyCustomAuthRequest:{fields:{username:{type:"string",id:1},password:{type:"string",id:2}}},VerifyCustomAuthResponse:{fields:{verified:{type:"bool",id:1}}},GetOrganizationIdRequest:{fields:{organizationName:{type:"string",id:1},subdomainName:{type:"string",id:2},domainName:{type:"string",id:3},userEmail:{type:"string",id:4}}},GetOrganizationIdResponse:{fields:{organizationId:{type:"int32",id:1}}},CreateDomainRequest:{fields:{organizationId:{type:"int32",id:1},domainName:{type:"string",id:2}}},DeleteDomainRequest:{fields:{organizationId:{type:"int32",id:1},domainId:{type:"int32",id:2}}},VerifyDomainRequest:{fields:{organizationId:{type:"int32",id:1},domainId:{type:"int32",id:2}}},GetDomainListRequest:{fields:{organizationId:{type:"int32",id:1}}},GetDomainListResponse:{fields:{domains:{rule:"repeated",type:"DomainDetails",id:1}}},GetDomainRequest:{fields:{organizationId:{type:"int32",id:1},domainId:{type:"int32",id:2}}},DomainDetails:{fields:{organizationId:{type:"int32",id:1},domainId:{type:"int32",id:2},domainName:{type:"string",id:3},verificationCode:{type:"string",id:4},verified:{type:"bool",id:5}}},ActivateUserRequest:{fields:{organizationId:{type:"int32",id:1}}},SendUserActivationEmailRequest:{fields:{organizationId:{type:"int32",id:1},userIds:{rule:"repeated",type:"int32",id:2}}},GetUserIdRequest:{fields:{email:{type:"string",id:1},createIfNotExists:{type:"bool",id:2}}},GetUserIdResponse:{fields:{userId:{type:"int32",id:1}}},GetUserDetailsRequest:{fields:{userId:{type:"int32",id:1}}}}},google:{nested:{protobuf:{nested:{Empty:{fields:{}},Duration:{fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}},Timestamp:{fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}}}}},meeting:{options:{go_package:"github.com/Inkerz/jibbapis/sdk/go/meeting"},nested:{Participant:{fields:{id:{type:"int32",id:1},userId:{type:"int32",id:2},email:{type:"string",id:3}}},Update:{fields:{id:{type:"int32",id:1},userId:{type:"int32",id:2},email:{type:"string",id:3},title:{type:"string",id:4},image:{type:"bytes",id:5}}},Drawing:{fields:{id:{type:"int32",id:1},userId:{type:"int32",id:2},email:{type:"string",id:3},data:{type:"string",id:4}}},Pointer:{fields:{id:{type:"int32",id:1},userId:{type:"int32",id:2},email:{type:"string",id:3},x:{type:"int32",id:4},y:{type:"int32",id:5}}},Message:{oneofs:{event:{oneof:["join","leave","update","drawing","pointer"]}},fields:{join:{type:"Participant",id:1},leave:{type:"Participant",id:2},update:{type:"Update",id:3},drawing:{type:"Drawing",id:6},pointer:{type:"Pointer",id:7}}}}},cilix:{options:{go_package:"github.com/Inkerz/jibbapis/sdk/go/cilix"},nested:{CameraDescription:{fields:{id:{type:"string",id:1},name:{type:"string",id:2}}},StartRequest:{fields:{config:{type:"jibb.ipsa.v1.Config",id:2},runtimeConfig:{type:"jibb.ipsa.v1.RuntimeConfig",id:4},camera:{type:"CameraDescription",id:5}}},PreviewRequest:{fields:{source:{type:"CameraDescription",id:2}}},PreviewResponse:{fields:{image:{type:"bytes",id:1}}},GetCameraListResponse:{fields:{items:{rule:"repeated",type:"CameraDescription",id:1}}},GetClientStatusListResponse:{fields:{clients:{rule:"repeated",type:"types.ClientDetails",id:1}}},BusMessage:{oneofs:{messageType:{oneof:["clientConnected","clientDisconnected","tooManyPublishers","ipsaResponse","startRequest","stopRequest","newPageRequest","previewRequest","previewResponse","cameraListRequest","cameraListResponse","runtimeConfigRequest","clientStatusRequest","recordingStarted","recordingStopped","error"]}},fields:{clientConnected:{type:"google.protobuf.Empty",id:2},clientDisconnected:{type:"google.protobuf.Empty",id:3},tooManyPublishers:{type:"google.protobuf.Empty",id:4},ipsaResponse:{type:"jibb.ipsa.v1.Response",id:6},startRequest:{type:"StartRequest",id:50},stopRequest:{type:"google.protobuf.Empty",id:51},newPageRequest:{type:"google.protobuf.Empty",id:52},previewRequest:{type:"PreviewRequest",id:53},previewResponse:{type:"PreviewResponse",id:54},cameraListRequest:{type:"google.protobuf.Empty",id:55},cameraListResponse:{type:"GetCameraListResponse",id:56},runtimeConfigRequest:{type:"jibb.ipsa.v1.RuntimeConfig",id:57},clientStatusRequest:{type:"google.protobuf.Empty",id:58},recordingStarted:{type:"google.protobuf.Empty",id:59},recordingStopped:{type:"google.protobuf.Empty",id:60},error:{type:"types.Code",id:100},src:{type:"types.ClientDetails",id:30},dst:{type:"types.ClientDetails",id:31}}}}}});module.exports=$root;
|
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 _auth.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{appConfig:b,config:c,runtimeConfig:d,camera:f,sipUri:g,clientId:h}=a;return this.writeObject({startRequest:{config:c,appConfig:b,runtimeConfig:d,camera:f,sipUri:g},dst:{id:h}})}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&&d.sipUri||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/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 _auth.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,sipUri:f,clientId:g}=a;return this.writeObject({startRequest:{config:b,runtimeConfig:c,camera:d,sipUri:f},dst:{id:g}})}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&&d.sipUri||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);
|
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.reduce.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"),_retry_connection=require("./retry_connection.js"),_connection_base=require("./connection_base.js"),_types=require("../types/types.js"),_proto=require("../types/proto.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}}const ErrorCode=_proto.types.Code;var _expiryTimer=/*#__PURE__*/new WeakMap,_clear=/*#__PURE__*/new WeakSet,_write=/*#__PURE__*/new WeakSet,_handleMessage=/*#__PURE__*/new WeakSet,_onResponse=/*#__PURE__*/new WeakSet,_writeInputImage=/*#__PURE__*/new WeakSet,_setConfig=/*#__PURE__*/new WeakSet;class IPSAClass extends _retry_connection.RetryConnection{constructor(){super("ipsa"),_classPrivateMethodInitSpec(this,_setConfig),_classPrivateMethodInitSpec(this,_writeInputImage),_classPrivateMethodInitSpec(this,_onResponse),_classPrivateMethodInitSpec(this,_handleMessage),_classPrivateMethodInitSpec(this,_write),_classPrivateMethodInitSpec(this,_clear),_classPrivateFieldInitSpec(this,_expiryTimer,{writable:!0,value:void 0}),this.socket=null,this.onInputImage=null,this.onError=null,this.onResponse=null,this.userToken=null,_classPrivateFieldSet(this,_expiryTimer,null),_classPrivateMethodGet(this,_clear,_clear2).call(this)}start(a){let{userToken:b,request:c,onInputImage:d,onError:e,onResponse:f}=a;if(!this.isStarted()){this.setRuntimeConfig(c.runtimeConfig),
|
|
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.reduce.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"),_retry_connection=require("./retry_connection.js"),_connection_base=require("./connection_base.js"),_types=require("../types/types.js"),_proto=require("../types/proto.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}}const ErrorCode=_proto.types.Code;var _expiryTimer=/*#__PURE__*/new WeakMap,_clear=/*#__PURE__*/new WeakSet,_write=/*#__PURE__*/new WeakSet,_handleMessage=/*#__PURE__*/new WeakSet,_onResponse=/*#__PURE__*/new WeakSet,_writeInputImage=/*#__PURE__*/new WeakSet,_setConfig=/*#__PURE__*/new WeakSet;class IPSAClass extends _retry_connection.RetryConnection{constructor(){super("ipsa"),_classPrivateMethodInitSpec(this,_setConfig),_classPrivateMethodInitSpec(this,_writeInputImage),_classPrivateMethodInitSpec(this,_onResponse),_classPrivateMethodInitSpec(this,_handleMessage),_classPrivateMethodInitSpec(this,_write),_classPrivateMethodInitSpec(this,_clear),_classPrivateFieldInitSpec(this,_expiryTimer,{writable:!0,value:void 0}),this.socket=null,this.onInputImage=null,this.onError=null,this.onResponse=null,this.userToken=null,_classPrivateFieldSet(this,_expiryTimer,null),_classPrivateMethodGet(this,_clear,_clear2).call(this)}start(a){let{userToken:b,request:c,onInputImage:d,onError:e,onResponse:f}=a;if(!this.isStarted()){this.setRuntimeConfig(c.runtimeConfig),_classPrivateMethodGet(this,_setConfig,_setConfig2).call(this,c.config),this.onInputImage=d,this.onError=e,this.onResponse=f,this.userToken=b;let a=new _types.MeetingClaims(this.request.config.meetingToken),g=new _types.UserClaims(this.userToken),h=Math.min(g.getSecondsUntilExpiry(),a.getSecondsUntilExpiry());if(0>=h)return void this.onErrorMessage(ErrorCode.ERR_TIMEOUT,"token expired");_classPrivateFieldSet(this,_expiryTimer,setTimeout(()=>{this.stop(),this.onErrorMessage(ErrorCode.ERR_TIMEOUT,"token expired")},h))}super.start()}stop(){clearTimeout(_classPrivateFieldGet(this,_expiryTimer)),_classPrivateMethodGet(this,_clear,_clear2).call(this),super.stop()}disconnect(){super.disconnect(),null!=this.socket&&(this.socket.close(),this.socket=null)}async connect(){if(this.getConnectionStatus()!=_connection_base.ConnectionStatus.DISCONNECTED)return;super.connect();let a=this.configRequest.config.meetingToken;try{let a=new _types.UserClaims(this.userToken);if(a.isExpired())return void this.onErrorMessage(ErrorCode.ERR_TIMEOUT,"token expired")}catch(a){return void this.onErrorMessage(ErrorCode.ERR_UNAUTHORIZED,"unauthorized")}_index.logger.info("Connecting IPSA to meeting ".concat(meetingId,"..."));let b=new URL(_config.Config.apiBaseURL),c="wss://".concat(b.hostname,"/ws/ipsa/").concat(meetingId,"?user_token=").concat(this.userToken,"&meeting_token=").concat(a);this.socket=new WebSocket(c),this.socket.binaryType="arraybuffer",this.socket.addEventListener("open",async()=>{try{await _classPrivateMethodGet(this,_write,_write2).call(this,this.configRequest),await _classPrivateMethodGet(this,_write,_write2).call(this,this.runtimeConfigRequest),this.onConnected()}catch(a){return this.onWarningMessage(ErrorCode.ERR_IO,a),void this.disconnect()}let a=()=>{this.isConnected()&&this.isStarted()&&(0<this.socket.bufferedAmount?(_index.logger.warn("ipsa: low internet speed connection"),setTimeout(a,100)):(setTimeout(a,500),_classPrivateMethodGet(this,_writeInputImage,_writeInputImage2).call(this).catch(a=>_index.logger.error(a))))};a()}),this.socket.addEventListener("close",()=>{this.onDisconnected()}),this.socket.addEventListener("message",a=>{_classPrivateMethodGet(this,_handleMessage,_handleMessage2).call(this,a.data)}),this.socket.addEventListener("error",a=>{this.onWarningMessage(ErrorCode.ERR_IO,a)})}getAverageResponseTime(){let a=NaN;try{let b=Array.from(this.stats.values()).map(a=>a.responseTime-a.requestTime).filter(a=>!isNaN(a)),c=b.reduce((c,a)=>c+a);a=c/b.length}catch(a){}return a}setRuntimeConfig(a){let b=_proto.ipsa.Request.create({runtimeConfig:a});this.runtimeConfigRequest=b,this.isConnected()&&_classPrivateMethodGet(this,_write,_write2).call(this,b)}}function _clear2(){this.configRequest=null,this.runtimeConfigRequest=null,this.stats=new Map,this.requestId=0}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();this.socket.send(b)}}async function _handleMessage2(a){var b,c,d,e;try{if(a instanceof ArrayBuffer){let b=new Uint8Array(a),c=_proto.ipsa.Response.decode(b);return void _classPrivateMethodGet(this,_onResponse,_onResponse2).call(this,c)}}catch(a){_index.logger.error(a)}try{switch(a=JSON.parse(a),a.code){case ErrorCode.ERR_TOO_MANY_CONNECTIONS:case ErrorCode.ERR_UNAUTHORIZED:case ErrorCode.ERR_BAD_REQUEST:this.onErrorMessage(null===(b=a)||void 0===b?void 0:b.code,null===(c=a)||void 0===c?void 0:c.reason),this.stop();break;default:this.onInfoMessage(null===(d=a)||void 0===d?void 0:d.code,null===(e=a)||void 0===e?void 0:e.reason);}}catch(a){this.onWarningMessage(ErrorCode.ERR_IO,a)}}function _onResponse2(a){if(100<=a.id){let b=a.id-100,c=this.stats.get(b)||{};c.responseTime=performance.now(),this.stats.set(b,c)}this.onResponse&&this.onResponse(a)}async function _writeInputImage2(){let a=await this.onInputImage();this.requestId=(this.requestId+1)%8,this.stats.set(this.requestId,{requestTime:performance.now()});let b=_proto.ipsa.Request.create({id:this.requestId+100,ipsa:{data:a}});_classPrivateMethodGet(this,_write,_write2).call(this,b)}function _setConfig2(a){let b=_proto.ipsa.Request.create({config:a});this.configRequest=b,this.isConnected()&&_classPrivateMethodGet(this,_write,_write2).call(this,b)}let IPSA=new IPSAClass;exports.IPSA=IPSA;
|