sip-connector 6.23.0 → 6.24.1
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/dist/{SipConnector-m1cOb6M0.js → SipConnector-1HoiCnsj.js} +1 -1
- package/dist/{SipConnector-Q7QLgdlo.cjs → SipConnector-eRr2JbY9.cjs} +1 -1
- package/dist/__fixtures__/BaseSession.mock.d.ts +4 -4
- package/dist/__fixtures__/UA.mock.d.ts +2 -2
- package/dist/__fixtures__/index.d.ts +3 -2
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +102 -98
- package/dist/index.cjs +1 -1
- package/dist/index.js +64 -65
- package/dist/tools/__fixtures__/connectToServer.d.ts +4 -3
- package/dist/tools/__fixtures__/hasValidUri.d.ts +2 -8
- package/dist/tools/__fixtures__/processRequest.d.ts +1 -1
- package/dist/tools/connectToServer.d.ts +5 -1
- package/dist/tools/disconnectFromServer.d.ts +5 -1
- package/package.json +12 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Rt=Object.defineProperty;var It=(r,e,t)=>e in r?Rt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var i=(r,e,t)=>(It(r,typeof e!="symbol"?e+"":e,t),t);const S=require("@krivega/cancelable-promise"),Pe=require("events-constructor"),B=require("debug"),mt="Connection Error",He="Request Timeout",ft="SIP Failure Code",Ot="Internal Error",Dt="Busy",V="Rejected",Mt="Redirected",Pt="Unavailable",qe="Not Found",pt="Address Incomplete",vt="Incompatible SDP",bt="Missing SDP",wt="Authentication Error",ke="Terminated",yt="WebRTC Error",We="Canceled",Ut="No Answer",Lt="Expires",Ht="No ACK",qt="Dialog Error",kt="User Denied Media Access",Fe="Bad Media Description",Wt="RTP Timeout",Ft=Object.freeze(Object.defineProperty({__proto__:null,ADDRESS_INCOMPLETE:pt,AUTHENTICATION_ERROR:wt,BAD_MEDIA_DESCRIPTION:Fe,BUSY:Dt,BYE:ke,CANCELED:We,CONNECTION_ERROR:mt,DIALOG_ERROR:qt,EXPIRES:Lt,INCOMPATIBLE_SDP:vt,INTERNAL_ERROR:Ot,MISSING_SDP:bt,NOT_FOUND:qe,NO_ACK:Ht,NO_ANSWER:Ut,REDIRECTED:Mt,REJECTED:V,REQUEST_TIMEOUT:He,RTP_TIMEOUT:Wt,SIP_FAILURE_CODE:ft,UNAVAILABLE:Pt,USER_DENIED_MEDIA_ACCESS:kt,WEBRTC_ERROR:yt},Symbol.toStringTag,{value:"Module"})),Y="incomingCall",x="declinedIncomingCall",G="failedIncomingCall",$="terminatedIncomingCall",H="connecting",I="connected",T="disconnected",M="newRTCSession",m="registered",X="unregistered",f="registrationFailed",Be="newMessage",J="sipEvent",z="availableSecondRemoteStream",Q="notAvailableSecondRemoteStream",K="mustStopPresentation",P="shareState",j="enterRoom",Z="useLicense",ee="peerconnection:confirmed",te="peerconnection:ontrack",p="channels",ne="channels:notify",se="ended:fromserver",ie="main-cam-control",re="admin-stop-main-cam",oe="admin-start-main-cam",ae="admin-stop-mic",ce="admin-start-mic",v="admin-force-sync-media-state",Ee="participant:added-to-list-moderators",_e="participant:removed-from-list-moderators",he="participant:move-request-to-stream",de="participation:accepting-word-request",le="participation:cancelling-word-request",ue="webcast:started",Te="webcast:stopped",Se="account:changed",Ne="account:deleted",ge="conference:participant-token-issued",O="ended",Ve="sending",Ye="reinvite",xe="replaces",Ge="refer",$e="progress",Xe="accepted",b="confirmed",w="peerconnection",C="failed",Je="muted",ze="unmuted",Ce="newDTMF",Ae="newInfo",Qe="hold",Ke="unhold",je="update",Ze="sdp",et="icecandidate",tt="getusermediafailed",nt="peerconnection:createofferfailed",st="peerconnection:createanswerfailed",it="peerconnection:setlocaldescriptionfailed",rt="peerconnection:setremotedescriptionfailed",ot="presentation:start",at="presentation:started",ct="presentation:end",Re="presentation:ended",y="presentation:failed",Bt=Object.freeze(Object.defineProperty({__proto__:null,ACCEPTED:Xe,ACCOUNT_CHANGED:Se,ACCOUNT_DELETED:Ne,ADMIN_FORCE_SYNC_MEDIA_STATE:v,ADMIN_START_MAIN_CAM:oe,ADMIN_START_MIC:ce,ADMIN_STOP_MAIN_CAM:re,ADMIN_STOP_MIC:ae,AVAILABLE_SECOND_REMOTE_STREAM_EVENT:z,CHANNELS:p,CHANNELS_NOTIFY:ne,CONFERENCE_PARTICIPANT_TOKEN_ISSUED:ge,CONFIRMED:b,CONNECTED:I,CONNECTING:H,DECLINED_INCOMING_CALL:x,DISCONNECTED:T,ENDED:O,ENDED_FROM_SERVER:se,ENTER_ROOM:j,FAILED:C,FAILED_INCOMING_CALL:G,GET_USER_MEDIA_FAILED:tt,HOLD:Qe,ICE_CANDIDATE:et,INCOMING_CALL:Y,MAIN_CAM_CONTROL:ie,MUST_STOP_PRESENTATION_EVENT:K,MUTED:Je,NEW_DTMF:Ce,NEW_INFO:Ae,NEW_MESSAGE:Be,NEW_RTC_SESSION:M,NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT:Q,PARTICIPANT_ADDED_TO_LIST_MODERATORS:Ee,PARTICIPANT_MOVE_REQUEST_TO_STREAM:he,PARTICIPANT_REMOVED_FROM_LIST_MODERATORS:_e,PARTICIPATION_ACCEPTING_WORD_REQUEST:de,PARTICIPATION_CANCELLING_WORD_REQUEST:le,PEER_CONNECTION:w,PEER_CONNECTION_CONFIRMED:ee,PEER_CONNECTION_CREATE_ANSWER_FAILED:st,PEER_CONNECTION_CREATE_OFFER_FAILED:nt,PEER_CONNECTION_ONTRACK:te,PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED:it,PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED:rt,PRESENTATION_END:ct,PRESENTATION_ENDED:Re,PRESENTATION_FAILED:y,PRESENTATION_START:ot,PRESENTATION_STARTED:at,PROGRESS:$e,REFER:Ge,REGISTERED:m,REGISTRATION_FAILED:f,REINVITE:Ye,REPLACES:xe,SDP:Ze,SENDING:Ve,SHARE_STATE:P,SIP_EVENT:J,TERMINATED_INCOMING_CALL:$,UNHOLD:Ke,UNMUTED:ze,UNREGISTERED:X,UPDATE:je,USE_LICENSE:Z,WEBCAST_STARTED:ue,WEBCAST_STOPPED:Te},Symbol.toStringTag,{value:"Module"})),Et=[Y,x,$,G,de,le,he,ne,ge,Se,Ne,ue,Te,Ee,_e],Ie=[H,I,T,M,m,X,f,Be,J],_t=[z,Q,K,P,j,Z,ee,te,p,se,ie,oe,re,ae,ce,v],me=[O,H,Ve,Ye,xe,Ge,$e,Xe,b,w,C,Je,ze,Ce,Ae,Qe,Ke,je,Ze,et,tt,nt,st,it,rt,ot,at,ct,Re,y],fe=[...Ie,...Et],Oe=[...me,..._t],Vt=Object.freeze(Object.defineProperty({__proto__:null,SESSION_EVENT_NAMES:Oe,SESSION_JSSIP_EVENT_NAMES:me,SESSION_SYNTHETICS_EVENT_NAMES:_t,UA_EVENT_NAMES:fe,UA_JSSIP_EVENT_NAMES:Ie,UA_SYNTHETICS_EVENT_NAMES:Et},Symbol.toStringTag,{value:"Module"})),Yt=r=>{const e=[];return r&&e.push(`X-Vinteo-Remote: ${r}`),e},xt="content-type",Gt="x-webrtc-enter-room",q="application/vinteo.webrtc.sharedesktop",$t="application/vinteo.webrtc.roomname",Xt="application/vinteo.webrtc.channels",Jt="application/vinteo.webrtc.mediastate",zt="application/vinteo.webrtc.refusal",pe="application/vinteo.webrtc.maincam",Qt="application/vinteo.webrtc.mic",Kt="application/vinteo.webrtc.uselic",jt="X-WEBRTC-USE-LICENSE",ve="X-WEBRTC-INPUT-CHANNELS",be="X-WEBRTC-OUTPUT-CHANNELS",Zt="X-WEBRTC-MAINCAM",en="X-WEBRTC-MIC",we="X-WEBRTC-SYNC",tn="X-WEBRTC-MAINCAM-RESOLUTION",nn="X-WEBRTC-MEDIA-STATE",sn="X-Vinteo-Media-Type",rn="X-Vinteo-MainCam-State",on="X-Vinteo-Mic-State",an="application/vinteo.webrtc.notify",cn="X-VINTEO-NOTIFY",D="x-webrtc-share-state",En=`${D}: LETMESTARTPRESENTATION`,_n=`${D}: STOPPRESENTATION`,ht="YOUCANRECEIVECONTENT",dt="CONTENTEND",hn="YOUMUSTSTOPSENDCONTENT",dn=`${D}: ${ht}`,ln=`${D}: ${dt}`,un="X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE",Tn=`${un}: LETMESTARTMAINCAM`,De="sip-connector",W=B(De),Sn=()=>{B.enable(De)},Nn=()=>{B.enable(`-${De}`)};var A=(r=>(r.PAUSE_MAIN_CAM="PAUSEMAINCAM",r.RESUME_MAIN_CAM="RESUMEMAINCAM",r.MAX_MAIN_CAM_RESOLUTION="MAXMAINCAMRESOLUTION",r.ADMIN_STOP_MAIN_CAM="ADMINSTOPMAINCAM",r.ADMIN_START_MAIN_CAM="ADMINSTARTMAINCAM",r))(A||{}),U=(r=>(r.ADMIN_STOP_MIC="ADMINSTOPMIC",r.ADMIN_START_MIC="ADMINSTARTMIC",r))(U||{}),L=(r=>(r.ADMIN_SYNC_FORCED="1",r.ADMIN_SYNC_NOT_FORCED="0",r))(L||{}),lt=(r=>(r.AUDIO="AUDIO",r.VIDEO="VIDEO",r.AUDIOPLUSPRESENTATION="AUDIOPLUSPRESENTATION",r))(lt||{});function ye(r){return e=>`sip:${e}@${r}`}const gn=(r,e)=>()=>Math.floor(Math.random()*(e-r))+r,Ue=r=>r.trim().replaceAll(" ","_"),Cn=gn(1e5,99999999),k=(r,{videoMode:e,audioMode:t}={})=>{if(!r||e==="recvonly"&&t==="recvonly")return;const n=t==="recvonly"?[]:r.getAudioTracks(),s=e==="recvonly"?[]:r.getVideoTracks(),o=[...n,...s],a=new MediaStream(o);return a.getTracks=()=>[...a.getAudioTracks(),...a.getVideoTracks()],a},An=r=>r.some(t=>{const{kind:n}=t;return n==="video"}),Rn="Error decline with 603",In=r=>r.message===Rn,mn=(r,e)=>r.find(t=>t.track&&e.getTracks().includes(t.track)),ut=1,Tt=r=>(e,t)=>t!==void 0&&e!==t||t===void 0&&e!==r,fn=Tt(ut),On=(r,e)=>{const t=r===void 0?void 0:Math.max(r,ut);if(t!==void 0&&fn(t,e))return t},Dn=Tt(),Mn=(r,e)=>{if(Dn(r,e))return r},St=async(r,e,t)=>{const n=r.getParameters();(n.encodings===void 0||n.encodings.length===0)&&(n.encodings=[{}]);const[s]=n.encodings,o=s.scaleResolutionDownBy,a=On(e.scaleResolutionDownBy,o);let c=!1;a!==void 0&&(n.encodings[0].scaleResolutionDownBy=a,c=!0);const E=s.maxBitrate,h=Mn(e.maxBitrate,E);return h!==void 0&&(n.encodings[0].maxBitrate=h,c=!0),c?(t&&t(n),r.setParameters(n).then(()=>({parameters:n,isChanged:c}))):{parameters:n,isChanged:c}},Pn=async(r,e,t)=>{const n=mn(r,e);if(n)return St(n,{maxBitrate:t})},pn=486,vn=487,F="local",Le="remote",bn=(r=new Error)=>{const{originator:e,cause:t}=r;return S.isCanceledError(r)?!0:typeof t=="string"?t===He||t===V||e===F&&(t===We||t===ke):!1},N="SipConnector",wn="channels",yn="WebcastStarted",Un="WebcastStopped",Ln="accountChanged",Hn="accountDeleted",qn="addedToListModerators",kn="removedFromListModerators",Wn="ParticipationRequestAccepted",Fn="ParticipationRequestRejected",Bn="ParticipantMovedToWebcast",Vn="ConferenceParticipantTokenIssued";class Yn{constructor({JsSIP:e}){i(this,"_isRegisterConfig",!1);i(this,"_connectionConfiguration",{});i(this,"_remoteStreams",{});i(this,"JsSIP");i(this,"_sessionEvents");i(this,"_uaEvents");i(this,"_cancelableConnect");i(this,"_cancelableInitUa");i(this,"_cancelableDisconnect");i(this,"_cancelableSet");i(this,"_cancelableCall");i(this,"_cancelableAnswer");i(this,"_cancelableSendDTMF");i(this,"getSipServerUrl",e=>e);i(this,"promisePendingStartPresentation");i(this,"promisePendingStopPresentation");i(this,"ua");i(this,"session");i(this,"incomingSession");i(this,"_streamPresentationCurrent");i(this,"socket");i(this,"connect",async e=>(this._cancelRequests(),this._cancelableConnect.request(e)));i(this,"initUa",async e=>this._cancelableInitUa.request(e));i(this,"set",async e=>this._cancelableSet.request(e));i(this,"call",async e=>this._cancelableCall.request(e));i(this,"disconnect",async()=>(this._cancelRequests(),this._disconnectWithoutCancelRequests()));i(this,"answerToIncomingCall",async e=>this._cancelableAnswer.request(e));i(this,"sendDTMF",async e=>this._cancelableSendDTMF.request(e));i(this,"hangUp",async()=>(this._cancelRequests(),this._hangUpWithoutCancelRequests()));i(this,"tryRegister",async()=>{if(!this.isRegisterConfig)throw new Error("Config is not registered");this._uaEvents.trigger(H,void 0);try{await this.unregister()}catch(e){W("tryRegister",e)}return this.register()});i(this,"declineToIncomingCall",async({statusCode:e=vn}={})=>new Promise((t,n)=>{if(!this.isAvailableIncomingCall){n(new Error("no incomingSession"));return}const s=this.incomingSession,o=this.remoteCallerData;this._cancelableCall.cancelRequest(),this._cancelableAnswer.cancelRequest(),this.removeIncomingSession(),this._uaEvents.trigger(x,o),t(s.terminate({status_code:e}))}));i(this,"busyIncomingCall",async()=>this.declineToIncomingCall({statusCode:pn}));i(this,"removeIncomingSession",()=>{delete this.incomingSession});i(this,"handleNewRTCSession",({originator:e,session:t})=>{if(e===Le){this.incomingSession=t;const n=this.remoteCallerData;t.on(C,s=>{this.removeIncomingSession(),s.originator===F?this._uaEvents.trigger($,n):this._uaEvents.trigger(G,n)}),this._uaEvents.trigger(Y,n)}});i(this,"_connect",async e=>this.initUa(e).then(async()=>this._start()));i(this,"_initUa",async({user:e,password:t,sipServerUrl:n,sipWebSocketServerURL:s,remoteAddress:o,sdpSemantics:a,sessionTimers:c,registerExpires:E,connectionRecoveryMinInterval:h,connectionRecoveryMaxInterval:_,userAgent:u,displayName:l="",register:d=!1,extraHeaders:g=[]})=>{if(!n)throw new Error("sipServerUrl is required");if(!s)throw new Error("sipWebSocketServerURL is required");if(d&&!e)throw new Error("user is required for authorized connection");if(d&&!t)throw new Error("password is required for authorized connection");this._connectionConfiguration={sipServerUrl:n,displayName:l,register:d,user:e,password:t},this.getSipServerUrl=ye(n),this.socket=new this.JsSIP.WebSocketInterface(s),this.ua&&await this._disconnectWithoutCancelRequests(),this._isRegisterConfig=!!d;const{socket:R}=this;this.ua=this._createUa({user:e,password:t,socket:R,displayName:l,register:d,sdpSemantics:a,sessionTimers:c,registerExpires:E,connectionRecoveryMinInterval:h,connectionRecoveryMaxInterval:_,userAgent:u,getSipServerUrl:this.getSipServerUrl}),this._uaEvents.eachTriggers((gt,Ct)=>{const Me=Ie.find(At=>At===Ct);Me&&this.ua&&this.ua.on(Me,gt)});const Nt=[...Yt(o),...g];return this.ua.registrator().setExtraHeaders(Nt),this.ua});i(this,"_createUa",({user:e,password:t,socket:n,displayName:s,getSipServerUrl:o,register:a=!1,sdpSemantics:c="plan-b",sessionTimers:E=!1,registerExpires:h=60*5,connectionRecoveryMinInterval:_=2,connectionRecoveryMaxInterval:u=6,userAgent:l})=>{if(a&&!t)throw new Error("password is required for authorized connection");const d=a&&e?e.trim():`${Cn()}`,g=o(d),R={password:t,register:a,uri:g,display_name:Ue(s),user_agent:l,sdp_semantics:c,sockets:[n],session_timers:E,register_expires:h,connection_recovery_min_interval:_,connection_recovery_max_interval:u};return new this.JsSIP.UA(R)});i(this,"_start",async()=>new Promise((e,t)=>{const{ua:n}=this;if(!n){t(new Error("this.ua is not initialized"));return}const s=()=>{c(),e(n)},o=E=>{c(),t(E)},a=()=>{this.isRegisterConfig?(this.on(m,s),this.on(f,o)):this.on(I,s),this.on(T,o)},c=()=>{this.off(m,s),this.off(f,o),this.off(I,s),this.off(T,o)};a(),this.on(M,this.handleNewRTCSession),n.start()}));i(this,"_set",async({displayName:e,password:t})=>new Promise((n,s)=>{const{ua:o}=this;if(!o){s(new Error("this.ua is not initialized"));return}let a=!1,c=!1;e!==void 0&&e!==this._connectionConfiguration.displayName&&(a=o.set("display_name",Ue(e)),this._connectionConfiguration.displayName=e),t!==void 0&&t!==this._connectionConfiguration.password&&(c=o.set("password",t),this._connectionConfiguration.password=t);const E=a||c;c&&this.isRegisterConfig?this.register().then(()=>{n(E)}).catch(s):E?n(E):s(new Error("nothing changed"))}));i(this,"_disconnectWithoutCancelRequests",async()=>this._cancelableDisconnect.request());i(this,"_disconnect",async()=>{this.off(M,this.handleNewRTCSession);const e=new Promise(t=>{this.once(T,()=>{delete this.ua,t()})});return this.ua?(await this._hangUpWithoutCancelRequests(),this.ua?this.ua.stop():this._uaEvents.trigger(T,void 0)):this._uaEvents.trigger(T,void 0),e});i(this,"_call",async({number:e,mediaStream:t,extraHeaders:n=[],ontrack:s,iceServers:o,videoMode:a,audioMode:c,degradationPreference:E,offerToReceiveAudio:h=!0,offerToReceiveVideo:_=!0})=>new Promise((u,l)=>{const{ua:d}=this;if(!d){l(new Error("this.ua is not initialized"));return}this._connectionConfiguration.number=e,this._connectionConfiguration.answer=!1,this._handleCall({ontrack:s}).then(u).catch(l),this.session=d.call(this.getSipServerUrl(e),{extraHeaders:n,mediaStream:k(t,{videoMode:a,audioMode:c}),eventHandlers:this._sessionEvents.triggers,videoMode:a,audioMode:c,degradationPreference:E,pcConfig:{iceServers:o},rtcOfferConstraints:{offerToReceiveAudio:h,offerToReceiveVideo:_}})}));i(this,"_answer",async({mediaStream:e,ontrack:t,extraHeaders:n=[],iceServers:s,videoMode:o,audioMode:a,degradationPreference:c})=>new Promise((E,h)=>{if(!this.isAvailableIncomingCall){h(new Error("no incomingSession"));return}this.session=this.incomingSession,this.removeIncomingSession();const{session:_}=this;if(!_){h(new Error("No session established"));return}this._sessionEvents.eachTriggers((l,d)=>{const g=me.find(R=>R===d);g&&_.on(g,l)}),this._connectionConfiguration.answer=!0,this._connectionConfiguration.number=_.remote_identity.uri.user,this._handleCall({ontrack:t}).then(E).catch(h);const u=k(e,{videoMode:o,audioMode:a});_.answer({extraHeaders:n,videoMode:o,audioMode:a,degradationPreference:c,mediaStream:u,pcConfig:{iceServers:s}})}));i(this,"_handleCall",async({ontrack:e})=>new Promise((t,n)=>{const s=()=>{this.onSession(w,_),this.onSession(b,u)},o=()=>{this.offSession(w,_),this.offSession(b,u)},a=()=>{this.onSession(C,E),this.onSession(O,E)},c=()=>{this.offSession(C,E),this.offSession(O,E)},E=l=>{o(),c(),n(l)};let h;const _=({peerconnection:l})=>{h=l,h.ontrack=d=>{this._sessionEvents.trigger(te,h),e&&e(d)}},u=()=>{h&&this._sessionEvents.trigger(ee,h),o(),c(),t(h)};s(),a()}));i(this,"_restoreSession",()=>{this._resetPresentation(),delete this._connectionConfiguration.number,delete this.session,this._remoteStreams={}});i(this,"_sendDTMF",async e=>new Promise((t,n)=>{const{session:s}=this;if(!s){n(new Error("No session established"));return}this.onceSession(Ce,({originator:o})=>{o===F&&t()}),s.sendDTMF(e,{duration:120,interToneGap:600})}));i(this,"_hangUpWithoutCancelRequests",async()=>{if(this.ua&&this.session){const{session:e}=this;this._streamPresentationCurrent&&await this.stopPresentation(),this._restoreSession(),e.isEnded()||e.terminate()}});i(this,"_handleShareState",e=>{switch(e){case ht:{this._sessionEvents.trigger(z,void 0);break}case dt:{this._sessionEvents.trigger(Q,void 0);break}case hn:{this._sessionEvents.trigger(K,void 0);break}}});i(this,"_maybeTriggerChannels",e=>{const t=e.getHeader(ve),n=e.getHeader(be);if(t&&n){const s={inputChannels:t,outputChannels:n};this._sessionEvents.trigger(p,s)}});i(this,"_handleNotify",e=>{switch(e.cmd){case wn:{const t=e;this._triggerChannelsNotify(t);break}case yn:{const t=e;this._triggerWebcastStartedNotify(t);break}case Un:{const t=e;this._triggerWebcastStoppedNotify(t);break}case qn:{const t=e;this._triggerAddedToListModeratorsNotify(t);break}case kn:{const t=e;this._triggerRemovedFromListModeratorsNotify(t);break}case Wn:{const t=e;this._triggerParticipationAcceptingWordRequest(t);break}case Fn:{const t=e;this._triggerParticipationCancellingWordRequest(t);break}case Bn:{const t=e;this._triggerParticipantMoveRequestToStream(t);break}case Ln:{this._triggerAccountChangedNotify();break}case Hn:{this._triggerAccountDeletedNotify();break}case Vn:{const t=e;this._triggerConferenceParticipantTokenIssued(t);break}default:W("unknown cmd",e.cmd)}});i(this,"_triggerRemovedFromListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(_e,t)});i(this,"_triggerAddedToListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(Ee,t)});i(this,"_triggerWebcastStartedNotify",({body:{conference:e,type:t}})=>{const n={conference:e,type:t};this._uaEvents.trigger(ue,n)});i(this,"_triggerWebcastStoppedNotify",({body:{conference:e,type:t}})=>{const n={conference:e,type:t};this._uaEvents.trigger(Te,n)});i(this,"_triggerAccountChangedNotify",()=>{this._uaEvents.trigger(Se,void 0)});i(this,"_triggerAccountDeletedNotify",()=>{this._uaEvents.trigger(Ne,void 0)});i(this,"_triggerConferenceParticipantTokenIssued",({body:{conference:e,participant:t,jwt:n}})=>{const s={conference:e,participant:t,jwt:n};this._uaEvents.trigger(ge,s)});i(this,"_triggerChannelsNotify",e=>{const t=e.input,n=e.output,s={inputChannels:t,outputChannels:n};this._uaEvents.trigger(ne,s)});i(this,"_triggerParticipationAcceptingWordRequest",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(de,t)});i(this,"_triggerParticipationCancellingWordRequest",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(le,t)});i(this,"_triggerParticipantMoveRequestToStream",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(he,t)});i(this,"_triggerEnterRoom",e=>{const t=e.getHeader(Gt);this._sessionEvents.trigger(j,t)});i(this,"_triggerShareState",e=>{const t=e.getHeader(D);this._sessionEvents.trigger(P,t)});i(this,"_triggerMainCamControl",e=>{const t=e.getHeader(Zt),n=e.getHeader(we),s=n===L.ADMIN_SYNC_FORCED;if(t===A.ADMIN_START_MAIN_CAM)this._sessionEvents.trigger(oe,{isSyncForced:s});else if(t===A.ADMIN_STOP_MAIN_CAM)this._sessionEvents.trigger(re,{isSyncForced:s});else if((t===A.RESUME_MAIN_CAM||t===A.PAUSE_MAIN_CAM)&&n)this._sessionEvents.trigger(v,{isSyncForced:s});else{const o=e.getHeader(tn);this._sessionEvents.trigger(ie,{mainCam:t,resolutionMainCam:o})}});i(this,"_triggerMicControl",e=>{const t=e.getHeader(en),s=e.getHeader(we)===L.ADMIN_SYNC_FORCED;t===U.ADMIN_START_MIC?this._sessionEvents.trigger(ce,{isSyncForced:s}):t===U.ADMIN_STOP_MIC&&this._sessionEvents.trigger(ae,{isSyncForced:s})});i(this,"_triggerUseLicense",e=>{const t=e.getHeader(jt);this._sessionEvents.trigger(Z,t)});i(this,"_handleNewInfo",e=>{const{originator:t}=e;if(t!=="remote")return;const{request:n}=e,s=n.getHeader(xt);if(s)switch(s){case $t:{this._triggerEnterRoom(n),this._maybeTriggerChannels(n);break}case an:{this._maybeHandleNotify(n);break}case q:{this._triggerShareState(n);break}case pe:{this._triggerMainCamControl(n);break}case Qt:{this._triggerMicControl(n);break}case Kt:{this._triggerUseLicense(n);break}}});i(this,"_handleSipEvent",({request:e})=>{this._maybeHandleNotify(e)});i(this,"_maybeHandleNotify",e=>{const t=e.getHeader(cn);if(t){const n=JSON.parse(t);this._handleNotify(n)}});i(this,"_handleEnded",e=>{const{originator:t}=e;t===Le&&this._sessionEvents.trigger(se,e),this._restoreSession()});this.JsSIP=e,this._sessionEvents=new Pe(Oe),this._uaEvents=new Pe(fe),this._cancelableConnect=new S.CancelableRequest(this._connect,{moduleName:N,afterCancelRequest:()=>{this._cancelableInitUa.cancelRequest(),this._cancelableDisconnect.cancelRequest()}}),this._cancelableInitUa=new S.CancelableRequest(this._initUa,{moduleName:N}),this._cancelableDisconnect=new S.CancelableRequest(this._disconnect,{moduleName:N}),this._cancelableSet=new S.CancelableRequest(this._set,{moduleName:N}),this._cancelableCall=new S.CancelableRequest(this._call,{moduleName:N}),this._cancelableAnswer=new S.CancelableRequest(this._answer,{moduleName:N}),this._cancelableSendDTMF=new S.CancelableRequest(this._sendDTMF,{moduleName:N}),this.onSession(P,this._handleShareState),this.onSession(Ae,this._handleNewInfo),this.on(J,this._handleSipEvent),this.onSession(C,this._handleEnded),this.onSession(O,this._handleEnded)}async register(){return new Promise((e,t)=>{this.isRegisterConfig&&this.ua?(this.ua.on(m,e),this.ua.on(f,t),this.ua.register()):t(new Error("Config is not registered"))})}async unregister(){return new Promise((e,t)=>{this.isRegistered&&this.ua?(this.ua.on(X,e),this.ua.unregister()):t(new Error("ua is not registered"))})}async sendOptions(e,t,n){if(!this.ua)throw new Error("is not connected");return new Promise((s,o)=>{try{this.ua.sendOptions(e,t,{extraHeaders:n,eventHandlers:{succeeded:()=>{s()},failed:o}})}catch(a){o(a)}})}async ping(e,t){var s;if(!((s=this.ua)!=null&&s.configuration.uri))throw new Error("is not connected");const n=this.ua.configuration.uri;return this.sendOptions(n,e,t)}async checkTelephony({userAgent:e,displayName:t,sipServerUrl:n,sipWebSocketServerURL:s,sdpSemantics:o}){return new Promise((a,c)=>{const E=ye(n),h=new this.JsSIP.WebSocketInterface(s),_=this._createUa({socket:h,displayName:t,sdpSemantics:o,userAgent:e,getSipServerUrl:E}),u=()=>{const d=new Error("Telephony is not available");c(d)};_.once(T,u);const l=()=>{_.removeAllListeners(),_.once(T,a),_.stop()};_.once(I,l),_.start()})}async replaceMediaStream(e,t){if(!this.session)throw new Error("No session established");return this.session.replaceMediaStream(e,t)}async askPermissionToEnableCam(e={}){if(!this.session)throw new Error("No session established");const t=[Tn];return this.session.sendInfo(pe,void 0,{noTerminateWhenError:!0,...e,extraHeaders:t}).catch(n=>{if(In(n))throw n})}get isPendingPresentation(){return!!this.promisePendingStartPresentation||!!this.promisePendingStopPresentation}async _sendPresentation(e,t,{maxBitrate:n,degradationPreference:s,isNeedReinvite:o=!0,isP2P:a=!1}){const c=k(t);this._streamPresentationCurrent=c;const E=a?[dn]:[En],h=e.sendInfo(q,void 0,{extraHeaders:E}).then(async()=>e.startPresentation(c,o,s)).then(async()=>{const{connection:_}=this;if(!_||n===void 0)return;const u=_.getSenders();return Pn(u,t,n)}).then(()=>t).catch(_=>{throw this._sessionEvents.trigger(y,_),_});return this.promisePendingStartPresentation=h,h.finally(()=>{this.promisePendingStartPresentation=void 0})}async startPresentation(e,{isNeedReinvite:t=!0,isP2P:n=!1,maxBitrate:s,degradationPreference:o}={}){const a=this.establishedSession;if(!a)throw new Error("No session established");if(this._streamPresentationCurrent)throw new Error("Presentation is already started");return this._sendPresentation(a,e,{isNeedReinvite:t,isP2P:n,maxBitrate:s,degradationPreference:o})}async stopPresentation({isP2P:e=!1}={}){const t=this._streamPresentationCurrent;let n=this.promisePendingStartPresentation??Promise.resolve();const s=e?[ln]:[_n],o=this.establishedSession;return o&&t&&(n=n.then(async()=>o.sendInfo(q,void 0,{extraHeaders:s})).then(async()=>o.stopPresentation(t)).catch(a=>{throw this._sessionEvents.trigger(y,a),a})),!o&&t&&this._sessionEvents.trigger(Re,t),this.promisePendingStopPresentation=n,n.finally(()=>{this._resetPresentation()})}async updatePresentation(e,{isP2P:t=!1,maxBitrate:n,degradationPreference:s}={}){const o=this.establishedSession;if(!o)throw new Error("No session established");if(!this._streamPresentationCurrent)throw new Error("Presentation has not started yet");return this.promisePendingStartPresentation&&await this.promisePendingStartPresentation,this._sendPresentation(o,e,{isP2P:t,maxBitrate:n,degradationPreference:s,isNeedReinvite:!1})}_resetPresentation(){delete this._streamPresentationCurrent,this.promisePendingStartPresentation=void 0,this.promisePendingStopPresentation=void 0}on(e,t){return this._uaEvents.on(e,t)}once(e,t){return this._uaEvents.once(e,t)}onceRace(e,t){return this._uaEvents.onceRace(e,t)}async wait(e){return this._uaEvents.wait(e)}off(e,t){this._uaEvents.off(e,t)}onSession(e,t){return this._sessionEvents.on(e,t)}onceSession(e,t){return this._sessionEvents.once(e,t)}onceRaceSession(e,t){return this._sessionEvents.onceRace(e,t)}async waitSession(e){return this._sessionEvents.wait(e)}offSession(e,t){this._sessionEvents.off(e,t)}isConfigured(){return!!this.ua}getConnectionConfiguration(){return{...this._connectionConfiguration}}getRemoteStreams(){if(!this.connection)return;const t=this.connection.getReceivers().map(({track:n})=>n);return An(t)?this._generateStreams(t):this._generateAudioStreams(t)}get connection(){var t;return(t=this.session)==null?void 0:t.connection}get remoteCallerData(){var e,t,n,s,o,a;return{displayName:(t=(e=this.incomingSession)==null?void 0:e.remote_identity)==null?void 0:t.display_name,host:(s=(n=this.incomingSession)==null?void 0:n.remote_identity)==null?void 0:s.uri.host,incomingNumber:(a=(o=this.incomingSession)==null?void 0:o.remote_identity)==null?void 0:a.uri.user,session:this.incomingSession}}get requested(){return this._cancelableConnect.requested||this._cancelableInitUa.requested||this._cancelableCall.requested||this._cancelableAnswer.requested}get establishedSession(){return this.session&&this.session.isEstablished()?this.session:void 0}get isRegistered(){return!!this.ua&&this.ua.isRegistered()}get isRegisterConfig(){return!!this.ua&&this._isRegisterConfig}get isCallActive(){return!!(this.ua&&this.session)}get isAvailableIncomingCall(){return!!this.incomingSession}_generateStream(e,t){const{id:n}=e,s=this._remoteStreams[n]||new MediaStream;return t&&s.addTrack(t),s.addTrack(e),this._remoteStreams[n]=s,s}_generateAudioStream(e){const{id:t}=e,n=this._remoteStreams[t]||new MediaStream;return n.addTrack(e),this._remoteStreams[t]=n,n}_generateStreams(e){const t=[];return e.forEach((n,s)=>{if(n.kind==="audio")return;const o=n,a=e[s-1];let c;a&&a.kind==="audio"&&(c=a);const E=this._generateStream(o,c);t.push(E)}),t}_generateAudioStreams(e){return e.map(n=>this._generateAudioStream(n))}_cancelRequests(){this._cancelActionsRequests(),this._cancelCallRequests(),this._cancelConnectRequests()}_cancelConnectRequests(){this._cancelableConnect.cancelRequest()}_cancelCallRequests(){this._cancelableCall.cancelRequest(),this._cancelableAnswer.cancelRequest()}_cancelActionsRequests(){this._cancelableAnswer.cancelRequest(),this._cancelableSendDTMF.cancelRequest()}async waitChannels(){return this.waitSession(p)}async waitSyncMediaState(){return this.waitSession(v)}async sendChannels({inputChannels:e,outputChannels:t}){if(!this.session)throw new Error("No session established");const n=`${ve}: ${e}`,s=`${be}: ${t}`,o=[n,s];return this.session.sendInfo(Xt,void 0,{extraHeaders:o})}async sendMediaState({cam:e,mic:t},n={}){if(!this.session)throw new Error("No session established");const s=`${nn}: currentstate`,o=`${rn}: ${Number(e)}`,a=`${on}: ${Number(t)}`,c=[s,o,a];return this.session.sendInfo(Jt,void 0,{noTerminateWhenError:!0,...n,extraHeaders:c})}async _sendRefusalToTurnOn(e,t={}){if(!this.session)throw new Error("No session established");const c=[`${sn}: ${e==="mic"?0:1}`];return this.session.sendInfo(zt,void 0,{noTerminateWhenError:!0,...t,extraHeaders:c})}async sendRefusalToTurnOnMic(e={}){if(!this.session)throw new Error("No session established");return this._sendRefusalToTurnOn("mic",{noTerminateWhenError:!0,...e})}async sendRefusalToTurnOnCam(e={}){if(!this.session)throw new Error("No session established");return this._sendRefusalToTurnOn("cam",{noTerminateWhenError:!0,...e})}}exports.BAD_MEDIA_DESCRIPTION=Fe;exports.EEventsMainCAM=A;exports.EEventsMic=U;exports.EEventsSyncMediaState=L;exports.EUseLicense=lt;exports.NOT_FOUND=qe;exports.REJECTED=V;exports.SESSION_EVENT_NAMES=Oe;exports.SipConnector=Yn;exports.UA_EVENT_NAMES=fe;exports.causes=Ft;exports.constants=Bt;exports.disableDebug=Nn;exports.enableDebug=Sn;exports.eventNames=Vt;exports.hasCanceledCallError=bn;exports.logger=W;exports.setEncodingsToSender=St;
|
|
1
|
+
"use strict";var Rt=Object.defineProperty;var It=(r,e,t)=>e in r?Rt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var i=(r,e,t)=>(It(r,typeof e!="symbol"?e+"":e,t),t);const S=require("@krivega/cancelable-promise"),Pe=require("events-constructor"),B=require("debug"),mt="Connection Error",He="Request Timeout",ft="SIP Failure Code",Ot="Internal Error",Dt="Busy",V="Rejected",Mt="Redirected",Pt="Unavailable",qe="Not Found",pt="Address Incomplete",vt="Incompatible SDP",bt="Missing SDP",wt="Authentication Error",ke="Terminated",yt="WebRTC Error",We="Canceled",Ut="No Answer",Lt="Expires",Ht="No ACK",qt="Dialog Error",kt="User Denied Media Access",Fe="Bad Media Description",Wt="RTP Timeout",Ft=Object.freeze(Object.defineProperty({__proto__:null,ADDRESS_INCOMPLETE:pt,AUTHENTICATION_ERROR:wt,BAD_MEDIA_DESCRIPTION:Fe,BUSY:Dt,BYE:ke,CANCELED:We,CONNECTION_ERROR:mt,DIALOG_ERROR:qt,EXPIRES:Lt,INCOMPATIBLE_SDP:vt,INTERNAL_ERROR:Ot,MISSING_SDP:bt,NOT_FOUND:qe,NO_ACK:Ht,NO_ANSWER:Ut,REDIRECTED:Mt,REJECTED:V,REQUEST_TIMEOUT:He,RTP_TIMEOUT:Wt,SIP_FAILURE_CODE:ft,UNAVAILABLE:Pt,USER_DENIED_MEDIA_ACCESS:kt,WEBRTC_ERROR:yt},Symbol.toStringTag,{value:"Module"})),Y="incomingCall",x="declinedIncomingCall",G="failedIncomingCall",$="terminatedIncomingCall",H="connecting",I="connected",T="disconnected",M="newRTCSession",m="registered",X="unregistered",f="registrationFailed",Be="newMessage",J="sipEvent",z="availableSecondRemoteStream",Q="notAvailableSecondRemoteStream",K="mustStopPresentation",P="shareState",j="enterRoom",Z="useLicense",ee="peerconnection:confirmed",te="peerconnection:ontrack",p="channels",ne="channels:notify",se="ended:fromserver",ie="main-cam-control",re="admin-stop-main-cam",oe="admin-start-main-cam",ae="admin-stop-mic",ce="admin-start-mic",v="admin-force-sync-media-state",Ee="participant:added-to-list-moderators",_e="participant:removed-from-list-moderators",he="participant:move-request-to-stream",de="participation:accepting-word-request",le="participation:cancelling-word-request",ue="webcast:started",Te="webcast:stopped",Se="account:changed",Ne="account:deleted",ge="conference:participant-token-issued",O="ended",Ve="sending",Ye="reinvite",xe="replaces",Ge="refer",$e="progress",Xe="accepted",b="confirmed",w="peerconnection",C="failed",Je="muted",ze="unmuted",Ce="newDTMF",Ae="newInfo",Qe="hold",Ke="unhold",je="update",Ze="sdp",et="icecandidate",tt="getusermediafailed",nt="peerconnection:createofferfailed",st="peerconnection:createanswerfailed",it="peerconnection:setlocaldescriptionfailed",rt="peerconnection:setremotedescriptionfailed",ot="presentation:start",at="presentation:started",ct="presentation:end",Re="presentation:ended",y="presentation:failed",Bt=Object.freeze(Object.defineProperty({__proto__:null,ACCEPTED:Xe,ACCOUNT_CHANGED:Se,ACCOUNT_DELETED:Ne,ADMIN_FORCE_SYNC_MEDIA_STATE:v,ADMIN_START_MAIN_CAM:oe,ADMIN_START_MIC:ce,ADMIN_STOP_MAIN_CAM:re,ADMIN_STOP_MIC:ae,AVAILABLE_SECOND_REMOTE_STREAM_EVENT:z,CHANNELS:p,CHANNELS_NOTIFY:ne,CONFERENCE_PARTICIPANT_TOKEN_ISSUED:ge,CONFIRMED:b,CONNECTED:I,CONNECTING:H,DECLINED_INCOMING_CALL:x,DISCONNECTED:T,ENDED:O,ENDED_FROM_SERVER:se,ENTER_ROOM:j,FAILED:C,FAILED_INCOMING_CALL:G,GET_USER_MEDIA_FAILED:tt,HOLD:Qe,ICE_CANDIDATE:et,INCOMING_CALL:Y,MAIN_CAM_CONTROL:ie,MUST_STOP_PRESENTATION_EVENT:K,MUTED:Je,NEW_DTMF:Ce,NEW_INFO:Ae,NEW_MESSAGE:Be,NEW_RTC_SESSION:M,NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT:Q,PARTICIPANT_ADDED_TO_LIST_MODERATORS:Ee,PARTICIPANT_MOVE_REQUEST_TO_STREAM:he,PARTICIPANT_REMOVED_FROM_LIST_MODERATORS:_e,PARTICIPATION_ACCEPTING_WORD_REQUEST:de,PARTICIPATION_CANCELLING_WORD_REQUEST:le,PEER_CONNECTION:w,PEER_CONNECTION_CONFIRMED:ee,PEER_CONNECTION_CREATE_ANSWER_FAILED:st,PEER_CONNECTION_CREATE_OFFER_FAILED:nt,PEER_CONNECTION_ONTRACK:te,PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED:it,PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED:rt,PRESENTATION_END:ct,PRESENTATION_ENDED:Re,PRESENTATION_FAILED:y,PRESENTATION_START:ot,PRESENTATION_STARTED:at,PROGRESS:$e,REFER:Ge,REGISTERED:m,REGISTRATION_FAILED:f,REINVITE:Ye,REPLACES:xe,SDP:Ze,SENDING:Ve,SHARE_STATE:P,SIP_EVENT:J,TERMINATED_INCOMING_CALL:$,UNHOLD:Ke,UNMUTED:ze,UNREGISTERED:X,UPDATE:je,USE_LICENSE:Z,WEBCAST_STARTED:ue,WEBCAST_STOPPED:Te},Symbol.toStringTag,{value:"Module"})),Et=[Y,x,$,G,de,le,he,ne,ge,Se,Ne,ue,Te,Ee,_e],Ie=[H,I,T,M,m,X,f,Be,J],_t=[z,Q,K,P,j,Z,ee,te,p,se,ie,oe,re,ae,ce,v],me=[O,H,Ve,Ye,xe,Ge,$e,Xe,b,w,C,Je,ze,Ce,Ae,Qe,Ke,je,Ze,et,tt,nt,st,it,rt,ot,at,ct,Re,y],fe=[...Ie,...Et],Oe=[...me,..._t],Vt=Object.freeze(Object.defineProperty({__proto__:null,SESSION_EVENT_NAMES:Oe,SESSION_JSSIP_EVENT_NAMES:me,SESSION_SYNTHETICS_EVENT_NAMES:_t,UA_EVENT_NAMES:fe,UA_JSSIP_EVENT_NAMES:Ie,UA_SYNTHETICS_EVENT_NAMES:Et},Symbol.toStringTag,{value:"Module"})),Yt=r=>{const e=[];return r&&e.push(`X-Vinteo-Remote: ${r}`),e},xt="content-type",Gt="x-webrtc-enter-room",q="application/vinteo.webrtc.sharedesktop",$t="application/vinteo.webrtc.roomname",Xt="application/vinteo.webrtc.channels",Jt="application/vinteo.webrtc.mediastate",zt="application/vinteo.webrtc.refusal",pe="application/vinteo.webrtc.maincam",Qt="application/vinteo.webrtc.mic",Kt="application/vinteo.webrtc.uselic",jt="X-WEBRTC-USE-LICENSE",ve="X-WEBRTC-INPUT-CHANNELS",be="X-WEBRTC-OUTPUT-CHANNELS",Zt="X-WEBRTC-MAINCAM",en="X-WEBRTC-MIC",we="X-WEBRTC-SYNC",tn="X-WEBRTC-MAINCAM-RESOLUTION",nn="X-WEBRTC-MEDIA-STATE",sn="X-Vinteo-Media-Type",rn="X-Vinteo-MainCam-State",on="X-Vinteo-Mic-State",an="application/vinteo.webrtc.notify",cn="X-VINTEO-NOTIFY",D="x-webrtc-share-state",En=`${D}: LETMESTARTPRESENTATION`,_n=`${D}: STOPPRESENTATION`,ht="YOUCANRECEIVECONTENT",dt="CONTENTEND",hn="YOUMUSTSTOPSENDCONTENT",dn=`${D}: ${ht}`,ln=`${D}: ${dt}`,un="X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE",Tn=`${un}: LETMESTARTMAINCAM`,De="sip-connector",W=B(De),Sn=()=>{B.enable(De)},Nn=()=>{B.enable(`-${De}`)};var A=(r=>(r.PAUSE_MAIN_CAM="PAUSEMAINCAM",r.RESUME_MAIN_CAM="RESUMEMAINCAM",r.MAX_MAIN_CAM_RESOLUTION="MAXMAINCAMRESOLUTION",r.ADMIN_STOP_MAIN_CAM="ADMINSTOPMAINCAM",r.ADMIN_START_MAIN_CAM="ADMINSTARTMAINCAM",r))(A||{}),U=(r=>(r.ADMIN_STOP_MIC="ADMINSTOPMIC",r.ADMIN_START_MIC="ADMINSTARTMIC",r))(U||{}),L=(r=>(r.ADMIN_SYNC_FORCED="1",r.ADMIN_SYNC_NOT_FORCED="0",r))(L||{}),lt=(r=>(r.AUDIO="AUDIO",r.VIDEO="VIDEO",r.AUDIOPLUSPRESENTATION="AUDIOPLUSPRESENTATION",r))(lt||{});function ye(r){return e=>`sip:${e}@${r}`}const gn=(r,e)=>()=>Math.floor(Math.random()*(e-r))+r,Ue=r=>r.trim().replaceAll(" ","_"),Cn=gn(1e5,99999999),k=(r,{videoMode:e,audioMode:t}={})=>{if(!r||e==="recvonly"&&t==="recvonly")return;const n=t==="recvonly"?[]:r.getAudioTracks(),s=e==="recvonly"?[]:r.getVideoTracks(),o=[...n,...s],a=new MediaStream(o);return a.getTracks=()=>[...a.getAudioTracks(),...a.getVideoTracks()],a},An=r=>r.some(t=>{const{kind:n}=t;return n==="video"}),Rn="Error decline with 603",In=r=>r.message===Rn,mn=(r,e)=>r.find(t=>t.track&&e.getTracks().includes(t.track)),ut=1,Tt=r=>(e,t)=>t!==void 0&&e!==t||t===void 0&&e!==r,fn=Tt(ut),On=(r,e)=>{const t=r===void 0?void 0:Math.max(r,ut);if(t!==void 0&&fn(t,e))return t},Dn=Tt(),Mn=(r,e)=>{if(Dn(r,e))return r},St=async(r,e,t)=>{const n=r.getParameters();(n.encodings===void 0||n.encodings.length===0)&&(n.encodings=[{}]);const[s]=n.encodings,o=s.scaleResolutionDownBy,a=On(e.scaleResolutionDownBy,o);let c=!1;a!==void 0&&(n.encodings[0].scaleResolutionDownBy=a,c=!0);const E=s.maxBitrate,h=Mn(e.maxBitrate,E);return h!==void 0&&(n.encodings[0].maxBitrate=h,c=!0),c?(t&&t(n),r.setParameters(n).then(()=>({parameters:n,isChanged:c}))):{parameters:n,isChanged:c}},Pn=async(r,e,t)=>{const n=mn(r,e);if(n)return St(n,{maxBitrate:t})},pn=486,vn=487,F="local",Le="remote",bn=(r=new Error)=>{const{originator:e,cause:t}=r;return S.isCanceledError(r)?!0:typeof t=="string"?t===He||t===V||e===F&&(t===We||t===ke):!1},N="SipConnector",wn="channels",yn="WebcastStarted",Un="WebcastStopped",Ln="accountChanged",Hn="accountDeleted",qn="addedToListModerators",kn="removedFromListModerators",Wn="ParticipationRequestAccepted",Fn="ParticipationRequestRejected",Bn="ParticipantMovedToWebcast",Vn="ConferenceParticipantTokenIssued";class Yn{constructor({JsSIP:e}){i(this,"_isRegisterConfig",!1);i(this,"_connectionConfiguration",{});i(this,"_remoteStreams",{});i(this,"JsSIP");i(this,"_sessionEvents");i(this,"_uaEvents");i(this,"_cancelableConnect");i(this,"_cancelableInitUa");i(this,"_cancelableDisconnect");i(this,"_cancelableSet");i(this,"_cancelableCall");i(this,"_cancelableAnswer");i(this,"_cancelableSendDTMF");i(this,"getSipServerUrl",e=>e);i(this,"promisePendingStartPresentation");i(this,"promisePendingStopPresentation");i(this,"ua");i(this,"session");i(this,"incomingSession");i(this,"_streamPresentationCurrent");i(this,"socket");i(this,"connect",async e=>(this._cancelRequests(),this._cancelableConnect.request(e)));i(this,"initUa",async e=>this._cancelableInitUa.request(e));i(this,"set",async e=>this._cancelableSet.request(e));i(this,"call",async e=>this._cancelableCall.request(e));i(this,"disconnect",async()=>(this._cancelRequests(),this._disconnectWithoutCancelRequests()));i(this,"answerToIncomingCall",async e=>this._cancelableAnswer.request(e));i(this,"sendDTMF",async e=>this._cancelableSendDTMF.request(e));i(this,"hangUp",async()=>(this._cancelRequests(),this._hangUpWithoutCancelRequests()));i(this,"tryRegister",async()=>{if(!this.isRegisterConfig)throw new Error("Config is not registered");this._uaEvents.trigger(H,void 0);try{await this.unregister()}catch(e){W("tryRegister",e)}return this.register()});i(this,"declineToIncomingCall",async({statusCode:e=vn}={})=>new Promise((t,n)=>{if(!this.isAvailableIncomingCall){n(new Error("no incomingSession"));return}const s=this.incomingSession,o=this.remoteCallerData;this._cancelableCall.cancelRequest(),this._cancelableAnswer.cancelRequest(),this.removeIncomingSession(),this._uaEvents.trigger(x,o),t(s.terminate({status_code:e}))}));i(this,"busyIncomingCall",async()=>this.declineToIncomingCall({statusCode:pn}));i(this,"removeIncomingSession",()=>{delete this.incomingSession});i(this,"handleNewRTCSession",({originator:e,session:t})=>{if(e===Le){this.incomingSession=t;const n=this.remoteCallerData;t.on(C,s=>{this.removeIncomingSession(),s.originator===F?this._uaEvents.trigger($,n):this._uaEvents.trigger(G,n)}),this._uaEvents.trigger(Y,n)}});i(this,"_connect",async e=>this.initUa(e).then(async()=>this._start()));i(this,"_initUa",async({user:e,password:t,sipServerUrl:n,sipWebSocketServerURL:s,remoteAddress:o,sdpSemantics:a,sessionTimers:c,registerExpires:E,connectionRecoveryMinInterval:h,connectionRecoveryMaxInterval:_,userAgent:u,displayName:l="",register:d=!1,extraHeaders:g=[]})=>{if(!n)throw new Error("sipServerUrl is required");if(!s)throw new Error("sipWebSocketServerURL is required");if(d&&!e)throw new Error("user is required for authorized connection");if(d&&!t)throw new Error("password is required for authorized connection");this._connectionConfiguration={sipServerUrl:n,displayName:l,register:d,user:e,password:t},this.getSipServerUrl=ye(n),this.socket=new this.JsSIP.WebSocketInterface(s),this.ua&&await this._disconnectWithoutCancelRequests(),this._isRegisterConfig=!!d;const{socket:R}=this;this.ua=this._createUa({user:e,password:t,socket:R,displayName:l,register:d,sdpSemantics:a,sessionTimers:c,registerExpires:E,connectionRecoveryMinInterval:h,connectionRecoveryMaxInterval:_,userAgent:u,getSipServerUrl:this.getSipServerUrl}),this._uaEvents.eachTriggers((gt,Ct)=>{const Me=Ie.find(At=>At===Ct);Me&&this.ua&&this.ua.on(Me,gt)});const Nt=[...Yt(o),...g];return this.ua.registrator().setExtraHeaders(Nt),this.ua});i(this,"_createUa",({user:e,password:t,socket:n,displayName:s,getSipServerUrl:o,register:a=!1,sdpSemantics:c="plan-b",sessionTimers:E=!1,registerExpires:h=60*5,connectionRecoveryMinInterval:_=2,connectionRecoveryMaxInterval:u=6,userAgent:l})=>{if(a&&!t)throw new Error("password is required for authorized connection");const d=a&&e?e.trim():`${Cn()}`,g=o(d),R={password:t,register:a,uri:g,display_name:Ue(s),user_agent:l,sdp_semantics:c,sockets:[n],session_timers:E,register_expires:h,connection_recovery_min_interval:_,connection_recovery_max_interval:u};return new this.JsSIP.UA(R)});i(this,"_start",async()=>new Promise((e,t)=>{const{ua:n}=this;if(!n){t(new Error("this.ua is not initialized"));return}const s=()=>{c(),e(n)},o=E=>{c(),t(E)},a=()=>{this.isRegisterConfig?(this.on(m,s),this.on(f,o)):this.on(I,s),this.on(T,o)},c=()=>{this.off(m,s),this.off(f,o),this.off(I,s),this.off(T,o)};a(),this.on(M,this.handleNewRTCSession),n.start()}));i(this,"_set",async({displayName:e,password:t})=>new Promise((n,s)=>{const{ua:o}=this;if(!o){s(new Error("this.ua is not initialized"));return}let a=!1,c=!1;e!==void 0&&e!==this._connectionConfiguration.displayName&&(a=o.set("display_name",Ue(e)),this._connectionConfiguration.displayName=e),t!==void 0&&t!==this._connectionConfiguration.password&&(c=o.set("password",t),this._connectionConfiguration.password=t);const E=a||c;c&&this.isRegisterConfig?this.register().then(()=>{n(E)}).catch(s):E?n(E):s(new Error("nothing changed"))}));i(this,"_disconnectWithoutCancelRequests",async()=>this._cancelableDisconnect.request());i(this,"_disconnect",async()=>{this.off(M,this.handleNewRTCSession);const e=new Promise(t=>{this.once(T,()=>{delete this.ua,t()})});return this.ua?(await this._hangUpWithoutCancelRequests(),this.ua?this.ua.stop():this._uaEvents.trigger(T,void 0)):this._uaEvents.trigger(T,void 0),e});i(this,"_call",async({number:e,mediaStream:t,extraHeaders:n=[],ontrack:s,iceServers:o,videoMode:a,audioMode:c,degradationPreference:E,offerToReceiveAudio:h=!0,offerToReceiveVideo:_=!0})=>new Promise((u,l)=>{const{ua:d}=this;if(!d){l(new Error("this.ua is not initialized"));return}this._connectionConfiguration.number=e,this._connectionConfiguration.answer=!1,this._handleCall({ontrack:s}).then(u).catch(l),this.session=d.call(this.getSipServerUrl(e),{extraHeaders:n,mediaStream:k(t,{videoMode:a,audioMode:c}),eventHandlers:this._sessionEvents.triggers,videoMode:a,audioMode:c,degradationPreference:E,pcConfig:{iceServers:o},rtcOfferConstraints:{offerToReceiveAudio:h,offerToReceiveVideo:_}})}));i(this,"_answer",async({mediaStream:e,ontrack:t,extraHeaders:n=[],iceServers:s,videoMode:o,audioMode:a,degradationPreference:c})=>new Promise((E,h)=>{if(!this.isAvailableIncomingCall){h(new Error("no incomingSession"));return}this.session=this.incomingSession,this.removeIncomingSession();const{session:_}=this;if(!_){h(new Error("No session established"));return}this._sessionEvents.eachTriggers((l,d)=>{const g=me.find(R=>R===d);g&&_.on(g,l)}),this._connectionConfiguration.answer=!0,this._connectionConfiguration.number=_.remote_identity.uri.user,this._handleCall({ontrack:t}).then(E).catch(h);const u=k(e,{videoMode:o,audioMode:a});_.answer({extraHeaders:n,videoMode:o,audioMode:a,degradationPreference:c,mediaStream:u,pcConfig:{iceServers:s}})}));i(this,"_handleCall",async({ontrack:e})=>new Promise((t,n)=>{const s=()=>{this.onSession(w,_),this.onSession(b,u)},o=()=>{this.offSession(w,_),this.offSession(b,u)},a=()=>{this.onSession(C,E),this.onSession(O,E)},c=()=>{this.offSession(C,E),this.offSession(O,E)},E=l=>{o(),c(),n(l)};let h;const _=({peerconnection:l})=>{h=l,h.ontrack=d=>{this._sessionEvents.trigger(te,h),e&&e(d)}},u=()=>{h&&this._sessionEvents.trigger(ee,h),o(),c(),t(h)};s(),a()}));i(this,"_restoreSession",()=>{this._resetPresentation(),delete this._connectionConfiguration.number,delete this.session,this._remoteStreams={}});i(this,"_sendDTMF",async e=>new Promise((t,n)=>{const{session:s}=this;if(!s){n(new Error("No session established"));return}this.onceSession(Ce,({originator:o})=>{o===F&&t()}),s.sendDTMF(e,{duration:120,interToneGap:600})}));i(this,"_hangUpWithoutCancelRequests",async()=>{if(this.ua&&this.session){const{session:e}=this;this._streamPresentationCurrent&&await this.stopPresentation(),this._restoreSession(),e.isEnded()||e.terminate()}});i(this,"_handleShareState",e=>{switch(e){case ht:{this._sessionEvents.trigger(z,void 0);break}case dt:{this._sessionEvents.trigger(Q,void 0);break}case hn:{this._sessionEvents.trigger(K,void 0);break}}});i(this,"_maybeTriggerChannels",e=>{const t=e.getHeader(ve),n=e.getHeader(be);if(t&&n){const s={inputChannels:t,outputChannels:n};this._sessionEvents.trigger(p,s)}});i(this,"_handleNotify",e=>{switch(e.cmd){case wn:{const t=e;this._triggerChannelsNotify(t);break}case yn:{const t=e;this._triggerWebcastStartedNotify(t);break}case Un:{const t=e;this._triggerWebcastStoppedNotify(t);break}case qn:{const t=e;this._triggerAddedToListModeratorsNotify(t);break}case kn:{const t=e;this._triggerRemovedFromListModeratorsNotify(t);break}case Wn:{const t=e;this._triggerParticipationAcceptingWordRequest(t);break}case Fn:{const t=e;this._triggerParticipationCancellingWordRequest(t);break}case Bn:{const t=e;this._triggerParticipantMoveRequestToStream(t);break}case Ln:{this._triggerAccountChangedNotify();break}case Hn:{this._triggerAccountDeletedNotify();break}case Vn:{const t=e;this._triggerConferenceParticipantTokenIssued(t);break}default:W("unknown cmd",e.cmd)}});i(this,"_triggerRemovedFromListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(_e,t)});i(this,"_triggerAddedToListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(Ee,t)});i(this,"_triggerWebcastStartedNotify",({body:{conference:e,type:t}})=>{const n={conference:e,type:t};this._uaEvents.trigger(ue,n)});i(this,"_triggerWebcastStoppedNotify",({body:{conference:e,type:t}})=>{const n={conference:e,type:t};this._uaEvents.trigger(Te,n)});i(this,"_triggerAccountChangedNotify",()=>{this._uaEvents.trigger(Se,void 0)});i(this,"_triggerAccountDeletedNotify",()=>{this._uaEvents.trigger(Ne,void 0)});i(this,"_triggerConferenceParticipantTokenIssued",({body:{conference:e,participant:t,jwt:n}})=>{const s={conference:e,participant:t,jwt:n};this._uaEvents.trigger(ge,s)});i(this,"_triggerChannelsNotify",e=>{const t=e.input,n=e.output,s={inputChannels:t,outputChannels:n};this._uaEvents.trigger(ne,s)});i(this,"_triggerParticipationAcceptingWordRequest",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(de,t)});i(this,"_triggerParticipationCancellingWordRequest",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(le,t)});i(this,"_triggerParticipantMoveRequestToStream",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(he,t)});i(this,"_triggerEnterRoom",e=>{const t=e.getHeader(Gt);this._sessionEvents.trigger(j,t)});i(this,"_triggerShareState",e=>{const t=e.getHeader(D);this._sessionEvents.trigger(P,t)});i(this,"_triggerMainCamControl",e=>{const t=e.getHeader(Zt),n=e.getHeader(we),s=n===L.ADMIN_SYNC_FORCED;if(t===A.ADMIN_START_MAIN_CAM)this._sessionEvents.trigger(oe,{isSyncForced:s});else if(t===A.ADMIN_STOP_MAIN_CAM)this._sessionEvents.trigger(re,{isSyncForced:s});else if((t===A.RESUME_MAIN_CAM||t===A.PAUSE_MAIN_CAM)&&n)this._sessionEvents.trigger(v,{isSyncForced:s});else{const o=e.getHeader(tn);this._sessionEvents.trigger(ie,{mainCam:t,resolutionMainCam:o})}});i(this,"_triggerMicControl",e=>{const t=e.getHeader(en),s=e.getHeader(we)===L.ADMIN_SYNC_FORCED;t===U.ADMIN_START_MIC?this._sessionEvents.trigger(ce,{isSyncForced:s}):t===U.ADMIN_STOP_MIC&&this._sessionEvents.trigger(ae,{isSyncForced:s})});i(this,"_triggerUseLicense",e=>{const t=e.getHeader(jt);this._sessionEvents.trigger(Z,t)});i(this,"_handleNewInfo",e=>{const{originator:t}=e;if(t!=="remote")return;const{request:n}=e,s=n.getHeader(xt);if(s)switch(s){case $t:{this._triggerEnterRoom(n),this._maybeTriggerChannels(n);break}case an:{this._maybeHandleNotify(n);break}case q:{this._triggerShareState(n);break}case pe:{this._triggerMainCamControl(n);break}case Qt:{this._triggerMicControl(n);break}case Kt:{this._triggerUseLicense(n);break}}});i(this,"_handleSipEvent",({request:e})=>{this._maybeHandleNotify(e)});i(this,"_maybeHandleNotify",e=>{const t=e.getHeader(cn);if(t){const n=JSON.parse(t);this._handleNotify(n)}});i(this,"_handleEnded",e=>{const{originator:t}=e;t===Le&&this._sessionEvents.trigger(se,e),this._restoreSession()});this.JsSIP=e,this._sessionEvents=new Pe(Oe),this._uaEvents=new Pe(fe),this._cancelableConnect=new S.CancelableRequest(this._connect,{moduleName:N,afterCancelRequest:()=>{this._cancelableInitUa.cancelRequest(),this._cancelableDisconnect.cancelRequest()}}),this._cancelableInitUa=new S.CancelableRequest(this._initUa,{moduleName:N}),this._cancelableDisconnect=new S.CancelableRequest(this._disconnect,{moduleName:N}),this._cancelableSet=new S.CancelableRequest(this._set,{moduleName:N}),this._cancelableCall=new S.CancelableRequest(this._call,{moduleName:N}),this._cancelableAnswer=new S.CancelableRequest(this._answer,{moduleName:N}),this._cancelableSendDTMF=new S.CancelableRequest(this._sendDTMF,{moduleName:N}),this.onSession(P,this._handleShareState),this.onSession(Ae,this._handleNewInfo),this.on(J,this._handleSipEvent),this.onSession(C,this._handleEnded),this.onSession(O,this._handleEnded)}async register(){return new Promise((e,t)=>{this.isRegisterConfig&&this.ua?(this.ua.on(m,e),this.ua.on(f,t),this.ua.register()):t(new Error("Config is not registered"))})}async unregister(){return new Promise((e,t)=>{this.isRegistered&&this.ua?(this.ua.on(X,e),this.ua.unregister()):t(new Error("ua is not registered"))})}async sendOptions(e,t,n){if(!this.ua)throw new Error("is not connected");return new Promise((s,o)=>{try{this.ua.sendOptions(e,t,{extraHeaders:n,eventHandlers:{succeeded:()=>{s()},failed:o}})}catch(a){o(a)}})}async ping(e,t){var s;if(!((s=this.ua)!=null&&s.configuration.uri))throw new Error("is not connected");const n=this.ua.configuration.uri;return this.sendOptions(n,e,t)}async checkTelephony({userAgent:e,displayName:t,sipServerUrl:n,sipWebSocketServerURL:s,sdpSemantics:o}){return new Promise((a,c)=>{const E=ye(n),h=new this.JsSIP.WebSocketInterface(s),_=this._createUa({socket:h,displayName:t,sdpSemantics:o,userAgent:e,getSipServerUrl:E}),u=()=>{const d=new Error("Telephony is not available");c(d)};_.once(T,u);const l=()=>{_.removeAllListeners(),_.once(T,a),_.stop()};_.once(I,l),_.start()})}async replaceMediaStream(e,t){if(!this.session)throw new Error("No session established");return this.session.replaceMediaStream(e,t)}async askPermissionToEnableCam(e={}){if(!this.session)throw new Error("No session established");const t=[Tn];return this.session.sendInfo(pe,void 0,{noTerminateWhenError:!0,...e,extraHeaders:t}).catch(n=>{if(In(n))throw n})}get isPendingPresentation(){return!!this.promisePendingStartPresentation||!!this.promisePendingStopPresentation}async _sendPresentation(e,t,{maxBitrate:n,degradationPreference:s,isNeedReinvite:o=!0,isP2P:a=!1}){const c=k(t);this._streamPresentationCurrent=c;const E=a?[dn]:[En],h=e.sendInfo(q,void 0,{extraHeaders:E}).then(async()=>e.startPresentation(c,o,s)).then(async()=>{const{connection:_}=this;if(!_||n===void 0)return;const u=_.getSenders();await Pn(u,t,n)}).then(()=>t).catch(_=>{throw this._sessionEvents.trigger(y,_),_});return this.promisePendingStartPresentation=h,h.finally(()=>{this.promisePendingStartPresentation=void 0})}async startPresentation(e,{isNeedReinvite:t=!0,isP2P:n=!1,maxBitrate:s,degradationPreference:o}={}){const a=this.establishedSession;if(!a)throw new Error("No session established");if(this._streamPresentationCurrent)throw new Error("Presentation is already started");return this._sendPresentation(a,e,{isNeedReinvite:t,isP2P:n,maxBitrate:s,degradationPreference:o})}async stopPresentation({isP2P:e=!1}={}){const t=this._streamPresentationCurrent;let n=this.promisePendingStartPresentation??Promise.resolve();const s=e?[ln]:[_n],o=this.establishedSession;return o&&t&&(n=n.then(async()=>o.sendInfo(q,void 0,{extraHeaders:s})).then(async()=>o.stopPresentation(t)).catch(a=>{throw this._sessionEvents.trigger(y,a),a})),!o&&t&&this._sessionEvents.trigger(Re,t),this.promisePendingStopPresentation=n,n.finally(()=>{this._resetPresentation()})}async updatePresentation(e,{isP2P:t=!1,maxBitrate:n,degradationPreference:s}={}){const o=this.establishedSession;if(!o)throw new Error("No session established");if(!this._streamPresentationCurrent)throw new Error("Presentation has not started yet");return this.promisePendingStartPresentation&&await this.promisePendingStartPresentation,this._sendPresentation(o,e,{isP2P:t,maxBitrate:n,degradationPreference:s,isNeedReinvite:!1})}_resetPresentation(){delete this._streamPresentationCurrent,this.promisePendingStartPresentation=void 0,this.promisePendingStopPresentation=void 0}on(e,t){return this._uaEvents.on(e,t)}once(e,t){return this._uaEvents.once(e,t)}onceRace(e,t){return this._uaEvents.onceRace(e,t)}async wait(e){return this._uaEvents.wait(e)}off(e,t){this._uaEvents.off(e,t)}onSession(e,t){return this._sessionEvents.on(e,t)}onceSession(e,t){return this._sessionEvents.once(e,t)}onceRaceSession(e,t){return this._sessionEvents.onceRace(e,t)}async waitSession(e){return this._sessionEvents.wait(e)}offSession(e,t){this._sessionEvents.off(e,t)}isConfigured(){return!!this.ua}getConnectionConfiguration(){return{...this._connectionConfiguration}}getRemoteStreams(){if(!this.connection)return;const t=this.connection.getReceivers().map(({track:n})=>n);return An(t)?this._generateStreams(t):this._generateAudioStreams(t)}get connection(){var t;return(t=this.session)==null?void 0:t.connection}get remoteCallerData(){var e,t,n,s,o,a;return{displayName:(t=(e=this.incomingSession)==null?void 0:e.remote_identity)==null?void 0:t.display_name,host:(s=(n=this.incomingSession)==null?void 0:n.remote_identity)==null?void 0:s.uri.host,incomingNumber:(a=(o=this.incomingSession)==null?void 0:o.remote_identity)==null?void 0:a.uri.user,session:this.incomingSession}}get requested(){return this._cancelableConnect.requested||this._cancelableInitUa.requested||this._cancelableCall.requested||this._cancelableAnswer.requested}get establishedSession(){return this.session&&this.session.isEstablished()?this.session:void 0}get isRegistered(){return!!this.ua&&this.ua.isRegistered()}get isRegisterConfig(){return!!this.ua&&this._isRegisterConfig}get isCallActive(){return!!(this.ua&&this.session)}get isAvailableIncomingCall(){return!!this.incomingSession}_generateStream(e,t){const{id:n}=e,s=this._remoteStreams[n]||new MediaStream;return t&&s.addTrack(t),s.addTrack(e),this._remoteStreams[n]=s,s}_generateAudioStream(e){const{id:t}=e,n=this._remoteStreams[t]||new MediaStream;return n.addTrack(e),this._remoteStreams[t]=n,n}_generateStreams(e){const t=[];return e.forEach((n,s)=>{if(n.kind==="audio")return;const o=n,a=e[s-1];let c;a&&a.kind==="audio"&&(c=a);const E=this._generateStream(o,c);t.push(E)}),t}_generateAudioStreams(e){return e.map(n=>this._generateAudioStream(n))}_cancelRequests(){this._cancelActionsRequests(),this._cancelCallRequests(),this._cancelConnectRequests()}_cancelConnectRequests(){this._cancelableConnect.cancelRequest()}_cancelCallRequests(){this._cancelableCall.cancelRequest(),this._cancelableAnswer.cancelRequest()}_cancelActionsRequests(){this._cancelableAnswer.cancelRequest(),this._cancelableSendDTMF.cancelRequest()}async waitChannels(){return this.waitSession(p)}async waitSyncMediaState(){return this.waitSession(v)}async sendChannels({inputChannels:e,outputChannels:t}){if(!this.session)throw new Error("No session established");const n=`${ve}: ${e}`,s=`${be}: ${t}`,o=[n,s];return this.session.sendInfo(Xt,void 0,{extraHeaders:o})}async sendMediaState({cam:e,mic:t},n={}){if(!this.session)throw new Error("No session established");const s=`${nn}: currentstate`,o=`${rn}: ${Number(e)}`,a=`${on}: ${Number(t)}`,c=[s,o,a];return this.session.sendInfo(Jt,void 0,{noTerminateWhenError:!0,...n,extraHeaders:c})}async _sendRefusalToTurnOn(e,t={}){if(!this.session)throw new Error("No session established");const c=[`${sn}: ${e==="mic"?0:1}`];return this.session.sendInfo(zt,void 0,{noTerminateWhenError:!0,...t,extraHeaders:c})}async sendRefusalToTurnOnMic(e={}){if(!this.session)throw new Error("No session established");return this._sendRefusalToTurnOn("mic",{noTerminateWhenError:!0,...e})}async sendRefusalToTurnOnCam(e={}){if(!this.session)throw new Error("No session established");return this._sendRefusalToTurnOn("cam",{noTerminateWhenError:!0,...e})}}exports.BAD_MEDIA_DESCRIPTION=Fe;exports.EEventsMainCAM=A;exports.EEventsMic=U;exports.EEventsSyncMediaState=L;exports.EUseLicense=lt;exports.NOT_FOUND=qe;exports.REJECTED=V;exports.SESSION_EVENT_NAMES=Oe;exports.SipConnector=Yn;exports.UA_EVENT_NAMES=fe;exports.causes=Ft;exports.constants=Bt;exports.disableDebug=Nn;exports.enableDebug=Sn;exports.eventNames=Vt;exports.hasCanceledCallError=bn;exports.logger=W;exports.setEncodingsToSender=St;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnswerOptions, ExtraHeaders, HoldOptions,
|
|
1
|
+
import type { AnswerOptions, ExtraHeaders, HoldOptions, MediaStreamTypes, NameAddrHeader, OnHoldResult, RTCPeerConnectionDeprecated, RTCSession, ReferOptions, RenegotiateOptions, SessionDirection, SessionStatus, TerminateOptions, URI, C as constants } from '@krivega/jssip';
|
|
2
2
|
import Events from 'events-constructor';
|
|
3
3
|
import type { TEventSession } from '../eventNames';
|
|
4
4
|
import { SESSION_EVENT_NAMES } from '../eventNames';
|
|
@@ -42,9 +42,9 @@ declare class BaseSession implements RTCSession {
|
|
|
42
42
|
unhold(_options?: HoldOptions, _done?: VoidFunction): boolean;
|
|
43
43
|
renegotiate(_options?: RenegotiateOptions, _done?: VoidFunction): Promise<boolean>;
|
|
44
44
|
isOnHold(): OnHoldResult;
|
|
45
|
-
mute(_options?:
|
|
46
|
-
unmute(_options?:
|
|
47
|
-
isMuted():
|
|
45
|
+
mute(_options?: MediaStreamConstraints): void;
|
|
46
|
+
unmute(_options?: MediaStreamConstraints): void;
|
|
47
|
+
isMuted(): MediaStreamTypes;
|
|
48
48
|
refer(_target: URI | string, _options?: ReferOptions): void;
|
|
49
49
|
resetLocalMedia(): void;
|
|
50
50
|
replaceMediaStream(_stream: MediaStream, _options?: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="jest" />
|
|
2
|
-
import type { UA as IUA, IncomingRequest, UAConfiguration } from '@krivega/jssip';
|
|
2
|
+
import type { UA as IUA, IncomingRequest, UAConfiguration, UAConfigurationParams } from '@krivega/jssip';
|
|
3
3
|
import Events from 'events-constructor';
|
|
4
4
|
import type { TEventUA } from '../eventNames';
|
|
5
5
|
import { UA_EVENT_NAMES } from '../eventNames';
|
|
@@ -20,7 +20,7 @@ declare class UA implements IUA {
|
|
|
20
20
|
_isConnected?: boolean;
|
|
21
21
|
configuration: UAConfiguration;
|
|
22
22
|
_registrator: Registrator;
|
|
23
|
-
constructor(
|
|
23
|
+
constructor(_configuration: UAConfigurationParams);
|
|
24
24
|
/**
|
|
25
25
|
* start
|
|
26
26
|
*
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { URI } from '@krivega/jssip';
|
|
1
2
|
export declare const user = "user";
|
|
2
3
|
export declare const displayName = "displayName";
|
|
3
4
|
export declare const SIP_SERVER_URL = "SIP_SERVER_URL";
|
|
@@ -33,7 +34,7 @@ export declare const dataForConnectionWithoutAuthorization: {
|
|
|
33
34
|
};
|
|
34
35
|
export declare const uaConfigurationWithAuthorization: {
|
|
35
36
|
password: string;
|
|
36
|
-
uri:
|
|
37
|
+
uri: URI;
|
|
37
38
|
display_name: string;
|
|
38
39
|
register: boolean;
|
|
39
40
|
session_timers: boolean;
|
|
@@ -46,7 +47,7 @@ export declare const uaConfigurationWithAuthorization: {
|
|
|
46
47
|
};
|
|
47
48
|
export declare const uaConfigurationWithAuthorizationWithDisplayName: {
|
|
48
49
|
password: string;
|
|
49
|
-
uri:
|
|
50
|
+
uri: URI;
|
|
50
51
|
display_name: string;
|
|
51
52
|
register: boolean;
|
|
52
53
|
session_timers: boolean;
|
package/dist/doMock.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var D=Object.defineProperty;var k=(r,e,t)=>e in r?D(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var n=(r,e,t)=>(k(r,typeof e!="symbol"?e+"":e,t),t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("./SipConnector-Q7QLgdlo.cjs"),L=require("@krivega/jssip/lib/NameAddrHeader"),P=require("@krivega/jssip/lib/URI"),x=require("node:events"),F=require("@krivega/jssip/lib/SIPMessage"),M=require("events-constructor");require("@krivega/cancelable-promise");require("debug");class T extends F.IncomingRequest{constructor(t){super();n(this,"headers");this.headers=new Headers(t)}getHeader(t){return this.headers.get(t)||""}}var V=Object.defineProperty,z=(r,e,t)=>e in r?V(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,s=(r,e,t)=>(z(r,typeof e!="symbol"?e+"":e,t),t);const m="ended",q="mute",U="isolationchange",H="overconstrained",j="unmute",$=[m,q,j,U,H];class y{constructor(e,{id:t="identifier",constraints:i={}}={}){s(this,"events"),s(this,"id"),s(this,"kind"),s(this,"constraints"),s(this,"enabled"),s(this,"contentHint",""),s(this,"readyState","live"),s(this,"isolated",!1),s(this,"label",""),s(this,"muted",!1),s(this,"onended",null),s(this,"onisolationchange",null),s(this,"onmute",null),s(this,"onunmute",null),s(this,"getConstraints",()=>this.constraints),s(this,"stop",()=>{const o={...new Event(m)};this.events.trigger(m,o),this.readyState=m,this.onended&&this.onended(o)}),s(this,"addEventListener",(o,a)=>{this.events.on(o,a)}),s(this,"removeEventListener",(o,a)=>{this.events.off(o,a)}),this.id=`${t}-${e}-track`,this.kind=e,this.enabled=!0,this.constraints={...i},this.events=new M($)}clone(){return{...this}}getCapabilities(){return{width:{min:352,max:4096},height:{min:288,max:2160}}}getSettings(){let e=0,t=0;return typeof this.constraints.width=="object"&&this.constraints.width.ideal!==void 0?e=this.constraints.width.ideal:typeof this.constraints.width=="object"&&this.constraints.width.exact!==void 0?e=this.constraints.width.exact:typeof this.constraints.width=="number"&&this.constraints.width&&(e=this.constraints.width),typeof this.constraints.height=="object"&&this.constraints.height.ideal!==void 0?t=this.constraints.height.ideal:typeof this.constraints.height=="object"&&this.constraints.height.exact!==void 0?t=this.constraints.height.exact:typeof this.constraints.height=="number"&&this.constraints.height&&(t=this.constraints.height),{width:e,height:t}}async applyConstraints(e){this.constraints={...e}}dispatchEvent(e){const t=e.type;return this.events.trigger(t,e),!0}}const B=r=>new y("audio",r),K=r=>new y("video",r);class Y{constructor({originator:e="local",eventHandlers:t}){n(this,"originator");n(this,"_connection");n(this,"_events");n(this,"_remote_identity");n(this,"_mutedOptions",{audio:!1,video:!1});this.originator=e,this._events=new M(l.SESSION_EVENT_NAMES),this.initEvents(t)}get C(){throw new Error("Method not implemented.")}get causes(){throw new Error("Method not implemented.")}get id(){throw new Error("Method not implemented.")}set data(e){throw new Error("Method not implemented.")}get data(){throw new Error("Method not implemented.")}get connection(){return this._connection}get contact(){throw new Error("Method not implemented.")}get direction(){throw new Error("Method not implemented.")}get local_identity(){throw new Error("Method not implemented.")}get remote_identity(){return this._remote_identity}get start_time(){throw new Error("Method not implemented.")}get end_time(){throw new Error("Method not implemented.")}get status(){throw new Error("Method not implemented.")}isInProgress(){throw new Error("Method not implemented.")}isEnded(){throw new Error("Method not implemented.")}isReadyToReOffer(){throw new Error("Method not implemented.")}answer(e){throw new Error("Method not implemented.")}terminate(e){throw new Error("Method not implemented.")}async sendInfo(e,t,i){throw new Error("Method not implemented.")}hold(e,t){throw new Error("Method not implemented.")}unhold(e,t){throw new Error("Method not implemented.")}async renegotiate(e,t){throw new Error("Method not implemented.")}isOnHold(){throw new Error("Method not implemented.")}mute(e){throw new Error("Method not implemented.")}unmute(e){throw new Error("Method not implemented.")}isMuted(){throw new Error("Method not implemented.")}refer(e,t){throw new Error("Method not implemented.")}resetLocalMedia(){throw new Error("Method not implemented.")}async replaceMediaStream(e,t){throw new Error("Method not implemented.")}addListener(e,t){throw new Error("Method not implemented.")}once(e,t){throw new Error("Method not implemented.")}removeListener(e,t){throw new Error("Method not implemented.")}off(e,t){throw new Error("Method not implemented.")}removeAllListeners(e){throw new Error("Method not implemented.")}setMaxListeners(e){throw new Error("Method not implemented.")}getMaxListeners(){throw new Error("Method not implemented.")}listeners(e){throw new Error("Method not implemented.")}rawListeners(e){throw new Error("Method not implemented.")}emit(e,...t){throw new Error("Method not implemented.")}listenerCount(e){throw new Error("Method not implemented.")}prependListener(e,t){throw new Error("Method not implemented.")}prependOnceListener(e,t){throw new Error("Method not implemented.")}eventNames(){throw new Error("Method not implemented.")}initEvents(e=[]){Object.entries(e).forEach(([t,i])=>this.on(t,i))}on(e,t){return this._events.on(e,t),this}trigger(e,t){this._events.trigger(e,t)}sendDTMF(){this.trigger("newDTMF",{originator:this.originator})}async startPresentation(e){return e}async updatePresentation(e){return e}async stopPresentation(e){return e}isEstablished(){return!0}}class J{constructor(e,t){n(this,"_senders",[]);n(this,"_receivers",[]);n(this,"canTrickleIceCandidates");n(this,"connectionState");n(this,"currentLocalDescription");n(this,"currentRemoteDescription");n(this,"iceConnectionState");n(this,"iceGatheringState");n(this,"idpErrorInfo");n(this,"idpLoginUrl");n(this,"localDescription");n(this,"onconnectionstatechange");n(this,"ondatachannel");n(this,"onicecandidate");n(this,"onicecandidateerror",null);n(this,"oniceconnectionstatechange");n(this,"onicegatheringstatechange");n(this,"onnegotiationneeded");n(this,"onsignalingstatechange");n(this,"ontrack");n(this,"peerIdentity");n(this,"pendingLocalDescription");n(this,"pendingRemoteDescription");n(this,"remoteDescription");n(this,"sctp",null);n(this,"signalingState");n(this,"getReceivers",()=>this._receivers);n(this,"getSenders",()=>this._senders);n(this,"addTrack",e=>{const t={track:e};return this._senders.push(t),t});this._receivers=t.map(i=>({track:i}))}getRemoteStreams(){throw new Error("Method not implemented.")}async addIceCandidate(e){throw new Error("Method not implemented.")}addTransceiver(e,t){throw new Error("Method not implemented.")}close(){throw new Error("Method not implemented.")}restartIce(){throw new Error("Method not implemented.")}async createAnswer(e,t){throw new Error("Method not implemented.")}createDataChannel(e,t){throw new Error("Method not implemented.")}async createOffer(e,t,i){throw new Error("Method not implemented.")}getConfiguration(){throw new Error("Method not implemented.")}async getIdentityAssertion(){throw new Error("Method not implemented.")}async getStats(e){throw new Error("Method not implemented.")}getTransceivers(){throw new Error("Method not implemented.")}removeTrack(e){throw new Error("Method not implemented.")}setConfiguration(e){throw new Error("Method not implemented.")}async setLocalDescription(e){throw new Error("Method not implemented.")}async setRemoteDescription(e){throw new Error("Method not implemented.")}addEventListener(e,t,i){throw new Error("Method not implemented.")}removeEventListener(e,t,i){throw new Error("Method not implemented.")}dispatchEvent(e){throw new Error("Method not implemented.")}}function G(r){const e=r.match(/[\d.]+/g);if(!e)throw new Error("wrong sip url");return e[0]}const w=400,A="777",X=r=>r.getVideoTracks().length>0;class b extends Y{constructor({url:t="",mediaStream:i,eventHandlers:o,originator:a}){super({originator:a,eventHandlers:o});n(this,"url");n(this,"status_code");n(this,"_isEnded",!1);n(this,"answer",jest.fn(({mediaStream:t})=>{if(this.originator!=="remote")throw new Error("answer available only for remote sessions");this.initPeerconnection(t),setTimeout(()=>{this.trigger("connecting"),setTimeout(()=>{this.trigger("accepted")},100),setTimeout(()=>{this.trigger("confirmed")},200)},w)}));this.url=t,this.initPeerconnection(i)}initPeerconnection(t){return t?(this.createPeerconnection(t),!0):!1}createPeerconnection(t){const i=B();i.id="mainaudio1";const o=[i];if(X(t)){const S=K();S.id="mainvideo1",o.push(S)}this._connection=new J(void 0,o),this._addStream(t),setTimeout(()=>{this.trigger("peerconnection",{peerconnection:this.connection})},w)}connect(t){const i=G(t);setTimeout(()=>{this.url.includes(A)?this.trigger("failed",{originator:"remote",message:"IncomingResponse",cause:l.REJECTED}):(this.trigger("connecting"),setTimeout(()=>{this.trigger("enterRoom",i)},100),setTimeout(()=>{this.trigger("accepted")},200),setTimeout(()=>{this.trigger("confirmed")},300))},w)}terminate({status_code:t}={}){return this.status_code=t,this.trigger("ended",{status_code:t}),this._isEnded=!1,this}terminateRemote({status_code:t}={}){return this.status_code=t,this.trigger("ended",{status_code:t,originator:"remote"}),this}_addStream(t,i="getTracks"){t[i]().forEach(o=>this.connection.addTrack(o))}_forEachSenders(t){const i=this.connection.getSenders();for(const o of i)t(o);return i}_toggleMuteAudio(t){this._forEachSenders(({track:i})=>{i&&i.kind==="audio"&&(i.enabled=!t)})}_toggleMuteVideo(t){this._forEachSenders(({track:i})=>{i&&i.kind==="video"&&(i.enabled=!t)})}mute(t){t.audio&&(this._mutedOptions.audio=!0,this._toggleMuteAudio(this._mutedOptions.audio)),t.video&&(this._mutedOptions.video=!0,this._toggleMuteVideo(this._mutedOptions.video)),this._onmute(t)}unmute(t){t.audio&&(this._mutedOptions.audio=!1),t.video&&(this._mutedOptions.video=!1),this.trigger("unmuted",t)}isMuted(){return this._mutedOptions}async replaceMediaStream(t){return t}_onmute({audio:t,video:i}){this.trigger("muted",{audio:t,video:i})}async sendInfo(){}isEnded(){return this._isEnded}newInfo(t){this.trigger("newInfo",t)}}class Q{constructor(){n(this,"extraHeaders")}setExtraHeaders(e){this.extraHeaders=e}setExtraContactParams(){}}const d="PASSWORD_CORRECT",E="PASSWORD_CORRECT_2",I="NAME_INCORRECT",c=400,u=class u{constructor(e){n(this,"_events");n(this,"_startedTimeout");n(this,"_stopedTimeout");n(this,"session");n(this,"_isRegistered");n(this,"_isConnected");n(this,"configuration");n(this,"_registrator");n(this,"call",jest.fn((e,t)=>{const{mediaStream:i,eventHandlers:o}=t;return this.session=new b({url:e,mediaStream:i,eventHandlers:o,originator:"local"}),this.session.connect(e),this.session}));this._events=new M(l.UA_EVENT_NAMES),this.configuration=e,this._registrator=new Q}static setAvailableTelephony(){this.isAvailableTelephony=!0}static setNotAvailableTelephony(){this.isAvailableTelephony=!1}start(){this.register()}stop(){this._startedTimeout&&clearTimeout(this._startedTimeout),this._stopedTimeout&&clearTimeout(this._stopedTimeout),this.unregister(),this.isStarted()?this._stopedTimeout=setTimeout(()=>{this.trigger("disconnected",{error:new Error("stoped")})},c):this.trigger("disconnected",{error:new Error("stoped")})}on(e,t){return this._events.on(e,t),this}once(e,t){return this._events.once(e,t),this}off(e,t){return this._events.off(e,t),this}removeAllListeners(){return this._events.removeEventHandlers(),this}trigger(e,t){this._events.trigger(e,t)}terminateSessions(){this.session.terminate()}set(e,t){return this.configuration[e]=t,!0}register(){this._startedTimeout&&clearTimeout(this._startedTimeout);const{password:e,register:t,uri:i}=this.configuration;t&&i.includes(I)?(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Request Timeout"})},c)):!this._isRegistered&&t&&(e===d||e===E)?(this._isRegistered=!0,this._startedTimeout=setTimeout(()=>{this.trigger("registered")},c)):t&&e!==d&&e!==E&&(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Wrong credentials"})},c)),u.isAvailableTelephony?(this.trigger("connected"),this._isConnected=!0):this.stop()}unregister(){this._isRegistered=!1,this._isConnected=!1,this.trigger("unregistered")}isRegistered(){return!!this._isRegistered}isStarted(){return this.configuration&&(this.configuration.register&&!!this._isRegistered||!this.configuration.register&&!!this._isConnected)}registrator(){return this._registrator}newSipEvent(e){this.trigger("sipEvent",e)}};n(u,"isAvailableTelephony",!0);let f=u;class Z{constructor(e){n(this,"url");this.url=e}}class ee extends x.EventEmitter{constructor(t,i){super();n(this,"contentType");n(this,"body");this.contentType=t,this.body=i}}const v="remote",te=(r,e)=>{const t=new T(e),i={originator:v,request:t,info:new ee("","")};r.newInfo(i)},ne=(r,e)=>{const i={request:new T(e)};r.newSipEvent(i)},ie=(r,{incomingNumber:e="1234",displayName:t,host:i})=>{const o=new b({originator:v}),a=new P("sip",e,i);o._remote_identity=new L(a,t),r.trigger("newRTCSession",{originator:v,session:o})},re=(r,e)=>{e?r.trigger("failed",e):r.trigger("failed",r)},O={triggerNewInfo:te,triggerNewSipEvent:ne,triggerIncomingSession:ie,triggerFailIncomingSession:re,WebSocketInterface:Z,UA:f,C:{INVITE:"INVITE"}},g="user",h="displayName",_="SIP_SERVER_URL",C="SIP_WEB_SOCKET_SERVER_URL",oe=new O.WebSocketInterface(C),R={userAgent:"Chrome",sipServerUrl:_,sipWebSocketServerURL:C},se={...R},N={...R,user:g,password:d,register:!0},ae={...N,displayName:h},de={...R,displayName:h,register:!1},p={session_timers:!1,sockets:[oe],user_agent:"Chrome",sdp_semantics:"plan-b",register_expires:300,connection_recovery_max_interval:6,connection_recovery_min_interval:2},he={...p,password:d,uri:`sip:${g}@${_}`,display_name:"",register:!0},ce={...p,password:d,uri:`sip:${g}@${_}`,display_name:h,register:!0},me={...p,display_name:h,register:!1},ue={...p,display_name:"",register:!1},W="10.10.10.10",le=[`X-Vinteo-Remote: ${W}`],ge=()=>new l.SipConnector({JsSIP:O});exports.FAILED_CONFERENCE_NUMBER=A;exports.NAME_INCORRECT=I;exports.PASSWORD_CORRECT=d;exports.PASSWORD_CORRECT_2=E;exports.SIP_SERVER_URL=_;exports.SIP_WEB_SOCKET_SERVER_URL=C;exports.dataForConnectionWithAuthorization=N;exports.dataForConnectionWithAuthorizationWithDisplayName=ae;exports.dataForConnectionWithoutAuthorization=de;exports.dataForConnectionWithoutAuthorizationWithoutDisplayName=se;exports.default=ge;exports.displayName=h;exports.extraHeadersRemoteAddress=le;exports.remoteAddress=W;exports.uaConfigurationWithAuthorization=he;exports.uaConfigurationWithAuthorizationWithDisplayName=ce;exports.uaConfigurationWithoutAuthorization=me;exports.uaConfigurationWithoutAuthorizationWithoutDisplayName=ue;exports.user=g;
|
|
1
|
+
"use strict";var k=Object.defineProperty;var L=(r,e,t)=>e in r?k(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var n=(r,e,t)=>(L(r,typeof e!="symbol"?e+"":e,t),t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("./SipConnector-eRr2JbY9.cjs"),P=require("@krivega/jssip/lib/NameAddrHeader"),x=require("@krivega/jssip/lib/URI"),F=require("node:events"),U=require("@krivega/jssip/lib/SIPMessage"),R=require("events-constructor"),C=require("@krivega/jssip");class y extends U.IncomingRequest{constructor(t){super();n(this,"headers");this.headers=new Headers(t)}getHeader(t){return this.headers.get(t)||""}}var V=Object.defineProperty,z=(r,e,t)=>e in r?V(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,s=(r,e,t)=>(z(r,typeof e!="symbol"?e+"":e,t),t);const m="ended",q="mute",H="isolationchange",j="overconstrained",B="unmute",$=[m,q,B,H,j];class A{constructor(e,{id:t="identifier",constraints:i={}}={}){s(this,"events"),s(this,"id"),s(this,"kind"),s(this,"constraints"),s(this,"enabled"),s(this,"contentHint",""),s(this,"readyState","live"),s(this,"isolated",!1),s(this,"label",""),s(this,"muted",!1),s(this,"onended",null),s(this,"onisolationchange",null),s(this,"onmute",null),s(this,"onunmute",null),s(this,"getConstraints",()=>this.constraints),s(this,"stop",()=>{const o={...new Event(m)};this.events.trigger(m,o),this.readyState=m,this.onended&&this.onended(o)}),s(this,"addEventListener",(o,a)=>{this.events.on(o,a)}),s(this,"removeEventListener",(o,a)=>{this.events.off(o,a)}),this.id=`${t}-${e}-track`,this.kind=e,this.enabled=!0,this.constraints={...i},this.events=new R($)}clone(){return{...this}}getCapabilities(){return{width:{min:352,max:4096},height:{min:288,max:2160}}}getSettings(){let e=0,t=0;return typeof this.constraints.width=="object"&&this.constraints.width.ideal!==void 0?e=this.constraints.width.ideal:typeof this.constraints.width=="object"&&this.constraints.width.exact!==void 0?e=this.constraints.width.exact:typeof this.constraints.width=="number"&&this.constraints.width&&(e=this.constraints.width),typeof this.constraints.height=="object"&&this.constraints.height.ideal!==void 0?t=this.constraints.height.ideal:typeof this.constraints.height=="object"&&this.constraints.height.exact!==void 0?t=this.constraints.height.exact:typeof this.constraints.height=="number"&&this.constraints.height&&(t=this.constraints.height),{width:e,height:t}}async applyConstraints(e){this.constraints={...e}}dispatchEvent(e){const t=e.type;return this.events.trigger(t,e),!0}}const K=r=>new A("audio",r),Y=r=>new A("video",r);class J{constructor({originator:e="local",eventHandlers:t}){n(this,"originator");n(this,"_connection");n(this,"_events");n(this,"_remote_identity");n(this,"_mutedOptions",{audio:!1,video:!1});this.originator=e,this._events=new R(g.SESSION_EVENT_NAMES),this.initEvents(t)}get C(){throw new Error("Method not implemented.")}get causes(){throw new Error("Method not implemented.")}get id(){throw new Error("Method not implemented.")}set data(e){throw new Error("Method not implemented.")}get data(){throw new Error("Method not implemented.")}get connection(){return this._connection}get contact(){throw new Error("Method not implemented.")}get direction(){throw new Error("Method not implemented.")}get local_identity(){throw new Error("Method not implemented.")}get remote_identity(){return this._remote_identity}get start_time(){throw new Error("Method not implemented.")}get end_time(){throw new Error("Method not implemented.")}get status(){throw new Error("Method not implemented.")}isInProgress(){throw new Error("Method not implemented.")}isEnded(){throw new Error("Method not implemented.")}isReadyToReOffer(){throw new Error("Method not implemented.")}answer(e){throw new Error("Method not implemented.")}terminate(e){throw new Error("Method not implemented.")}async sendInfo(e,t,i){throw new Error("Method not implemented.")}hold(e,t){throw new Error("Method not implemented.")}unhold(e,t){throw new Error("Method not implemented.")}async renegotiate(e,t){throw new Error("Method not implemented.")}isOnHold(){throw new Error("Method not implemented.")}mute(e){throw new Error("Method not implemented.")}unmute(e){throw new Error("Method not implemented.")}isMuted(){throw new Error("Method not implemented.")}refer(e,t){throw new Error("Method not implemented.")}resetLocalMedia(){throw new Error("Method not implemented.")}async replaceMediaStream(e,t){throw new Error("Method not implemented.")}addListener(e,t){throw new Error("Method not implemented.")}once(e,t){throw new Error("Method not implemented.")}removeListener(e,t){throw new Error("Method not implemented.")}off(e,t){throw new Error("Method not implemented.")}removeAllListeners(e){throw new Error("Method not implemented.")}setMaxListeners(e){throw new Error("Method not implemented.")}getMaxListeners(){throw new Error("Method not implemented.")}listeners(e){throw new Error("Method not implemented.")}rawListeners(e){throw new Error("Method not implemented.")}emit(e,...t){throw new Error("Method not implemented.")}listenerCount(e){throw new Error("Method not implemented.")}prependListener(e,t){throw new Error("Method not implemented.")}prependOnceListener(e,t){throw new Error("Method not implemented.")}eventNames(){throw new Error("Method not implemented.")}initEvents(e=[]){Object.entries(e).forEach(([t,i])=>this.on(t,i))}on(e,t){return this._events.on(e,t),this}trigger(e,t){this._events.trigger(e,t)}sendDTMF(){this.trigger("newDTMF",{originator:this.originator})}async startPresentation(e){return e}async updatePresentation(e){return e}async stopPresentation(e){return e}isEstablished(){return!0}}class G{constructor(e,t){n(this,"_senders",[]);n(this,"_receivers",[]);n(this,"canTrickleIceCandidates");n(this,"connectionState");n(this,"currentLocalDescription");n(this,"currentRemoteDescription");n(this,"iceConnectionState");n(this,"iceGatheringState");n(this,"idpErrorInfo");n(this,"idpLoginUrl");n(this,"localDescription");n(this,"onconnectionstatechange");n(this,"ondatachannel");n(this,"onicecandidate");n(this,"onicecandidateerror",null);n(this,"oniceconnectionstatechange");n(this,"onicegatheringstatechange");n(this,"onnegotiationneeded");n(this,"onsignalingstatechange");n(this,"ontrack");n(this,"peerIdentity");n(this,"pendingLocalDescription");n(this,"pendingRemoteDescription");n(this,"remoteDescription");n(this,"sctp",null);n(this,"signalingState");n(this,"getReceivers",()=>this._receivers);n(this,"getSenders",()=>this._senders);n(this,"addTrack",e=>{const t={track:e};return this._senders.push(t),t});this._receivers=t.map(i=>({track:i}))}getRemoteStreams(){throw new Error("Method not implemented.")}async addIceCandidate(e){throw new Error("Method not implemented.")}addTransceiver(e,t){throw new Error("Method not implemented.")}close(){throw new Error("Method not implemented.")}restartIce(){throw new Error("Method not implemented.")}async createAnswer(e,t){throw new Error("Method not implemented.")}createDataChannel(e,t){throw new Error("Method not implemented.")}async createOffer(e,t,i){throw new Error("Method not implemented.")}getConfiguration(){throw new Error("Method not implemented.")}async getIdentityAssertion(){throw new Error("Method not implemented.")}async getStats(e){throw new Error("Method not implemented.")}getTransceivers(){throw new Error("Method not implemented.")}removeTrack(e){throw new Error("Method not implemented.")}setConfiguration(e){throw new Error("Method not implemented.")}async setLocalDescription(e){throw new Error("Method not implemented.")}async setRemoteDescription(e){throw new Error("Method not implemented.")}addEventListener(e,t,i){throw new Error("Method not implemented.")}removeEventListener(e,t,i){throw new Error("Method not implemented.")}dispatchEvent(e){throw new Error("Method not implemented.")}}function X(r){const e=r.match(/[\d.]+/g);if(!e)throw new Error("wrong sip url");return e[0]}const E=400,I="777",Q=r=>r.getVideoTracks().length>0;class b extends J{constructor({url:t="",mediaStream:i,eventHandlers:o,originator:a}){super({originator:a,eventHandlers:o});n(this,"url");n(this,"status_code");n(this,"_isEnded",!1);n(this,"answer",jest.fn(({mediaStream:t})=>{if(this.originator!=="remote")throw new Error("answer available only for remote sessions");this.initPeerconnection(t),setTimeout(()=>{this.trigger("connecting"),setTimeout(()=>{this.trigger("accepted")},100),setTimeout(()=>{this.trigger("confirmed")},200)},E)}));this.url=t,this.initPeerconnection(i)}initPeerconnection(t){return t?(this.createPeerconnection(t),!0):!1}createPeerconnection(t){const i=K();i.id="mainaudio1";const o=[i];if(Q(t)){const c=Y();c.id="mainvideo1",o.push(c)}this._connection=new G(void 0,o),this._addStream(t),setTimeout(()=>{this.trigger("peerconnection",{peerconnection:this.connection})},E)}connect(t){const i=X(t);setTimeout(()=>{this.url.includes(I)?this.trigger("failed",{originator:"remote",message:"IncomingResponse",cause:g.REJECTED}):(this.trigger("connecting"),setTimeout(()=>{this.trigger("enterRoom",i)},100),setTimeout(()=>{this.trigger("accepted")},200),setTimeout(()=>{this.trigger("confirmed")},300))},E)}terminate({status_code:t}={}){return this.status_code=t,this.trigger("ended",{status_code:t}),this._isEnded=!1,this}terminateRemote({status_code:t}={}){return this.status_code=t,this.trigger("ended",{status_code:t,originator:"remote"}),this}_addStream(t,i="getTracks"){t[i]().forEach(o=>this.connection.addTrack(o))}_forEachSenders(t){const i=this.connection.getSenders();for(const o of i)t(o);return i}_toggleMuteAudio(t){this._forEachSenders(({track:i})=>{i&&i.kind==="audio"&&(i.enabled=!t)})}_toggleMuteVideo(t){this._forEachSenders(({track:i})=>{i&&i.kind==="video"&&(i.enabled=!t)})}mute(t){t.audio&&(this._mutedOptions.audio=!0,this._toggleMuteAudio(this._mutedOptions.audio)),t.video&&(this._mutedOptions.video=!0,this._toggleMuteVideo(this._mutedOptions.video)),this._onmute(t)}unmute(t){t.audio&&(this._mutedOptions.audio=!1),t.video&&(this._mutedOptions.video=!1),this.trigger("unmuted",t)}isMuted(){return this._mutedOptions}async replaceMediaStream(t){return t}_onmute({audio:t,video:i}){this.trigger("muted",{audio:t,video:i})}async sendInfo(){}isEnded(){return this._isEnded}newInfo(t){this.trigger("newInfo",t)}}class Z{constructor(){n(this,"extraHeaders")}setExtraHeaders(e){this.extraHeaders=e}setExtraContactParams(){}}const d="PASSWORD_CORRECT",f="PASSWORD_CORRECT_2",O="NAME_INCORRECT",u=400,l=class l{constructor(e){n(this,"_events");n(this,"_startedTimeout");n(this,"_stopedTimeout");n(this,"session");n(this,"_isRegistered");n(this,"_isConnected");n(this,"configuration");n(this,"_registrator");n(this,"call",jest.fn((e,t)=>{const{mediaStream:i,eventHandlers:o}=t;return this.session=new b({url:e,mediaStream:i,eventHandlers:o,originator:"local"}),this.session.connect(e),this.session}));this._events=new R(g.UA_EVENT_NAMES);const[t,i]=e.uri.split(":"),[o,a]=i.split("@"),c={...e,uri:new C.URI(t,o,a)};this.configuration=c,this._registrator=new Z}static setAvailableTelephony(){this.isAvailableTelephony=!0}static setNotAvailableTelephony(){this.isAvailableTelephony=!1}start(){this.register()}stop(){this._startedTimeout&&clearTimeout(this._startedTimeout),this._stopedTimeout&&clearTimeout(this._stopedTimeout),this.unregister(),this.isStarted()?this._stopedTimeout=setTimeout(()=>{this.trigger("disconnected",{error:new Error("stoped")})},u):this.trigger("disconnected",{error:new Error("stoped")})}on(e,t){return this._events.on(e,t),this}once(e,t){return this._events.once(e,t),this}off(e,t){return this._events.off(e,t),this}removeAllListeners(){return this._events.removeEventHandlers(),this}trigger(e,t){this._events.trigger(e,t)}terminateSessions(){this.session.terminate()}set(e,t){return this.configuration[e]=t,!0}register(){this._startedTimeout&&clearTimeout(this._startedTimeout);const{password:e,register:t,uri:i}=this.configuration;t&&i.user.includes(O)?(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Request Timeout"})},u)):!this._isRegistered&&t&&(e===d||e===f)?(this._isRegistered=!0,this._startedTimeout=setTimeout(()=>{this.trigger("registered")},u)):t&&e!==d&&e!==f&&(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Wrong credentials"})},u)),l.isAvailableTelephony?(this.trigger("connected"),this._isConnected=!0):this.stop()}unregister(){this._isRegistered=!1,this._isConnected=!1,this.trigger("unregistered")}isRegistered(){return!!this._isRegistered}isStarted(){return this.configuration&&(this.configuration.register&&!!this._isRegistered||!this.configuration.register&&!!this._isConnected)}registrator(){return this._registrator}newSipEvent(e){this.trigger("sipEvent",e)}};n(l,"isAvailableTelephony",!0);let v=l;class ee{constructor(e){n(this,"url");this.url=e}}class te extends F.EventEmitter{constructor(t,i){super();n(this,"contentType");n(this,"body");this.contentType=t,this.body=i}}const M="remote",ne=(r,e)=>{const t=new y(e),i={originator:M,request:t,info:new te("","")};r.newInfo(i)},ie=(r,e)=>{const i={request:new y(e)};r.newSipEvent(i)},re=(r,{incomingNumber:e="1234",displayName:t,host:i})=>{const o=new b({originator:M}),a=new x("sip",e,i);o._remote_identity=new P(a,t),r.trigger("newRTCSession",{originator:M,session:o})},oe=(r,e)=>{e?r.trigger("failed",e):r.trigger("failed",r)},N={triggerNewInfo:ne,triggerNewSipEvent:ie,triggerIncomingSession:re,triggerFailIncomingSession:oe,WebSocketInterface:ee,UA:v,C:{INVITE:"INVITE"}},_="user",h="displayName",p="SIP_SERVER_URL",S="SIP_WEB_SOCKET_SERVER_URL",se=new N.WebSocketInterface(S),T={userAgent:"Chrome",sipServerUrl:p,sipWebSocketServerURL:S},ae={...T},W={...T,user:_,password:d,register:!0},de={...W,displayName:h},he={...T,displayName:h,register:!1},w={session_timers:!1,sockets:[se],user_agent:"Chrome",sdp_semantics:"plan-b",register_expires:300,connection_recovery_max_interval:6,connection_recovery_min_interval:2},ce={...w,password:d,uri:new C.URI("sip",_,p),display_name:"",register:!0},ue={...w,password:d,uri:new C.URI("sip",_,p),display_name:h,register:!0},me={...w,display_name:h,register:!1},le={...w,display_name:"",register:!1},D="10.10.10.10",ge=[`X-Vinteo-Remote: ${D}`],_e=()=>new g.SipConnector({JsSIP:N});exports.FAILED_CONFERENCE_NUMBER=I;exports.NAME_INCORRECT=O;exports.PASSWORD_CORRECT=d;exports.PASSWORD_CORRECT_2=f;exports.SIP_SERVER_URL=p;exports.SIP_WEB_SOCKET_SERVER_URL=S;exports.dataForConnectionWithAuthorization=W;exports.dataForConnectionWithAuthorizationWithDisplayName=de;exports.dataForConnectionWithoutAuthorization=he;exports.dataForConnectionWithoutAuthorizationWithoutDisplayName=ae;exports.default=_e;exports.displayName=h;exports.extraHeadersRemoteAddress=ge;exports.remoteAddress=D;exports.uaConfigurationWithAuthorization=ce;exports.uaConfigurationWithAuthorizationWithDisplayName=ue;exports.uaConfigurationWithoutAuthorization=me;exports.uaConfigurationWithoutAuthorizationWithoutDisplayName=le;exports.user=_;
|
package/dist/doMock.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var n = (i, e, t) => (
|
|
4
|
-
import { j as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { EventEmitter as
|
|
8
|
-
import { IncomingRequest as
|
|
9
|
-
import
|
|
10
|
-
import "@krivega/
|
|
11
|
-
|
|
12
|
-
class y extends x {
|
|
1
|
+
var A = Object.defineProperty;
|
|
2
|
+
var O = (i, e, t) => e in i ? A(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
|
+
var n = (i, e, t) => (O(i, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
import { j as k, R as N, U as L, S as D } from "./SipConnector-1HoiCnsj.js";
|
|
5
|
+
import W from "@krivega/jssip/lib/NameAddrHeader";
|
|
6
|
+
import P from "@krivega/jssip/lib/URI";
|
|
7
|
+
import { EventEmitter as x } from "node:events";
|
|
8
|
+
import { IncomingRequest as V } from "@krivega/jssip/lib/SIPMessage";
|
|
9
|
+
import E from "events-constructor";
|
|
10
|
+
import { URI as f } from "@krivega/jssip";
|
|
11
|
+
class R extends V {
|
|
13
12
|
constructor(t) {
|
|
14
13
|
super();
|
|
15
14
|
n(this, "headers");
|
|
@@ -19,18 +18,18 @@ class y extends x {
|
|
|
19
18
|
return this.headers.get(t) || "";
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
|
-
var
|
|
23
|
-
const
|
|
24
|
-
class
|
|
21
|
+
var F = Object.defineProperty, U = (i, e, t) => e in i ? F(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, s = (i, e, t) => (U(i, typeof e != "symbol" ? e + "" : e, t), t);
|
|
22
|
+
const m = "ended", H = "mute", j = "isolationchange", z = "overconstrained", q = "unmute", $ = [m, H, q, j, z];
|
|
23
|
+
class S {
|
|
25
24
|
constructor(e, { id: t = "identifier", constraints: r = {} } = {}) {
|
|
26
25
|
s(this, "events"), s(this, "id"), s(this, "kind"), s(this, "constraints"), s(this, "enabled"), s(this, "contentHint", ""), s(this, "readyState", "live"), s(this, "isolated", !1), s(this, "label", ""), s(this, "muted", !1), s(this, "onended", null), s(this, "onisolationchange", null), s(this, "onmute", null), s(this, "onunmute", null), s(this, "getConstraints", () => this.constraints), s(this, "stop", () => {
|
|
27
|
-
const o = { ...new Event(
|
|
28
|
-
this.events.trigger(
|
|
26
|
+
const o = { ...new Event(m) };
|
|
27
|
+
this.events.trigger(m, o), this.readyState = m, this.onended && this.onended(o);
|
|
29
28
|
}), s(this, "addEventListener", (o, a) => {
|
|
30
29
|
this.events.on(o, a);
|
|
31
30
|
}), s(this, "removeEventListener", (o, a) => {
|
|
32
31
|
this.events.off(o, a);
|
|
33
|
-
}), this.id = `${t}-${e}-track`, this.kind = e, this.enabled = !0, this.constraints = { ...r }, this.events = new
|
|
32
|
+
}), this.id = `${t}-${e}-track`, this.kind = e, this.enabled = !0, this.constraints = { ...r }, this.events = new E($);
|
|
34
33
|
}
|
|
35
34
|
clone() {
|
|
36
35
|
return { ...this };
|
|
@@ -56,8 +55,8 @@ class R {
|
|
|
56
55
|
return this.events.trigger(t, e), !0;
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
|
-
const
|
|
60
|
-
class
|
|
58
|
+
const B = (i) => new S("audio", i), K = (i) => new S("video", i);
|
|
59
|
+
class Y {
|
|
61
60
|
// @ts-expect-error
|
|
62
61
|
constructor({ originator: e = "local", eventHandlers: t }) {
|
|
63
62
|
n(this, "originator");
|
|
@@ -65,7 +64,7 @@ class K {
|
|
|
65
64
|
n(this, "_events");
|
|
66
65
|
n(this, "_remote_identity");
|
|
67
66
|
n(this, "_mutedOptions", { audio: !1, video: !1 });
|
|
68
|
-
this.originator = e, this._events = new
|
|
67
|
+
this.originator = e, this._events = new E(k), this.initEvents(t);
|
|
69
68
|
}
|
|
70
69
|
// @ts-expect-error
|
|
71
70
|
get C() {
|
|
@@ -238,7 +237,7 @@ class K {
|
|
|
238
237
|
return !0;
|
|
239
238
|
}
|
|
240
239
|
}
|
|
241
|
-
class
|
|
240
|
+
class J {
|
|
242
241
|
constructor(e, t) {
|
|
243
242
|
n(this, "_senders", []);
|
|
244
243
|
n(this, "_receivers", []);
|
|
@@ -332,14 +331,14 @@ class Y {
|
|
|
332
331
|
throw new Error("Method not implemented.");
|
|
333
332
|
}
|
|
334
333
|
}
|
|
335
|
-
function
|
|
334
|
+
function G(i) {
|
|
336
335
|
const e = i.match(/[\d.]+/g);
|
|
337
336
|
if (!e)
|
|
338
337
|
throw new Error("wrong sip url");
|
|
339
338
|
return e[0];
|
|
340
339
|
}
|
|
341
|
-
const
|
|
342
|
-
class
|
|
340
|
+
const p = 400, X = "777", Q = (i) => i.getVideoTracks().length > 0;
|
|
341
|
+
class C extends Y {
|
|
343
342
|
constructor({
|
|
344
343
|
url: t = "",
|
|
345
344
|
mediaStream: r,
|
|
@@ -368,7 +367,7 @@ class S extends K {
|
|
|
368
367
|
}, 100), setTimeout(() => {
|
|
369
368
|
this.trigger("confirmed");
|
|
370
369
|
}, 200);
|
|
371
|
-
},
|
|
370
|
+
}, p);
|
|
372
371
|
}));
|
|
373
372
|
this.url = t, this.initPeerconnection(r);
|
|
374
373
|
}
|
|
@@ -376,24 +375,24 @@ class S extends K {
|
|
|
376
375
|
return t ? (this.createPeerconnection(t), !0) : !1;
|
|
377
376
|
}
|
|
378
377
|
createPeerconnection(t) {
|
|
379
|
-
const r =
|
|
378
|
+
const r = B();
|
|
380
379
|
r.id = "mainaudio1";
|
|
381
380
|
const o = [r];
|
|
382
|
-
if (
|
|
383
|
-
const
|
|
384
|
-
|
|
381
|
+
if (Q(t)) {
|
|
382
|
+
const h = K();
|
|
383
|
+
h.id = "mainvideo1", o.push(h);
|
|
385
384
|
}
|
|
386
|
-
this._connection = new
|
|
385
|
+
this._connection = new J(void 0, o), this._addStream(t), setTimeout(() => {
|
|
387
386
|
this.trigger("peerconnection", { peerconnection: this.connection });
|
|
388
|
-
},
|
|
387
|
+
}, p);
|
|
389
388
|
}
|
|
390
389
|
connect(t) {
|
|
391
|
-
const r =
|
|
390
|
+
const r = G(t);
|
|
392
391
|
setTimeout(() => {
|
|
393
|
-
this.url.includes(
|
|
392
|
+
this.url.includes(X) ? this.trigger("failed", {
|
|
394
393
|
originator: "remote",
|
|
395
394
|
message: "IncomingResponse",
|
|
396
|
-
cause:
|
|
395
|
+
cause: N
|
|
397
396
|
}) : (this.trigger("connecting"), setTimeout(() => {
|
|
398
397
|
this.trigger("enterRoom", r);
|
|
399
398
|
}, 100), setTimeout(() => {
|
|
@@ -401,7 +400,7 @@ class S extends K {
|
|
|
401
400
|
}, 200), setTimeout(() => {
|
|
402
401
|
this.trigger("confirmed");
|
|
403
402
|
}, 300));
|
|
404
|
-
},
|
|
403
|
+
}, p);
|
|
405
404
|
}
|
|
406
405
|
terminate({ status_code: t } = {}) {
|
|
407
406
|
return this.status_code = t, this.trigger("ended", { status_code: t }), this._isEnded = !1, this;
|
|
@@ -459,7 +458,7 @@ class S extends K {
|
|
|
459
458
|
}
|
|
460
459
|
/* eslint-enable no-param-reassign */
|
|
461
460
|
}
|
|
462
|
-
class
|
|
461
|
+
class Z {
|
|
463
462
|
constructor() {
|
|
464
463
|
n(this, "extraHeaders");
|
|
465
464
|
}
|
|
@@ -469,7 +468,7 @@ class Q {
|
|
|
469
468
|
setExtraContactParams() {
|
|
470
469
|
}
|
|
471
470
|
}
|
|
472
|
-
const d = "PASSWORD_CORRECT",
|
|
471
|
+
const d = "PASSWORD_CORRECT", y = "PASSWORD_CORRECT_2", ee = "NAME_INCORRECT", c = 400, l = class l {
|
|
473
472
|
constructor(e) {
|
|
474
473
|
n(this, "_events");
|
|
475
474
|
n(this, "_startedTimeout");
|
|
@@ -482,9 +481,14 @@ const d = "PASSWORD_CORRECT", T = "PASSWORD_CORRECT_2", Z = "NAME_INCORRECT", h
|
|
|
482
481
|
// @ts-expect-error
|
|
483
482
|
n(this, "call", jest.fn((e, t) => {
|
|
484
483
|
const { mediaStream: r, eventHandlers: o } = t;
|
|
485
|
-
return this.session = new
|
|
484
|
+
return this.session = new C({ url: e, mediaStream: r, eventHandlers: o, originator: "local" }), this.session.connect(e), this.session;
|
|
486
485
|
}));
|
|
487
|
-
this._events = new
|
|
486
|
+
this._events = new E(L);
|
|
487
|
+
const [t, r] = e.uri.split(":"), [o, a] = r.split("@"), h = {
|
|
488
|
+
...e,
|
|
489
|
+
uri: new f(t, o, a)
|
|
490
|
+
};
|
|
491
|
+
this.configuration = h, this._registrator = new Z();
|
|
488
492
|
}
|
|
489
493
|
static setAvailableTelephony() {
|
|
490
494
|
this.isAvailableTelephony = !0;
|
|
@@ -508,7 +512,7 @@ const d = "PASSWORD_CORRECT", T = "PASSWORD_CORRECT_2", Z = "NAME_INCORRECT", h
|
|
|
508
512
|
stop() {
|
|
509
513
|
this._startedTimeout && clearTimeout(this._startedTimeout), this._stopedTimeout && clearTimeout(this._stopedTimeout), this.unregister(), this.isStarted() ? this._stopedTimeout = setTimeout(() => {
|
|
510
514
|
this.trigger("disconnected", { error: new Error("stoped") });
|
|
511
|
-
},
|
|
515
|
+
}, c) : this.trigger("disconnected", { error: new Error("stoped") });
|
|
512
516
|
}
|
|
513
517
|
// @ts-expect-error
|
|
514
518
|
on(e, t) {
|
|
@@ -555,13 +559,13 @@ const d = "PASSWORD_CORRECT", T = "PASSWORD_CORRECT_2", Z = "NAME_INCORRECT", h
|
|
|
555
559
|
register() {
|
|
556
560
|
this._startedTimeout && clearTimeout(this._startedTimeout);
|
|
557
561
|
const { password: e, register: t, uri: r } = this.configuration;
|
|
558
|
-
t && r.includes(
|
|
562
|
+
t && r.user.includes(ee) ? (this._isRegistered = !1, this._isConnected = !1, this._startedTimeout = setTimeout(() => {
|
|
559
563
|
this.trigger("registrationFailed", { response: null, cause: "Request Timeout" });
|
|
560
|
-
},
|
|
564
|
+
}, c)) : !this._isRegistered && t && (e === d || e === y) ? (this._isRegistered = !0, this._startedTimeout = setTimeout(() => {
|
|
561
565
|
this.trigger("registered");
|
|
562
|
-
},
|
|
566
|
+
}, c)) : t && e !== d && e !== y && (this._isRegistered = !1, this._isConnected = !1, this._startedTimeout = setTimeout(() => {
|
|
563
567
|
this.trigger("registrationFailed", { response: null, cause: "Wrong credentials" });
|
|
564
|
-
},
|
|
568
|
+
}, c)), l.isAvailableTelephony ? (this.trigger("connected"), this._isConnected = !0) : this.stop();
|
|
565
569
|
}
|
|
566
570
|
/**
|
|
567
571
|
* unregister
|
|
@@ -594,15 +598,15 @@ const d = "PASSWORD_CORRECT", T = "PASSWORD_CORRECT_2", Z = "NAME_INCORRECT", h
|
|
|
594
598
|
this.trigger("sipEvent", e);
|
|
595
599
|
}
|
|
596
600
|
};
|
|
597
|
-
n(
|
|
598
|
-
let
|
|
599
|
-
class
|
|
601
|
+
n(l, "isAvailableTelephony", !0);
|
|
602
|
+
let _ = l;
|
|
603
|
+
class te {
|
|
600
604
|
constructor(e) {
|
|
601
605
|
n(this, "url");
|
|
602
606
|
this.url = e;
|
|
603
607
|
}
|
|
604
608
|
}
|
|
605
|
-
class
|
|
609
|
+
class ne extends x {
|
|
606
610
|
constructor(t, r) {
|
|
607
611
|
super();
|
|
608
612
|
n(this, "contentType");
|
|
@@ -610,102 +614,102 @@ class te extends P {
|
|
|
610
614
|
this.contentType = t, this.body = r;
|
|
611
615
|
}
|
|
612
616
|
}
|
|
613
|
-
const
|
|
614
|
-
const t = new
|
|
615
|
-
originator:
|
|
617
|
+
const w = "remote", re = (i, e) => {
|
|
618
|
+
const t = new R(e), r = {
|
|
619
|
+
originator: w,
|
|
616
620
|
request: t,
|
|
617
|
-
info: new
|
|
621
|
+
info: new ne("", "")
|
|
618
622
|
};
|
|
619
623
|
i.newInfo(r);
|
|
620
|
-
},
|
|
621
|
-
const r = { request: new
|
|
624
|
+
}, ie = (i, e) => {
|
|
625
|
+
const r = { request: new R(e) };
|
|
622
626
|
i.newSipEvent(r);
|
|
623
|
-
},
|
|
627
|
+
}, oe = (i, {
|
|
624
628
|
incomingNumber: e = "1234",
|
|
625
629
|
displayName: t,
|
|
626
630
|
host: r
|
|
627
631
|
}) => {
|
|
628
|
-
const o = new
|
|
629
|
-
o._remote_identity = new
|
|
630
|
-
},
|
|
632
|
+
const o = new C({ originator: w }), a = new P("sip", e, r);
|
|
633
|
+
o._remote_identity = new W(a, t), i.trigger("newRTCSession", { originator: w, session: o });
|
|
634
|
+
}, se = (i, e) => {
|
|
631
635
|
e ? i.trigger("failed", e) : i.trigger("failed", i);
|
|
632
|
-
},
|
|
633
|
-
triggerNewInfo:
|
|
634
|
-
triggerNewSipEvent:
|
|
635
|
-
triggerIncomingSession:
|
|
636
|
-
triggerFailIncomingSession:
|
|
637
|
-
WebSocketInterface:
|
|
638
|
-
UA:
|
|
636
|
+
}, b = {
|
|
637
|
+
triggerNewInfo: re,
|
|
638
|
+
triggerNewSipEvent: ie,
|
|
639
|
+
triggerIncomingSession: oe,
|
|
640
|
+
triggerFailIncomingSession: se,
|
|
641
|
+
WebSocketInterface: te,
|
|
642
|
+
UA: _,
|
|
639
643
|
C: {
|
|
640
644
|
INVITE: "INVITE"
|
|
641
645
|
}
|
|
642
|
-
},
|
|
646
|
+
}, v = "user", u = "displayName", M = "SIP_SERVER_URL", I = "SIP_WEB_SOCKET_SERVER_URL", ae = new b.WebSocketInterface(I), T = {
|
|
643
647
|
userAgent: "Chrome",
|
|
644
|
-
sipServerUrl:
|
|
645
|
-
sipWebSocketServerURL:
|
|
648
|
+
sipServerUrl: M,
|
|
649
|
+
sipWebSocketServerURL: I
|
|
646
650
|
}, Ee = {
|
|
647
|
-
...
|
|
648
|
-
},
|
|
649
|
-
...
|
|
650
|
-
user:
|
|
651
|
+
...T
|
|
652
|
+
}, de = {
|
|
653
|
+
...T,
|
|
654
|
+
user: v,
|
|
651
655
|
password: d,
|
|
652
656
|
register: !0
|
|
653
657
|
}, fe = {
|
|
654
|
-
...
|
|
655
|
-
displayName:
|
|
658
|
+
...de,
|
|
659
|
+
displayName: u
|
|
656
660
|
}, ve = {
|
|
657
|
-
...
|
|
658
|
-
displayName:
|
|
661
|
+
...T,
|
|
662
|
+
displayName: u,
|
|
659
663
|
register: !1
|
|
660
|
-
},
|
|
664
|
+
}, g = {
|
|
661
665
|
session_timers: !1,
|
|
662
|
-
sockets: [
|
|
666
|
+
sockets: [ae],
|
|
663
667
|
user_agent: "Chrome",
|
|
664
668
|
sdp_semantics: "plan-b",
|
|
665
669
|
register_expires: 300,
|
|
666
670
|
connection_recovery_max_interval: 6,
|
|
667
671
|
connection_recovery_min_interval: 2
|
|
668
672
|
}, Me = {
|
|
669
|
-
...
|
|
673
|
+
...g,
|
|
670
674
|
password: d,
|
|
671
|
-
uri:
|
|
675
|
+
uri: new f("sip", v, M),
|
|
672
676
|
display_name: "",
|
|
673
677
|
register: !0
|
|
674
678
|
}, Te = {
|
|
675
|
-
...
|
|
679
|
+
...g,
|
|
676
680
|
password: d,
|
|
677
|
-
uri:
|
|
678
|
-
display_name:
|
|
681
|
+
uri: new f("sip", v, M),
|
|
682
|
+
display_name: u,
|
|
679
683
|
register: !0
|
|
680
684
|
}, ye = {
|
|
681
|
-
...
|
|
682
|
-
display_name:
|
|
685
|
+
...g,
|
|
686
|
+
display_name: u,
|
|
683
687
|
register: !1
|
|
684
688
|
}, Re = {
|
|
685
|
-
...
|
|
689
|
+
...g,
|
|
686
690
|
display_name: "",
|
|
687
691
|
register: !1
|
|
688
|
-
},
|
|
689
|
-
JsSIP:
|
|
692
|
+
}, he = "10.10.10.10", Se = [`X-Vinteo-Remote: ${he}`], Ce = () => new D({
|
|
693
|
+
JsSIP: b
|
|
690
694
|
});
|
|
691
695
|
export {
|
|
692
|
-
|
|
693
|
-
|
|
696
|
+
X as FAILED_CONFERENCE_NUMBER,
|
|
697
|
+
ee as NAME_INCORRECT,
|
|
694
698
|
d as PASSWORD_CORRECT,
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
+
y as PASSWORD_CORRECT_2,
|
|
700
|
+
M as SIP_SERVER_URL,
|
|
701
|
+
I as SIP_WEB_SOCKET_SERVER_URL,
|
|
702
|
+
de as dataForConnectionWithAuthorization,
|
|
699
703
|
fe as dataForConnectionWithAuthorizationWithDisplayName,
|
|
700
704
|
ve as dataForConnectionWithoutAuthorization,
|
|
701
705
|
Ee as dataForConnectionWithoutAuthorizationWithoutDisplayName,
|
|
702
706
|
Ce as default,
|
|
703
|
-
|
|
707
|
+
u as displayName,
|
|
704
708
|
Se as extraHeadersRemoteAddress,
|
|
705
|
-
|
|
709
|
+
he as remoteAddress,
|
|
706
710
|
Me as uaConfigurationWithAuthorization,
|
|
707
711
|
Te as uaConfigurationWithAuthorizationWithDisplayName,
|
|
708
712
|
ye as uaConfigurationWithoutAuthorization,
|
|
709
713
|
Re as uaConfigurationWithoutAuthorizationWithoutDisplayName,
|
|
710
|
-
|
|
714
|
+
v as user
|
|
711
715
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("./SipConnector-Q7QLgdlo.cjs"),H=require("ts-debounce"),Y=require("@krivega/cancelable-promise"),z=require("debug");require("events-constructor");const x="purgatory",P=e=>e===x,B=e=>()=>(s.logger("getRemoteStreams"),e.getRemoteStreams()),J=({kind:e,readyState:n})=>e==="video"&&n==="live",V=e=>({track:n})=>{J(n)&&e()},D=({getRemoteStreams:e,setRemoteStreams:n})=>H.debounce(()=>{const t=e();s.logger("remoteStreams",t),t&&n(t)},200),Q=e=>async t=>{const{mediaStream:r,extraHeaders:o,iceServers:c,degradationPreference:a,setRemoteStreams:u,onBeforeProgressCall:d,onSuccessProgressCall:E,onEnterPurgatory:f,onEnterConference:m,onFailProgressCall:y,onFinishProgressCall:h,onEndedCall:M}=t,C=D({setRemoteStreams:u,getRemoteStreams:B(e)}),T=V(C);s.logger("answerIncomingCall",t);const O=async()=>e.answerToIncomingCall({mediaStream:r,extraHeaders:o,iceServers:c,degradationPreference:a,ontrack:T}),A=()=>{const{remoteCallerData:S}=e;return S.incomingNumber};let _=!1,i;const l=(s.logger("subscribeEnterConference: onEnterConference",m),f??m?e.onSession("enterRoom",S=>{s.logger("enterRoom",{_room:S,isSuccessProgressCall:_}),i=S,P(i)?f&&f():m&&m({isSuccessProgressCall:_})}):()=>{}),R=S=>(s.logger("onSuccess"),_=!0,C(),E&&E({isPurgatory:P(i)}),e.onceRaceSession(["ended","failed"],()=>{l(),M&&M()}),S),b=S=>{throw s.logger("onFail"),y&&y(),l(),S},N=()=>{s.logger("onFinish"),h&&h()};if(s.logger("onBeforeProgressCall"),d){const S=A();d(S)}return O().then(R).catch(b).finally(N)},Z=e=>async t=>{const{conference:r,mediaStream:o,extraHeaders:c,iceServers:a,degradationPreference:u,setRemoteStreams:d,onBeforeProgressCall:E,onSuccessProgressCall:f,onEnterPurgatory:m,onEnterConference:y,onFailProgressCall:h,onFinishProgressCall:M,onEndedCall:C}=t,T=D({setRemoteStreams:d,getRemoteStreams:B(e)}),O=V(T);s.logger("callToServer",t);const A=async()=>(s.logger("startCall"),e.call({mediaStream:o,extraHeaders:c,iceServers:a,degradationPreference:u,number:r,ontrack:O}));let _=!1,i;const l=(s.logger("subscribeEnterConference: onEnterConference",y),m??y?e.onSession("enterRoom",S=>{s.logger("enterRoom",{_room:S,isSuccessProgressCall:_}),i=S,P(i)?m&&m():y&&y({isSuccessProgressCall:_})}):()=>{}),R=S=>(s.logger("onSuccess"),_=!0,T(),f&&f({isPurgatory:P(i)}),e.onceRaceSession(["ended","failed"],()=>{l(),C&&C()}),S),b=S=>{throw s.logger("onFail"),h&&h(),l(),S},N=()=>{s.logger("onFinish"),M&&M()};return s.logger("onBeforeProgressCall"),E&&E(r),A().then(R).catch(b).finally(N)},p=e=>{if(!Y.isCanceledError(e))throw e;return!1},ee=e=>async t=>{const{userAgent:r,sipWebSocketServerURL:o,sipServerUrl:c,remoteAddress:a,displayName:u,name:d,password:E,isRegisteredUser:f,sdpSemantics:m,isDisconnectOnFail:y}=t;return s.logger("connectToServer",t),e.connect({userAgent:r,sdpSemantics:m,sipWebSocketServerURL:o,sipServerUrl:c,remoteAddress:a,displayName:u,password:E,user:d,register:f}).then(()=>(s.logger("connectToServer then"),!0)).catch(async h=>(s.logger("connectToServer catch: error",h),y===!0?e.disconnect().then(()=>p(h)).catch(()=>p(h)):p(h)))},ne=e=>async()=>(s.logger("disconnectFromServer"),e.disconnect().then(()=>(s.logger("disconnectFromServer: then"),!1)).catch(n=>(s.logger("disconnectFromServer: catch",n),!1))),k=e=>{const{url:n,cause:t}=e;let r=n;return(t===s.BAD_MEDIA_DESCRIPTION||t===s.NOT_FOUND)&&(r=`${e.message.to.uri.user}@${e.message.to.uri.host}`),r};var $=(e=>(e.CONNECT_SERVER_FAILED="CONNECT_SERVER_FAILED",e.WRONG_USER_OR_PASSWORD="WRONG_USER_OR_PASSWORD",e.BAD_MEDIA_ERROR="BAD_MEDIA_ERROR",e.NOT_FOUND_ERROR="NOT_FOUND_ERROR",e.WS_CONNECTION_FAILED="WS_CONNECTION_FAILED",e.CONNECT_SERVER_FAILED_BY_LINK="CONNECT_SERVER_FAILED_BY_LINK",e))($||{});const te=(e=new Error)=>{var o;const{cause:n,socket:t}=e;let r="CONNECT_SERVER_FAILED";switch(n){case"Forbidden":{r="WRONG_USER_OR_PASSWORD";break}case s.BAD_MEDIA_DESCRIPTION:{r="BAD_MEDIA_ERROR";break}case s.NOT_FOUND:{r="NOT_FOUND_ERROR";break}default:t&&((o=t==null?void 0:t._ws)==null?void 0:o.readyState)===3?r="WS_CONNECTION_FAILED":k(e)&&(r="CONNECT_SERVER_FAILED_BY_LINK")}return r},re=(e=new Error)=>{const{code:n,cause:t,message:r}=e,o=k(e),c={};return r&&(c.message=r),o&&(c.link=o),n&&(c.code=n),t&&(c.cause=t),c},se=Object.freeze(Object.defineProperty({__proto__:null,EErrorTypes:$,getLinkError:k,getTypeFromError:te,getValuesFromError:re},Symbol.toStringTag,{value:"Module"})),oe=({sessionId:e,remoteAddress:n,isMutedAudio:t,isMutedVideo:r,isRegistered:o,isPresentationCall:c})=>{const a=[],u=t?"0":"1",d=r?"0":"1";return a.push(`X-Vinteo-Mic-State: ${u}`,`X-Vinteo-MainCam-State: ${d}`),o||a.push("X-Vinteo-Purgatory-Call: yes"),e&&a.push(`X-Vinteo-Session: ${e}`),c&&a.push("X-Vinteo-Presentation-Call: yes"),n&&a.push(`X-Vinteo-Remote: ${n}`),a},ce=({appName:e,appVersion:n,browserName:t,browserVersion:r})=>{const o=`${e} ${n}`;return`ChromeNew - ${t?`${t} ${r}, ${o}`:o}`},ae=({isUnifiedSdpSemantic:e,appVersion:n,browserName:t,browserVersion:r,appName:o})=>e?ce({appVersion:n,browserName:t,browserVersion:r,appName:o}):"Chrome",ie=e=>async()=>{if(e.isCallActive)return s.logger("askPermissionToEnableCam"),e.askPermissionToEnableCam()},ue=e=>t=>(s.logger("onMustStopPresentation"),e.onSession("mustStopPresentation",t)),le=e=>t=>(s.logger("onUseLicense"),e.onSession("useLicense",t)),ge=e=>async({isEnabledCam:t,isEnabledMic:r})=>{if(e.isCallActive)return s.logger("sendMediaState"),e.sendMediaState({cam:t,mic:r})},Se=e=>async()=>{if(e.isCallActive)return s.logger("sendRefusalToTurnOnCam"),e.sendRefusalToTurnOnCam().catch(t=>{s.logger("sendRefusalToTurnOnCam: error",t)})},de=e=>async()=>{if(e.isCallActive)return s.logger("sendRefusalToTurnOnMic"),e.sendRefusalToTurnOnMic().catch(t=>{s.logger("sendRefusalToTurnOnMic: error",t)})},me=1e6,fe=({maxBitrate:e=me,sipConnector:n})=>async({mediaStream:r,isP2P:o=!1})=>(s.logger("startPresentation"),n.startPresentation(r,{isP2P:o,maxBitrate:e})),Ee=({sipConnector:e})=>async({isP2P:t=!1}={})=>(s.logger("stopShareSipConnector"),e.stopPresentation({isP2P:t}).catch(s.logger)),Ce=1e6,Re=({sipConnector:e,maxBitrate:n=Ce})=>async({mediaStream:r,isP2P:o=!1})=>(s.logger("updatePresentation"),e.updatePresentation(r,{isP2P:o,maxBitrate:n})),he="ERROR_NOT_RUNNING",Me=e=>{const n=new Error("Promise was not running");return n.basePromise=e,n.id=he,n.name="Not running",n},ye=async(e,n)=>e.reduce(async(t,r)=>t.then(async({success:o,errors:c,results:a})=>(!n||n(r)?r():Promise.reject(Me(r))).then(u=>({errors:c,success:[...o,u],results:[...a,u],isSuccessful:!0,isError:!1})).catch(u=>({success:o,errors:[...c,u],results:[...a,u],isSuccessful:!1,isError:!0}))),Promise.resolve({success:[],errors:[],results:[],isSuccessful:!1,isError:!1})),Te=e=>n=>[...n].map(r=>async()=>e(r)),_e=async({accumulatedKeys:e,sendKey:n,canRunTask:t})=>{const o=Te(n)(e);return ye(o,t)},be=e=>t=>(s.logger("onStartMainCam"),e.onSession("admin-start-main-cam",t)),ve=e=>t=>(s.logger("onStartMic"),e.onSession("admin-start-mic",t)),Ne=e=>t=>(s.logger("onStopMainCam"),e.onSession("admin-stop-main-cam",t)),Oe=e=>t=>(s.logger("onStopMic"),e.onSession("admin-stop-mic",t)),Ae=({sipConnector:e})=>{const n=(M,C)=>({isSyncForced:T=!1})=>{if(T){M();return}C()},t=be(e),r=Ne(e),o=ve(e),c=Oe(e);let a=()=>{},u=()=>{},d=()=>{},E=()=>{};const f=({onStartMainCamForced:M,onStartMainCamNotForced:C,onStopMainCamForced:T,onStopMainCamNotForced:O,onStartMicForced:A,onStartMicNotForced:_,onStopMicForced:i,onStopMicNotForced:g})=>{const l=n(M,C);a=t(l);const R=n(T,O);u=r(R);const b=n(A,_);d=o(b);const N=n(i,g);E=c(N)},m=()=>{a(),u(),d(),E()};return{start:M=>{f(M)},stop:()=>{m()}}},Pe=Object.freeze(Object.defineProperty({__proto__:null,PURGATORY_CONFERENCE_NUMBER:x,createSyncMediaState:Ae,error:se,getExtraHeaders:oe,getUserAgent:ae,hasPurgatory:P,resolveAnswerIncomingCall:Q,resolveAskPermissionToEnableCam:ie,resolveCallToServer:Z,resolveConnectToServer:ee,resolveDisconnectFromServer:ne,resolveGetRemoteStreams:B,resolveOnMustStopPresentation:ue,resolveOnUseLicense:le,resolveSendMediaState:ge,resolveSendRefusalToTurnOnCam:Se,resolveSendRefusalToTurnOnMic:de,resolveStartPresentation:fe,resolveStopShareSipConnector:Ee,resolveUpdatePresentation:Re,resolveUpdateRemoteStreams:D,sendDTMFAccumulated:_e},Symbol.toStringTag,{value:"Module"})),pe=e=>[...e.keys()].map(n=>e.get(n)),Ie=(e,n)=>pe(e).find(t=>t.type===n),j=async e=>e.getStats().then(n=>{const t=Ie(n,"codec");return t==null?void 0:t.mimeType}),we=e=>e.find(n=>{var t;return((t=n==null?void 0:n.track)==null?void 0:t.kind)==="video"}),G=(e,n)=>e!==void 0&&n!==void 0&&e.toLowerCase().includes(n.toLowerCase()),Be="ERROR_NOT_RUNNING",De=e=>{const n=new Error("Promise was not running");return n.basePromise=e,n.id=Be,n.name="Not running",n},ke=async(e,n)=>e.reduce(async(t,r)=>t.then(async({success:o,errors:c,results:a})=>(!n||n(r)?r():Promise.reject(De(r))).then(u=>({errors:c,success:[...o,u],results:[...a,u],isSuccessful:!0,isError:!1})).catch(u=>({success:o,errors:[...c,u],results:[...a,u],isSuccessful:!1,isError:!0}))),Promise.resolve({success:[],errors:[],results:[],isSuccessful:!1,isError:!1})),Fe=new Error("Stack is empty"),I=e=>e[e.length-1],Ue=new Error("Promise is not actual"),Le=new Error("stackPromises only works with functions that returns a Promise"),xe=({noRejectIsNotActual:e=!1,noRunIsNotActual:n=!1}={})=>{const t=[],r=[],o=({task:i,index:g})=>{r.push({task:i,index:g})},c=(i,{task:g,index:l})=>{const R=r.find(({task:b,index:N})=>g===b&&l===N);if(!R)throw new Error("Task not found");if(R.promise)throw new Error("Task is already running");R.promise=i},a=({task:i,index:g})=>{const l=r.find(({task:R,index:b})=>i===R&&g===b);if(l)return l.promise},u=({task:i})=>{const g=I(r);return(g==null?void 0:g.task)===i},d=({task:i,index:g})=>(o({task:i,index:g}),async()=>{let l=a({task:i,index:g});const R=u({task:i});return!l&&n&&!R?Promise.resolve():(l||(l=i({isActual:R}),c(l,{task:i,index:g})),l)}),E=({resolve:i,reject:g})=>({results:l,isSuccessful:R})=>{const b=l.length,N=t.length;if(b===N){const S=I(l);if(R){i(S);return}g(S);return}if(e){const S=I(l);i(S);return}g(Ue)};let f=!1;const m=()=>{f=!0},y=()=>{f=!1},h=()=>f,M=async()=>(m(),ke(t,h)),C=async()=>{if(t.length===0)throw Fe;return new Promise((i,g)=>{const l=E({resolve:i,reject:g});M().then(l).catch(l)})},T=i=>{if(typeof i!="function")throw Le;const g=t.length;return t.push(d({task:i,index:g})),C},O=async i=>(T(i),C()),A=()=>{t.length=0,r.length=0},_=()=>{y(),A()};return C.add=T,C.run=O,C.stop=_,C},Ve=1e6,v=e=>e*Ve,X=v(.06),$e=v(4),je=e=>e<=64?X:e<=128?v(.12):e<=256?v(.25):e<=384?v(.32):e<=426?v(.38):e<=640?v(.5):e<=848?v(.7):e<=1280?v(1):e<=1920?v(2):$e,Ge="av1",Xe=e=>G(e,Ge),Ke=.6,K=(e,n)=>Xe(n)?e*Ke:e,We=e=>K(X,e),W=(e,n)=>{const t=je(e);return K(t,n)},q=xe(),qe=async()=>q().catch(e=>{s.logger("videoSendingBalancer: error",e)}),He=async e=>(q.add(e),qe()),F=async({sender:e,scaleResolutionDownBy:n,maxBitrate:t,onSetParameters:r})=>He(async()=>s.setEncodingsToSender(e,{scaleResolutionDownBy:n,maxBitrate:t},r)),Ye=async({sender:e,codec:n},t)=>{const o=We(n);return F({sender:e,maxBitrate:o,onSetParameters:t,scaleResolutionDownBy:200})},w=async({sender:e,track:n,codec:t},r)=>{const a=n.getSettings().width,u=W(a,t);return F({sender:e,maxBitrate:u,onSetParameters:r,scaleResolutionDownBy:1})},ze=async({sender:e,track:n,resolution:t,codec:r},o)=>{const c=n.getSettings(),a=c.width,u=c.height,[d,E]=t.split("x"),f=a/Number(d),m=u/Number(E),h=Math.max(f,m,1),M=W(Number(d),r);return F({sender:e,maxBitrate:M,onSetParameters:o,scaleResolutionDownBy:h})},Je=async({mainCam:e,resolutionMainCam:n,sender:t,track:r,codec:o},c)=>{switch(e){case s.EEventsMainCAM.PAUSE_MAIN_CAM:return Ye({sender:t,codec:o},c);case s.EEventsMainCAM.RESUME_MAIN_CAM:return w({sender:t,track:r,codec:o},c);case s.EEventsMainCAM.MAX_MAIN_CAM_RESOLUTION:return n!==void 0?ze({sender:t,track:r,codec:o,resolution:n},c):w({sender:t,track:r,codec:o},c);default:return w({sender:t,track:r,codec:o},c)}},U={isChanged:!1,parameters:{encodings:[{}],transactionId:"0",codecs:[],headerExtensions:[],rtcp:{}}},L=async({mainCam:e,resolutionMainCam:n,connection:t,onSetParameters:r,ignoreForCodec:o})=>{const c=t.getSenders(),a=we(c);if(!(a!=null&&a.track))return U;const u=await j(a);return G(u,o)?U:Je({mainCam:e,resolutionMainCam:n,sender:a,codec:u,track:a.track},r)},Qe=(e,{ignoreForCodec:n,onSetParameters:t}={})=>{const r=async()=>{const{connection:d}=e;if(!d)throw new Error("connection is not exist");return L({connection:d,onSetParameters:t,ignoreForCodec:n})};let o=r;const c=async d=>(o=async()=>{const{mainCam:E,resolutionMainCam:f}=d,{connection:m}=e;if(!m)throw new Error("connection is not exist");return L({mainCam:E,resolutionMainCam:f,connection:m,onSetParameters:t,ignoreForCodec:n})},o());return{subscribe:()=>{e.onSession("main-cam-control",c)},unsubscribe:()=>{e.offSession("main-cam-control",c)},balanceByTrack:r,resetMainCamControl(){o=r},async reBalance(){return o()}}};exports.EEventsMainCAM=s.EEventsMainCAM;exports.EEventsMic=s.EEventsMic;exports.EEventsSyncMediaState=s.EEventsSyncMediaState;exports.EUseLicense=s.EUseLicense;exports.causes=s.causes;exports.constants=s.constants;exports.default=s.SipConnector;exports.disableDebug=s.disableDebug;exports.enableDebug=s.enableDebug;exports.eventNames=s.eventNames;exports.hasCanceledCallError=s.hasCanceledCallError;exports.debug=z;exports.getCodecFromSender=j;exports.resolveVideoSendingBalancer=Qe;exports.tools=Pe;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("./SipConnector-eRr2JbY9.cjs"),q=require("ts-debounce"),Y=require("@krivega/cancelable-promise"),z=require("debug"),x="purgatory",P=e=>e===x,B=e=>()=>(s.logger("getRemoteStreams"),e.getRemoteStreams()),J=({kind:e,readyState:n})=>e==="video"&&n==="live",V=e=>({track:n})=>{J(n)&&e()},D=({getRemoteStreams:e,setRemoteStreams:n})=>q.debounce(()=>{const t=e();s.logger("remoteStreams",t),t&&n(t)},200),Q=e=>async t=>{const{mediaStream:r,extraHeaders:o,iceServers:c,degradationPreference:a,setRemoteStreams:u,onBeforeProgressCall:d,onSuccessProgressCall:C,onEnterPurgatory:f,onEnterConference:m,onFailProgressCall:y,onFinishProgressCall:E,onEndedCall:M}=t,R=D({setRemoteStreams:u,getRemoteStreams:B(e)}),T=V(R);s.logger("answerIncomingCall",t);const O=async()=>e.answerToIncomingCall({mediaStream:r,extraHeaders:o,iceServers:c,degradationPreference:a,ontrack:T}),A=()=>{const{remoteCallerData:S}=e;return S.incomingNumber};let _=!1,i;const l=(s.logger("subscribeEnterConference: onEnterConference",m),f??m?e.onSession("enterRoom",S=>{s.logger("enterRoom",{_room:S,isSuccessProgressCall:_}),i=S,P(i)?f&&f():m&&m({isSuccessProgressCall:_})}):()=>{}),h=S=>(s.logger("onSuccess"),_=!0,R(),C&&C({isPurgatory:P(i)}),e.onceRaceSession(["ended","failed"],()=>{l(),M&&M()}),S),b=S=>{throw s.logger("onFail"),y&&y(),l(),S},N=()=>{s.logger("onFinish"),E&&E()};if(s.logger("onBeforeProgressCall"),d){const S=A();d(S)}return O().then(h).catch(b).finally(N)},Z=e=>async t=>{const{conference:r,mediaStream:o,extraHeaders:c,iceServers:a,degradationPreference:u,setRemoteStreams:d,onBeforeProgressCall:C,onSuccessProgressCall:f,onEnterPurgatory:m,onEnterConference:y,onFailProgressCall:E,onFinishProgressCall:M,onEndedCall:R}=t,T=D({setRemoteStreams:d,getRemoteStreams:B(e)}),O=V(T);s.logger("callToServer",t);const A=async()=>(s.logger("startCall"),e.call({mediaStream:o,extraHeaders:c,iceServers:a,degradationPreference:u,number:r,ontrack:O}));let _=!1,i;const l=(s.logger("subscribeEnterConference: onEnterConference",y),m??y?e.onSession("enterRoom",S=>{s.logger("enterRoom",{_room:S,isSuccessProgressCall:_}),i=S,P(i)?m&&m():y&&y({isSuccessProgressCall:_})}):()=>{}),h=S=>(s.logger("onSuccess"),_=!0,T(),f&&f({isPurgatory:P(i)}),e.onceRaceSession(["ended","failed"],()=>{l(),R&&R()}),S),b=S=>{throw s.logger("onFail"),E&&E(),l(),S},N=()=>{s.logger("onFinish"),M&&M()};return s.logger("onBeforeProgressCall"),C&&C(r),A().then(h).catch(b).finally(N)},p=e=>{if(!Y.isCanceledError(e))throw e;return{isSuccessful:!1}},ee=e=>async t=>{const{userAgent:r,sipWebSocketServerURL:o,sipServerUrl:c,remoteAddress:a,displayName:u,name:d,password:C,isRegisteredUser:f,sdpSemantics:m,isDisconnectOnFail:y}=t;return s.logger("connectToServer",t),e.connect({userAgent:r,sdpSemantics:m,sipWebSocketServerURL:o,sipServerUrl:c,remoteAddress:a,displayName:u,password:C,user:d,register:f}).then(E=>(s.logger("connectToServer then"),{ua:E,isSuccessful:!0})).catch(async E=>(s.logger("connectToServer catch: error",E),y===!0?e.disconnect().then(()=>p(E)).catch(()=>p(E)):p(E)))},ne=e=>async()=>(s.logger("disconnectFromServer"),e.disconnect().then(()=>(s.logger("disconnectFromServer: then"),{isSuccessful:!0})).catch(n=>(s.logger("disconnectFromServer: catch",n),{isSuccessful:!1}))),k=e=>{const{url:n,cause:t}=e;let r=n;return(t===s.BAD_MEDIA_DESCRIPTION||t===s.NOT_FOUND)&&(r=`${e.message.to.uri.user}@${e.message.to.uri.host}`),r};var $=(e=>(e.CONNECT_SERVER_FAILED="CONNECT_SERVER_FAILED",e.WRONG_USER_OR_PASSWORD="WRONG_USER_OR_PASSWORD",e.BAD_MEDIA_ERROR="BAD_MEDIA_ERROR",e.NOT_FOUND_ERROR="NOT_FOUND_ERROR",e.WS_CONNECTION_FAILED="WS_CONNECTION_FAILED",e.CONNECT_SERVER_FAILED_BY_LINK="CONNECT_SERVER_FAILED_BY_LINK",e))($||{});const te=(e=new Error)=>{var o;const{cause:n,socket:t}=e;let r="CONNECT_SERVER_FAILED";switch(n){case"Forbidden":{r="WRONG_USER_OR_PASSWORD";break}case s.BAD_MEDIA_DESCRIPTION:{r="BAD_MEDIA_ERROR";break}case s.NOT_FOUND:{r="NOT_FOUND_ERROR";break}default:t&&((o=t==null?void 0:t._ws)==null?void 0:o.readyState)===3?r="WS_CONNECTION_FAILED":k(e)&&(r="CONNECT_SERVER_FAILED_BY_LINK")}return r},re=(e=new Error)=>{const{code:n,cause:t,message:r}=e,o=k(e),c={};return r&&(c.message=r),o&&(c.link=o),n&&(c.code=n),t&&(c.cause=t),c},se=Object.freeze(Object.defineProperty({__proto__:null,EErrorTypes:$,getLinkError:k,getTypeFromError:te,getValuesFromError:re},Symbol.toStringTag,{value:"Module"})),oe=({sessionId:e,remoteAddress:n,isMutedAudio:t,isMutedVideo:r,isRegistered:o,isPresentationCall:c})=>{const a=[],u=t?"0":"1",d=r?"0":"1";return a.push(`X-Vinteo-Mic-State: ${u}`,`X-Vinteo-MainCam-State: ${d}`),o||a.push("X-Vinteo-Purgatory-Call: yes"),e&&a.push(`X-Vinteo-Session: ${e}`),c&&a.push("X-Vinteo-Presentation-Call: yes"),n&&a.push(`X-Vinteo-Remote: ${n}`),a},ce=({appName:e,appVersion:n,browserName:t,browserVersion:r})=>{const o=`${e} ${n}`;return`ChromeNew - ${t?`${t} ${r}, ${o}`:o}`},ae=({isUnifiedSdpSemantic:e,appVersion:n,browserName:t,browserVersion:r,appName:o})=>e?ce({appVersion:n,browserName:t,browserVersion:r,appName:o}):"Chrome",ie=e=>async()=>{if(e.isCallActive)return s.logger("askPermissionToEnableCam"),e.askPermissionToEnableCam()},ue=e=>t=>(s.logger("onMustStopPresentation"),e.onSession("mustStopPresentation",t)),le=e=>t=>(s.logger("onUseLicense"),e.onSession("useLicense",t)),ge=e=>async({isEnabledCam:t,isEnabledMic:r})=>{if(e.isCallActive)return s.logger("sendMediaState"),e.sendMediaState({cam:t,mic:r})},Se=e=>async()=>{if(e.isCallActive)return s.logger("sendRefusalToTurnOnCam"),e.sendRefusalToTurnOnCam().catch(t=>{s.logger("sendRefusalToTurnOnCam: error",t)})},de=e=>async()=>{if(e.isCallActive)return s.logger("sendRefusalToTurnOnMic"),e.sendRefusalToTurnOnMic().catch(t=>{s.logger("sendRefusalToTurnOnMic: error",t)})},me=1e6,fe=({maxBitrate:e=me,sipConnector:n})=>async({mediaStream:r,isP2P:o=!1})=>(s.logger("startPresentation"),n.startPresentation(r,{isP2P:o,maxBitrate:e})),Ee=({sipConnector:e})=>async({isP2P:t=!1}={})=>(s.logger("stopShareSipConnector"),e.stopPresentation({isP2P:t}).catch(s.logger)),Ce=1e6,Re=({sipConnector:e,maxBitrate:n=Ce})=>async({mediaStream:r,isP2P:o=!1})=>(s.logger("updatePresentation"),e.updatePresentation(r,{isP2P:o,maxBitrate:n})),he="ERROR_NOT_RUNNING",Me=e=>{const n=new Error("Promise was not running");return n.basePromise=e,n.id=he,n.name="Not running",n},ye=async(e,n)=>e.reduce(async(t,r)=>t.then(async({success:o,errors:c,results:a})=>(!n||n(r)?r():Promise.reject(Me(r))).then(u=>({errors:c,success:[...o,u],results:[...a,u],isSuccessful:!0,isError:!1})).catch(u=>({success:o,errors:[...c,u],results:[...a,u],isSuccessful:!1,isError:!0}))),Promise.resolve({success:[],errors:[],results:[],isSuccessful:!1,isError:!1})),Te=e=>n=>[...n].map(r=>async()=>e(r)),_e=async({accumulatedKeys:e,sendKey:n,canRunTask:t})=>{const o=Te(n)(e);return ye(o,t)},be=e=>t=>(s.logger("onStartMainCam"),e.onSession("admin-start-main-cam",t)),ve=e=>t=>(s.logger("onStartMic"),e.onSession("admin-start-mic",t)),Ne=e=>t=>(s.logger("onStopMainCam"),e.onSession("admin-stop-main-cam",t)),Oe=e=>t=>(s.logger("onStopMic"),e.onSession("admin-stop-mic",t)),Ae=({sipConnector:e})=>{const n=(M,R)=>({isSyncForced:T=!1})=>{if(T){M();return}R()},t=be(e),r=Ne(e),o=ve(e),c=Oe(e);let a=()=>{},u=()=>{},d=()=>{},C=()=>{};const f=({onStartMainCamForced:M,onStartMainCamNotForced:R,onStopMainCamForced:T,onStopMainCamNotForced:O,onStartMicForced:A,onStartMicNotForced:_,onStopMicForced:i,onStopMicNotForced:g})=>{const l=n(M,R);a=t(l);const h=n(T,O);u=r(h);const b=n(A,_);d=o(b);const N=n(i,g);C=c(N)},m=()=>{a(),u(),d(),C()};return{start:M=>{f(M)},stop:()=>{m()}}},Pe=Object.freeze(Object.defineProperty({__proto__:null,PURGATORY_CONFERENCE_NUMBER:x,createSyncMediaState:Ae,error:se,getExtraHeaders:oe,getUserAgent:ae,hasPurgatory:P,resolveAnswerIncomingCall:Q,resolveAskPermissionToEnableCam:ie,resolveCallToServer:Z,resolveConnectToServer:ee,resolveDisconnectFromServer:ne,resolveGetRemoteStreams:B,resolveOnMustStopPresentation:ue,resolveOnUseLicense:le,resolveSendMediaState:ge,resolveSendRefusalToTurnOnCam:Se,resolveSendRefusalToTurnOnMic:de,resolveStartPresentation:fe,resolveStopShareSipConnector:Ee,resolveUpdatePresentation:Re,resolveUpdateRemoteStreams:D,sendDTMFAccumulated:_e},Symbol.toStringTag,{value:"Module"})),pe=e=>[...e.keys()].map(n=>e.get(n)),Ie=(e,n)=>pe(e).find(t=>t.type===n),j=async e=>e.getStats().then(n=>{const t=Ie(n,"codec");return t==null?void 0:t.mimeType}),we=e=>e.find(n=>{var t;return((t=n==null?void 0:n.track)==null?void 0:t.kind)==="video"}),G=(e,n)=>e!==void 0&&n!==void 0&&e.toLowerCase().includes(n.toLowerCase()),Be="ERROR_NOT_RUNNING",De=e=>{const n=new Error("Promise was not running");return n.basePromise=e,n.id=Be,n.name="Not running",n},ke=async(e,n)=>e.reduce(async(t,r)=>t.then(async({success:o,errors:c,results:a})=>(!n||n(r)?r():Promise.reject(De(r))).then(u=>({errors:c,success:[...o,u],results:[...a,u],isSuccessful:!0,isError:!1})).catch(u=>({success:o,errors:[...c,u],results:[...a,u],isSuccessful:!1,isError:!0}))),Promise.resolve({success:[],errors:[],results:[],isSuccessful:!1,isError:!1})),Fe=new Error("Stack is empty"),I=e=>e[e.length-1],Ue=new Error("Promise is not actual"),Le=new Error("stackPromises only works with functions that returns a Promise"),xe=({noRejectIsNotActual:e=!1,noRunIsNotActual:n=!1}={})=>{const t=[],r=[],o=({task:i,index:g})=>{r.push({task:i,index:g})},c=(i,{task:g,index:l})=>{const h=r.find(({task:b,index:N})=>g===b&&l===N);if(!h)throw new Error("Task not found");if(h.promise)throw new Error("Task is already running");h.promise=i},a=({task:i,index:g})=>{const l=r.find(({task:h,index:b})=>i===h&&g===b);if(l)return l.promise},u=({task:i})=>{const g=I(r);return(g==null?void 0:g.task)===i},d=({task:i,index:g})=>(o({task:i,index:g}),async()=>{let l=a({task:i,index:g});const h=u({task:i});return!l&&n&&!h?Promise.resolve():(l||(l=i({isActual:h}),c(l,{task:i,index:g})),l)}),C=({resolve:i,reject:g})=>({results:l,isSuccessful:h})=>{const b=l.length,N=t.length;if(b===N){const S=I(l);if(h){i(S);return}g(S);return}if(e){const S=I(l);i(S);return}g(Ue)};let f=!1;const m=()=>{f=!0},y=()=>{f=!1},E=()=>f,M=async()=>(m(),ke(t,E)),R=async()=>{if(t.length===0)throw Fe;return new Promise((i,g)=>{const l=C({resolve:i,reject:g});M().then(l).catch(l)})},T=i=>{if(typeof i!="function")throw Le;const g=t.length;return t.push(d({task:i,index:g})),R},O=async i=>(T(i),R()),A=()=>{t.length=0,r.length=0},_=()=>{y(),A()};return R.add=T,R.run=O,R.stop=_,R},Ve=1e6,v=e=>e*Ve,X=v(.06),$e=v(4),je=e=>e<=64?X:e<=128?v(.12):e<=256?v(.25):e<=384?v(.32):e<=426?v(.38):e<=640?v(.5):e<=848?v(.7):e<=1280?v(1):e<=1920?v(2):$e,Ge="av1",Xe=e=>G(e,Ge),Ke=.6,K=(e,n)=>Xe(n)?e*Ke:e,We=e=>K(X,e),W=(e,n)=>{const t=je(e);return K(t,n)},H=xe(),He=async()=>H().catch(e=>{s.logger("videoSendingBalancer: error",e)}),qe=async e=>(H.add(e),He()),F=async({sender:e,scaleResolutionDownBy:n,maxBitrate:t,onSetParameters:r})=>qe(async()=>s.setEncodingsToSender(e,{scaleResolutionDownBy:n,maxBitrate:t},r)),Ye=async({sender:e,codec:n},t)=>{const o=We(n);return F({sender:e,maxBitrate:o,onSetParameters:t,scaleResolutionDownBy:200})},w=async({sender:e,track:n,codec:t},r)=>{const a=n.getSettings().width,u=W(a,t);return F({sender:e,maxBitrate:u,onSetParameters:r,scaleResolutionDownBy:1})},ze=async({sender:e,track:n,resolution:t,codec:r},o)=>{const c=n.getSettings(),a=c.width,u=c.height,[d,C]=t.split("x"),f=a/Number(d),m=u/Number(C),E=Math.max(f,m,1),M=W(Number(d),r);return F({sender:e,maxBitrate:M,onSetParameters:o,scaleResolutionDownBy:E})},Je=async({mainCam:e,resolutionMainCam:n,sender:t,track:r,codec:o},c)=>{switch(e){case s.EEventsMainCAM.PAUSE_MAIN_CAM:return Ye({sender:t,codec:o},c);case s.EEventsMainCAM.RESUME_MAIN_CAM:return w({sender:t,track:r,codec:o},c);case s.EEventsMainCAM.MAX_MAIN_CAM_RESOLUTION:return n!==void 0?ze({sender:t,track:r,codec:o,resolution:n},c):w({sender:t,track:r,codec:o},c);default:return w({sender:t,track:r,codec:o},c)}},U={isChanged:!1,parameters:{encodings:[{}],transactionId:"0",codecs:[],headerExtensions:[],rtcp:{}}},L=async({mainCam:e,resolutionMainCam:n,connection:t,onSetParameters:r,ignoreForCodec:o})=>{const c=t.getSenders(),a=we(c);if(!(a!=null&&a.track))return U;const u=await j(a);return G(u,o)?U:Je({mainCam:e,resolutionMainCam:n,sender:a,codec:u,track:a.track},r)},Qe=(e,{ignoreForCodec:n,onSetParameters:t}={})=>{const r=async()=>{const{connection:d}=e;if(!d)throw new Error("connection is not exist");return L({connection:d,onSetParameters:t,ignoreForCodec:n})};let o=r;const c=async d=>(o=async()=>{const{mainCam:C,resolutionMainCam:f}=d,{connection:m}=e;if(!m)throw new Error("connection is not exist");return L({mainCam:C,resolutionMainCam:f,connection:m,onSetParameters:t,ignoreForCodec:n})},o());return{subscribe:()=>{e.onSession("main-cam-control",c)},unsubscribe:()=>{e.offSession("main-cam-control",c)},balanceByTrack:r,resetMainCamControl(){o=r},async reBalance(){return o()}}};exports.EEventsMainCAM=s.EEventsMainCAM;exports.EEventsMic=s.EEventsMic;exports.EEventsSyncMediaState=s.EEventsSyncMediaState;exports.EUseLicense=s.EUseLicense;exports.causes=s.causes;exports.constants=s.constants;exports.default=s.SipConnector;exports.disableDebug=s.disableDebug;exports.enableDebug=s.enableDebug;exports.eventNames=s.eventNames;exports.hasCanceledCallError=s.hasCanceledCallError;exports.debug=z;exports.getCodecFromSender=j;exports.resolveVideoSendingBalancer=Qe;exports.tools=Pe;
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { l as c, B as V, N as $, E as P, s as q, S as nn } from "./SipConnector-
|
|
2
|
-
import { f as
|
|
1
|
+
import { l as c, B as V, N as $, E as P, s as q, S as nn } from "./SipConnector-1HoiCnsj.js";
|
|
2
|
+
import { f as un, g as ln, i as Sn, c as dn, a as mn, d as fn, b as Cn, e as En, h as gn } from "./SipConnector-1HoiCnsj.js";
|
|
3
3
|
import { debounce as J } from "ts-debounce";
|
|
4
4
|
import { isCanceledError as Q } from "@krivega/cancelable-promise";
|
|
5
|
-
import { default as
|
|
6
|
-
import "events-constructor";
|
|
5
|
+
import { default as hn } from "debug";
|
|
7
6
|
const G = "purgatory", A = (e) => e === G, k = (e) => () => (c("getRemoteStreams"), e.getRemoteStreams()), Z = ({ kind: e, readyState: n }) => e === "video" && n === "live", j = (e) => ({ track: n }) => {
|
|
8
7
|
Z(n) && e();
|
|
9
8
|
}, D = ({
|
|
@@ -20,16 +19,16 @@ const G = "purgatory", A = (e) => e === G, k = (e) => () => (c("getRemoteStreams
|
|
|
20
19
|
degradationPreference: a,
|
|
21
20
|
setRemoteStreams: u,
|
|
22
21
|
onBeforeProgressCall: m,
|
|
23
|
-
onSuccessProgressCall:
|
|
22
|
+
onSuccessProgressCall: g,
|
|
24
23
|
onEnterPurgatory: C,
|
|
25
24
|
onEnterConference: f,
|
|
26
25
|
onFailProgressCall: T,
|
|
27
|
-
onFinishProgressCall:
|
|
26
|
+
onFinishProgressCall: E,
|
|
28
27
|
onEndedCall: y
|
|
29
|
-
} = t,
|
|
28
|
+
} = t, R = D({
|
|
30
29
|
setRemoteStreams: u,
|
|
31
30
|
getRemoteStreams: k(e)
|
|
32
|
-
}), M = j(
|
|
31
|
+
}), M = j(R);
|
|
33
32
|
c("answerIncomingCall", t);
|
|
34
33
|
const v = async () => e.answerToIncomingCall({
|
|
35
34
|
mediaStream: s,
|
|
@@ -45,18 +44,18 @@ const G = "purgatory", A = (e) => e === G, k = (e) => () => (c("getRemoteStreams
|
|
|
45
44
|
const l = (c("subscribeEnterConference: onEnterConference", f), C ?? f ? e.onSession("enterRoom", (d) => {
|
|
46
45
|
c("enterRoom", { _room: d, isSuccessProgressCall: _ }), i = d, A(i) ? C && C() : f && f({ isSuccessProgressCall: _ });
|
|
47
46
|
}) : () => {
|
|
48
|
-
}),
|
|
47
|
+
}), h = (d) => (c("onSuccess"), _ = !0, R(), g && g({ isPurgatory: A(i) }), e.onceRaceSession(["ended", "failed"], () => {
|
|
49
48
|
l(), y && y();
|
|
50
49
|
}), d), b = (d) => {
|
|
51
50
|
throw c("onFail"), T && T(), l(), d;
|
|
52
51
|
}, O = () => {
|
|
53
|
-
c("onFinish"),
|
|
52
|
+
c("onFinish"), E && E();
|
|
54
53
|
};
|
|
55
54
|
if (c("onBeforeProgressCall"), m) {
|
|
56
55
|
const d = p();
|
|
57
56
|
m(d);
|
|
58
57
|
}
|
|
59
|
-
return v().then(
|
|
58
|
+
return v().then(h).catch(b).finally(O);
|
|
60
59
|
}, ne = (e) => async (t) => {
|
|
61
60
|
const {
|
|
62
61
|
conference: s,
|
|
@@ -65,13 +64,13 @@ const G = "purgatory", A = (e) => e === G, k = (e) => () => (c("getRemoteStreams
|
|
|
65
64
|
iceServers: a,
|
|
66
65
|
degradationPreference: u,
|
|
67
66
|
setRemoteStreams: m,
|
|
68
|
-
onBeforeProgressCall:
|
|
67
|
+
onBeforeProgressCall: g,
|
|
69
68
|
onSuccessProgressCall: C,
|
|
70
69
|
onEnterPurgatory: f,
|
|
71
70
|
onEnterConference: T,
|
|
72
|
-
onFailProgressCall:
|
|
71
|
+
onFailProgressCall: E,
|
|
73
72
|
onFinishProgressCall: y,
|
|
74
|
-
onEndedCall:
|
|
73
|
+
onEndedCall: R
|
|
75
74
|
} = t, M = D({
|
|
76
75
|
setRemoteStreams: m,
|
|
77
76
|
getRemoteStreams: k(e)
|
|
@@ -89,18 +88,18 @@ const G = "purgatory", A = (e) => e === G, k = (e) => () => (c("getRemoteStreams
|
|
|
89
88
|
const l = (c("subscribeEnterConference: onEnterConference", T), f ?? T ? e.onSession("enterRoom", (d) => {
|
|
90
89
|
c("enterRoom", { _room: d, isSuccessProgressCall: _ }), i = d, A(i) ? f && f() : T && T({ isSuccessProgressCall: _ });
|
|
91
90
|
}) : () => {
|
|
92
|
-
}),
|
|
93
|
-
l(),
|
|
91
|
+
}), h = (d) => (c("onSuccess"), _ = !0, M(), C && C({ isPurgatory: A(i) }), e.onceRaceSession(["ended", "failed"], () => {
|
|
92
|
+
l(), R && R();
|
|
94
93
|
}), d), b = (d) => {
|
|
95
|
-
throw c("onFail"),
|
|
94
|
+
throw c("onFail"), E && E(), l(), d;
|
|
96
95
|
}, O = () => {
|
|
97
96
|
c("onFinish"), y && y();
|
|
98
97
|
};
|
|
99
|
-
return c("onBeforeProgressCall"),
|
|
98
|
+
return c("onBeforeProgressCall"), g && g(s), p().then(h).catch(b).finally(O);
|
|
100
99
|
}, w = (e) => {
|
|
101
100
|
if (!Q(e))
|
|
102
101
|
throw e;
|
|
103
|
-
return !1;
|
|
102
|
+
return { isSuccessful: !1 };
|
|
104
103
|
}, te = (e) => async (t) => {
|
|
105
104
|
const {
|
|
106
105
|
userAgent: s,
|
|
@@ -109,7 +108,7 @@ const G = "purgatory", A = (e) => e === G, k = (e) => () => (c("getRemoteStreams
|
|
|
109
108
|
remoteAddress: a,
|
|
110
109
|
displayName: u,
|
|
111
110
|
name: m,
|
|
112
|
-
password:
|
|
111
|
+
password: g,
|
|
113
112
|
isRegisteredUser: C,
|
|
114
113
|
sdpSemantics: f,
|
|
115
114
|
isDisconnectOnFail: T
|
|
@@ -121,11 +120,11 @@ const G = "purgatory", A = (e) => e === G, k = (e) => () => (c("getRemoteStreams
|
|
|
121
120
|
sipServerUrl: o,
|
|
122
121
|
remoteAddress: a,
|
|
123
122
|
displayName: u,
|
|
124
|
-
password:
|
|
123
|
+
password: g,
|
|
125
124
|
user: m,
|
|
126
125
|
register: C
|
|
127
|
-
}).then(() => (c("connectToServer then"), !0)).catch(async (
|
|
128
|
-
}, se = (e) => async () => (c("disconnectFromServer"), e.disconnect().then(() => (c("disconnectFromServer: then"), !
|
|
126
|
+
}).then((E) => (c("connectToServer then"), { ua: E, isSuccessful: !0 })).catch(async (E) => (c("connectToServer catch: error", E), T === !0 ? e.disconnect().then(() => w(E)).catch(() => w(E)) : w(E)));
|
|
127
|
+
}, se = (e) => async () => (c("disconnectFromServer"), e.disconnect().then(() => (c("disconnectFromServer: then"), { isSuccessful: !0 })).catch((n) => (c("disconnectFromServer: catch", n), { isSuccessful: !1 }))), F = (e) => {
|
|
129
128
|
const { url: n, cause: t } = e;
|
|
130
129
|
let s = n;
|
|
131
130
|
return (t === V || t === $) && (s = `${e.message.to.uri.user}@${e.message.to.uri.host}`), s;
|
|
@@ -256,21 +255,21 @@ const re = (e = new Error()) => {
|
|
|
256
255
|
const r = be(n)(e);
|
|
257
256
|
return _e(r, t);
|
|
258
257
|
}, Oe = (e) => (t) => (c("onStartMainCam"), e.onSession("admin-start-main-cam", t)), ve = (e) => (t) => (c("onStartMic"), e.onSession("admin-start-mic", t)), pe = (e) => (t) => (c("onStopMainCam"), e.onSession("admin-stop-main-cam", t)), Ae = (e) => (t) => (c("onStopMic"), e.onSession("admin-stop-mic", t)), Pe = ({ sipConnector: e }) => {
|
|
259
|
-
const n = (y,
|
|
258
|
+
const n = (y, R) => ({ isSyncForced: M = !1 }) => {
|
|
260
259
|
if (M) {
|
|
261
260
|
y();
|
|
262
261
|
return;
|
|
263
262
|
}
|
|
264
|
-
|
|
263
|
+
R();
|
|
265
264
|
}, t = Oe(e), s = pe(e), r = ve(e), o = Ae(e);
|
|
266
265
|
let a = () => {
|
|
267
266
|
}, u = () => {
|
|
268
267
|
}, m = () => {
|
|
269
|
-
},
|
|
268
|
+
}, g = () => {
|
|
270
269
|
};
|
|
271
270
|
const C = ({
|
|
272
271
|
onStartMainCamForced: y,
|
|
273
|
-
onStartMainCamNotForced:
|
|
272
|
+
onStartMainCamNotForced: R,
|
|
274
273
|
onStopMainCamForced: M,
|
|
275
274
|
onStopMainCamNotForced: v,
|
|
276
275
|
onStartMicForced: p,
|
|
@@ -280,20 +279,20 @@ const re = (e = new Error()) => {
|
|
|
280
279
|
}) => {
|
|
281
280
|
const l = n(
|
|
282
281
|
y,
|
|
283
|
-
|
|
282
|
+
R
|
|
284
283
|
);
|
|
285
284
|
a = t(l);
|
|
286
|
-
const
|
|
285
|
+
const h = n(
|
|
287
286
|
M,
|
|
288
287
|
v
|
|
289
288
|
);
|
|
290
|
-
u = s(
|
|
289
|
+
u = s(h);
|
|
291
290
|
const b = n(p, _);
|
|
292
291
|
m = r(b);
|
|
293
292
|
const O = n(i, S);
|
|
294
|
-
|
|
293
|
+
g = o(O);
|
|
295
294
|
}, f = () => {
|
|
296
|
-
a(), u(), m(),
|
|
295
|
+
a(), u(), m(), g();
|
|
297
296
|
};
|
|
298
297
|
return {
|
|
299
298
|
start: (y) => {
|
|
@@ -303,7 +302,7 @@ const re = (e = new Error()) => {
|
|
|
303
302
|
f();
|
|
304
303
|
}
|
|
305
304
|
};
|
|
306
|
-
},
|
|
305
|
+
}, rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
307
306
|
__proto__: null,
|
|
308
307
|
PURGATORY_CONFERENCE_NUMBER: G,
|
|
309
308
|
createSyncMediaState: Pe,
|
|
@@ -366,17 +365,17 @@ const re = (e = new Error()) => {
|
|
|
366
365
|
const t = [], s = [], r = ({ task: i, index: S }) => {
|
|
367
366
|
s.push({ task: i, index: S });
|
|
368
367
|
}, o = (i, { task: S, index: l }) => {
|
|
369
|
-
const
|
|
370
|
-
if (!
|
|
368
|
+
const h = s.find(({ task: b, index: O }) => S === b && l === O);
|
|
369
|
+
if (!h)
|
|
371
370
|
throw new Error("Task not found");
|
|
372
|
-
if (
|
|
371
|
+
if (h.promise)
|
|
373
372
|
throw new Error("Task is already running");
|
|
374
|
-
|
|
373
|
+
h.promise = i;
|
|
375
374
|
}, a = ({
|
|
376
375
|
task: i,
|
|
377
376
|
index: S
|
|
378
377
|
}) => {
|
|
379
|
-
const l = s.find(({ task:
|
|
378
|
+
const l = s.find(({ task: h, index: b }) => i === h && S === b);
|
|
380
379
|
if (l)
|
|
381
380
|
return l.promise;
|
|
382
381
|
}, u = ({ task: i }) => {
|
|
@@ -384,16 +383,16 @@ const re = (e = new Error()) => {
|
|
|
384
383
|
return (S == null ? void 0 : S.task) === i;
|
|
385
384
|
}, m = ({ task: i, index: S }) => (r({ task: i, index: S }), async () => {
|
|
386
385
|
let l = a({ task: i, index: S });
|
|
387
|
-
const
|
|
388
|
-
return !l && n && !
|
|
389
|
-
}),
|
|
386
|
+
const h = u({ task: i });
|
|
387
|
+
return !l && n && !h ? Promise.resolve() : (l || (l = i({ isActual: h }), o(l, { task: i, index: S })), l);
|
|
388
|
+
}), g = ({
|
|
390
389
|
resolve: i,
|
|
391
390
|
reject: S
|
|
392
|
-
}) => ({ results: l, isSuccessful:
|
|
391
|
+
}) => ({ results: l, isSuccessful: h }) => {
|
|
393
392
|
const b = l.length, O = t.length;
|
|
394
393
|
if (b === O) {
|
|
395
394
|
const d = I(l);
|
|
396
|
-
if (
|
|
395
|
+
if (h) {
|
|
397
396
|
i(d);
|
|
398
397
|
return;
|
|
399
398
|
}
|
|
@@ -412,24 +411,24 @@ const re = (e = new Error()) => {
|
|
|
412
411
|
C = !0;
|
|
413
412
|
}, T = () => {
|
|
414
413
|
C = !1;
|
|
415
|
-
},
|
|
414
|
+
}, E = () => C, y = async () => (f(), Ue(t, E)), R = async () => {
|
|
416
415
|
if (t.length === 0)
|
|
417
416
|
throw Le;
|
|
418
417
|
return new Promise((i, S) => {
|
|
419
|
-
const l =
|
|
418
|
+
const l = g({ resolve: i, reject: S });
|
|
420
419
|
y().then(l).catch(l);
|
|
421
420
|
});
|
|
422
421
|
}, M = (i) => {
|
|
423
422
|
if (typeof i != "function")
|
|
424
423
|
throw Ve;
|
|
425
424
|
const S = t.length;
|
|
426
|
-
return t.push(m({ task: i, index: S })),
|
|
427
|
-
}, v = async (i) => (M(i),
|
|
425
|
+
return t.push(m({ task: i, index: S })), R;
|
|
426
|
+
}, v = async (i) => (M(i), R()), p = () => {
|
|
428
427
|
t.length = 0, s.length = 0;
|
|
429
428
|
}, _ = () => {
|
|
430
429
|
T(), p();
|
|
431
430
|
};
|
|
432
|
-
return
|
|
431
|
+
return R.add = M, R.run = v, R.stop = _, R;
|
|
433
432
|
}, Ge = 1e6, N = (e) => e * Ge, W = N(0.06), je = N(4), Xe = (e) => e <= 64 ? W : e <= 128 ? N(0.12) : e <= 256 ? N(0.25) : e <= 384 ? N(0.32) : e <= 426 ? N(0.38) : e <= 640 ? N(0.5) : e <= 848 ? N(0.7) : e <= 1280 ? N(1) : e <= 1920 ? N(2) : je, Ke = "av1", We = (e) => K(e, Ke), He = 0.6, H = (e, n) => We(n) ? e * He : e, Ye = (e) => H(W, e), Y = (e, n) => {
|
|
434
433
|
const t = Xe(e);
|
|
435
434
|
return H(t, n);
|
|
@@ -462,12 +461,12 @@ const re = (e = new Error()) => {
|
|
|
462
461
|
resolution: t,
|
|
463
462
|
codec: s
|
|
464
463
|
}, r) => {
|
|
465
|
-
const o = n.getSettings(), a = o.width, u = o.height, [m,
|
|
464
|
+
const o = n.getSettings(), a = o.width, u = o.height, [m, g] = t.split("x"), C = a / Number(m), f = u / Number(g), E = Math.max(C, f, 1), y = Y(Number(m), s);
|
|
466
465
|
return U({
|
|
467
466
|
sender: e,
|
|
468
467
|
maxBitrate: y,
|
|
469
468
|
onSetParameters: r,
|
|
470
|
-
scaleResolutionDownBy:
|
|
469
|
+
scaleResolutionDownBy: E
|
|
471
470
|
});
|
|
472
471
|
}, Ze = async ({
|
|
473
472
|
mainCam: e,
|
|
@@ -513,7 +512,7 @@ const re = (e = new Error()) => {
|
|
|
513
512
|
{ mainCam: e, resolutionMainCam: n, sender: a, codec: u, track: a.track },
|
|
514
513
|
s
|
|
515
514
|
);
|
|
516
|
-
},
|
|
515
|
+
}, on = (e, {
|
|
517
516
|
ignoreForCodec: n,
|
|
518
517
|
onSetParameters: t
|
|
519
518
|
} = {}) => {
|
|
@@ -529,11 +528,11 @@ const re = (e = new Error()) => {
|
|
|
529
528
|
};
|
|
530
529
|
let r = s;
|
|
531
530
|
const o = async (m) => (r = async () => {
|
|
532
|
-
const { mainCam:
|
|
531
|
+
const { mainCam: g, resolutionMainCam: C } = m, { connection: f } = e;
|
|
533
532
|
if (!f)
|
|
534
533
|
throw new Error("connection is not exist");
|
|
535
534
|
return x({
|
|
536
|
-
mainCam:
|
|
535
|
+
mainCam: g,
|
|
537
536
|
resolutionMainCam: C,
|
|
538
537
|
connection: f,
|
|
539
538
|
onSetParameters: t,
|
|
@@ -558,18 +557,18 @@ const re = (e = new Error()) => {
|
|
|
558
557
|
};
|
|
559
558
|
export {
|
|
560
559
|
P as EEventsMainCAM,
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
560
|
+
un as EEventsMic,
|
|
561
|
+
ln as EEventsSyncMediaState,
|
|
562
|
+
Sn as EUseLicense,
|
|
563
|
+
dn as causes,
|
|
564
|
+
mn as constants,
|
|
565
|
+
hn as debug,
|
|
567
566
|
nn as default,
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
567
|
+
fn as disableDebug,
|
|
568
|
+
Cn as enableDebug,
|
|
569
|
+
En as eventNames,
|
|
571
570
|
Be as getCodecFromSender,
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
571
|
+
gn as hasCanceledCallError,
|
|
572
|
+
on as resolveVideoSendingBalancer,
|
|
573
|
+
rn as tools
|
|
575
574
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { URI } from '@krivega/jssip';
|
|
1
2
|
export declare const LOCKED_SIP_WEB_SOCKET_SERVER_URL = "LOCKED_SIP_WEB_SOCKET_SERVER_URL";
|
|
2
3
|
export declare const dataForConnectionWithAuthorization: {
|
|
3
4
|
password: string;
|
|
@@ -98,7 +99,7 @@ export declare const dataForConnectionWithAuthorizationPasswordChanged: {
|
|
|
98
99
|
};
|
|
99
100
|
export declare const uaConfigurationWithAuthorization: {
|
|
100
101
|
password: string;
|
|
101
|
-
uri:
|
|
102
|
+
uri: URI;
|
|
102
103
|
display_name: string;
|
|
103
104
|
register: boolean;
|
|
104
105
|
session_timers: boolean;
|
|
@@ -111,7 +112,7 @@ export declare const uaConfigurationWithAuthorization: {
|
|
|
111
112
|
};
|
|
112
113
|
export declare const uaConfigurationWithAuthorizationPasswordChanged: {
|
|
113
114
|
password: string;
|
|
114
|
-
uri:
|
|
115
|
+
uri: URI;
|
|
115
116
|
display_name: string;
|
|
116
117
|
register: boolean;
|
|
117
118
|
session_timers: boolean;
|
|
@@ -125,5 +126,5 @@ export declare const uaConfigurationWithAuthorizationPasswordChanged: {
|
|
|
125
126
|
export declare const oneWord = "a";
|
|
126
127
|
export declare const twoWord = "ab";
|
|
127
128
|
export declare const thirdWord = "abc";
|
|
128
|
-
export declare const uriWithName: (name: string) =>
|
|
129
|
+
export declare const uriWithName: (name: string, url?: string) => URI;
|
|
129
130
|
export { uaConfigurationWithoutAuthorization, uaConfigurationWithoutAuthorizationWithoutDisplayName, } from '../../__fixtures__';
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* @param {string} uri The uri for check
|
|
5
|
-
* @param {string} url The base url
|
|
6
|
-
* @returns {boolean} True if has valid uri, False otherwise.
|
|
7
|
-
*/
|
|
8
|
-
declare const hasValidUri: (uri: string, url?: string) => boolean;
|
|
1
|
+
import type { URI } from '@krivega/jssip';
|
|
2
|
+
declare const hasValidUri: ({ scheme, user, host }: URI, url?: string) => boolean;
|
|
9
3
|
export default hasValidUri;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { UA } from '@krivega/jssip';
|
|
1
2
|
import type SipConnector from '../SipConnector';
|
|
2
3
|
declare const resolveConnectToServer: (sipConnector: SipConnector) => (parameters: {
|
|
3
4
|
userAgent: string;
|
|
@@ -10,5 +11,8 @@ declare const resolveConnectToServer: (sipConnector: SipConnector) => (parameter
|
|
|
10
11
|
isRegisteredUser?: boolean;
|
|
11
12
|
isDisconnectOnFail?: boolean;
|
|
12
13
|
sdpSemantics: 'plan-b' | 'unified-plan';
|
|
13
|
-
}) => Promise<
|
|
14
|
+
}) => Promise<{
|
|
15
|
+
ua?: UA;
|
|
16
|
+
isSuccessful: boolean;
|
|
17
|
+
}>;
|
|
14
18
|
export default resolveConnectToServer;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import type SipConnector from '../SipConnector';
|
|
2
|
-
declare const resolveDisconnectFromServer: (sipConnector: SipConnector) => () => Promise<
|
|
2
|
+
declare const resolveDisconnectFromServer: (sipConnector: SipConnector) => () => Promise<{
|
|
3
|
+
isSuccessful: boolean;
|
|
4
|
+
} | {
|
|
5
|
+
isSuccessful: boolean;
|
|
6
|
+
}>;
|
|
3
7
|
export default resolveDisconnectFromServer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sip-connector",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.24.1",
|
|
4
4
|
"description": "Module for connect to Vinteo server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webrtc",
|
|
@@ -63,35 +63,35 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@krivega/cancelable-promise": "^1.1.0",
|
|
66
|
-
"@krivega/jssip": "^3.23.
|
|
66
|
+
"@krivega/jssip": "^3.23.8",
|
|
67
67
|
"debug": "^4.3.4",
|
|
68
68
|
"events-constructor": "^1.2.2",
|
|
69
|
-
"sequent-promises": "^1.0.
|
|
69
|
+
"sequent-promises": "^1.0.2",
|
|
70
70
|
"stack-promises": "^1.0.2",
|
|
71
71
|
"ts-debounce": "^4.0.0",
|
|
72
72
|
"webrtc-mock": "^1.0.2"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@babel/preset-typescript": "^7.23.3",
|
|
76
|
-
"@commitlint/cli": "^
|
|
77
|
-
"@commitlint/config-conventional": "^
|
|
76
|
+
"@commitlint/cli": "^19.0.1",
|
|
77
|
+
"@commitlint/config-conventional": "^19.0.0",
|
|
78
78
|
"@nabla/vite-plugin-eslint": "^2.0.2",
|
|
79
79
|
"@types/debug": "^4.1.12",
|
|
80
80
|
"@types/jest": "^29.5.12",
|
|
81
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
82
|
-
"@typescript-eslint/parser": "^
|
|
81
|
+
"@typescript-eslint/eslint-plugin": "^7.1.0",
|
|
82
|
+
"@typescript-eslint/parser": "^7.1.0",
|
|
83
83
|
"cross-env": "^7.0.3",
|
|
84
|
-
"eslint": "^8.
|
|
84
|
+
"eslint": "^8.57.0",
|
|
85
85
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
86
86
|
"eslint-config-airbnb-typescript": "^17.1.0",
|
|
87
87
|
"eslint-config-prettier": "^9.1.0",
|
|
88
88
|
"eslint-import-resolver-typescript": "^3.6.1",
|
|
89
89
|
"eslint-plugin-flowtype": "^8.0.3",
|
|
90
90
|
"eslint-plugin-import": "^2.29.1",
|
|
91
|
-
"eslint-plugin-jest": "^27.
|
|
91
|
+
"eslint-plugin-jest": "^27.9.0",
|
|
92
92
|
"eslint-plugin-prettier": "^5.1.3",
|
|
93
93
|
"eslint-plugin-unicorn": "^51.0.1",
|
|
94
|
-
"husky": "^9.0.
|
|
94
|
+
"husky": "^9.0.11",
|
|
95
95
|
"jest": "^29.7.0",
|
|
96
96
|
"jest-environment-jsdom": "^29.7.0",
|
|
97
97
|
"jest-extended": "^4.0.2",
|
|
@@ -103,8 +103,8 @@
|
|
|
103
103
|
"ts-node": "^10.9.2",
|
|
104
104
|
"tsc-files": "^1.1.4",
|
|
105
105
|
"typescript": "^5.3.3",
|
|
106
|
-
"vite": "^5.
|
|
107
|
-
"vite-plugin-dts": "^3.7.
|
|
106
|
+
"vite": "^5.1.4",
|
|
107
|
+
"vite-plugin-dts": "^3.7.3",
|
|
108
108
|
"vite-tsconfig-paths": "^4.3.1"
|
|
109
109
|
},
|
|
110
110
|
"peerDependencies": {
|