sip-connector 6.22.2 → 6.22.3

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/doMock.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var N=Object.defineProperty;var O=(o,t,e)=>t in o?N(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var r=(o,t,e)=>(O(o,typeof t!="symbol"?t+"":t,e),e);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("./SipConnector-4TW1xlov.cjs"),W=require("@krivega/jssip/lib/NameAddrHeader"),k=require("@krivega/jssip/lib/URI"),D=require("node:events"),L=require("@krivega/jssip/lib/SIPMessage"),M=require("webrtc-mock"),R=require("events-constructor");require("@krivega/cancelable-promise");require("debug");class C extends L.IncomingRequest{constructor(e){super();r(this,"headers");this.headers=new Headers(e)}getHeader(e){return this.headers.get(e)||""}}class P{constructor({originator:t="local",eventHandlers:e}){r(this,"originator");r(this,"_connection");r(this,"_events");r(this,"_remote_identity");r(this,"_mutedOptions",{audio:!1,video:!1});this.originator=t,this._events=new R(h.SESSION_EVENT_NAMES),this.initEvents(e)}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(t){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(t){throw new Error("Method not implemented.")}terminate(t){throw new Error("Method not implemented.")}async sendInfo(t,e,n){throw new Error("Method not implemented.")}hold(t,e){throw new Error("Method not implemented.")}unhold(t,e){throw new Error("Method not implemented.")}async renegotiate(t,e){throw new Error("Method not implemented.")}isOnHold(){throw new Error("Method not implemented.")}mute(t){throw new Error("Method not implemented.")}unmute(t){throw new Error("Method not implemented.")}isMuted(){throw new Error("Method not implemented.")}refer(t,e){throw new Error("Method not implemented.")}resetLocalMedia(){throw new Error("Method not implemented.")}async replaceMediaStream(t,e){throw new Error("Method not implemented.")}addListener(t,e){throw new Error("Method not implemented.")}once(t,e){throw new Error("Method not implemented.")}removeListener(t,e){throw new Error("Method not implemented.")}off(t,e){throw new Error("Method not implemented.")}removeAllListeners(t){throw new Error("Method not implemented.")}setMaxListeners(t){throw new Error("Method not implemented.")}getMaxListeners(){throw new Error("Method not implemented.")}listeners(t){throw new Error("Method not implemented.")}rawListeners(t){throw new Error("Method not implemented.")}emit(t,...e){throw new Error("Method not implemented.")}listenerCount(t){throw new Error("Method not implemented.")}prependListener(t,e){throw new Error("Method not implemented.")}prependOnceListener(t,e){throw new Error("Method not implemented.")}eventNames(){throw new Error("Method not implemented.")}initEvents(t=[]){Object.entries(t).forEach(([e,n])=>this.on(e,n))}on(t,e){return this._events.on(t,e),this}trigger(t,e){this._events.trigger(t,e)}sendDTMF(){this.trigger("newDTMF",{originator:this.originator})}async startPresentation(t){return t}async updatePresentation(t){return t}async stopPresentation(t){return t}isEstablished(){return!0}}class b{constructor(t,e){r(this,"_senders",[]);r(this,"_receivers",[]);r(this,"canTrickleIceCandidates");r(this,"connectionState");r(this,"currentLocalDescription");r(this,"currentRemoteDescription");r(this,"iceConnectionState");r(this,"iceGatheringState");r(this,"idpErrorInfo");r(this,"idpLoginUrl");r(this,"localDescription");r(this,"onconnectionstatechange");r(this,"ondatachannel");r(this,"onicecandidate");r(this,"onicecandidateerror",null);r(this,"oniceconnectionstatechange");r(this,"onicegatheringstatechange");r(this,"onnegotiationneeded");r(this,"onsignalingstatechange");r(this,"ontrack");r(this,"peerIdentity");r(this,"pendingLocalDescription");r(this,"pendingRemoteDescription");r(this,"remoteDescription");r(this,"sctp",null);r(this,"signalingState");r(this,"getReceivers",()=>this._receivers);r(this,"getSenders",()=>this._senders);r(this,"addTrack",t=>{const e={track:t};return this._senders.push(e),e});this._receivers=e.map(n=>({track:n}))}getRemoteStreams(){throw new Error("Method not implemented.")}async addIceCandidate(t){throw new Error("Method not implemented.")}addTransceiver(t,e){throw new Error("Method not implemented.")}close(){throw new Error("Method not implemented.")}restartIce(){throw new Error("Method not implemented.")}async createAnswer(t,e){throw new Error("Method not implemented.")}createDataChannel(t,e){throw new Error("Method not implemented.")}async createOffer(t,e,n){throw new Error("Method not implemented.")}getConfiguration(){throw new Error("Method not implemented.")}async getIdentityAssertion(){throw new Error("Method not implemented.")}async getStats(t){throw new Error("Method not implemented.")}getTransceivers(){throw new Error("Method not implemented.")}removeTrack(t){throw new Error("Method not implemented.")}setConfiguration(t){throw new Error("Method not implemented.")}async setLocalDescription(t){throw new Error("Method not implemented.")}async setRemoteDescription(t){throw new Error("Method not implemented.")}addEventListener(t,e,n){throw new Error("Method not implemented.")}removeEventListener(t,e,n){throw new Error("Method not implemented.")}dispatchEvent(t){throw new Error("Method not implemented.")}}function F(o){const t=o.match(/[\d.]+/g);if(!t)throw new Error("wrong sip url");return t[0]}const g=400,S="777",V=o=>o.getVideoTracks().length>0;class T extends P{constructor({url:e="",mediaStream:n,eventHandlers:i,originator:d}){super({originator:d,eventHandlers:i});r(this,"url");r(this,"status_code");r(this,"_isEnded",!1);r(this,"answer",jest.fn(({mediaStream:e})=>{if(this.originator!=="remote")throw new Error("answer available only for remote sessions");this.initPeerconnection(e),setTimeout(()=>{this.trigger("connecting"),setTimeout(()=>{this.trigger("accepted")},100),setTimeout(()=>{this.trigger("confirmed")},200)},g)}));this.url=e,this.initPeerconnection(n)}initPeerconnection(e){return e?(this.createPeerconnection(e),!0):!1}createPeerconnection(e){const n=M.createAudioMediaStreamTrackMock();n.id="mainaudio1";const i=[n];if(V(e)){const f=M.createVideoMediaStreamTrackMock();f.id="mainvideo1",i.push(f)}this._connection=new b(void 0,i),this._addStream(e),setTimeout(()=>{this.trigger("peerconnection",{peerconnection:this.connection})},g)}connect(e){const n=F(e);setTimeout(()=>{this.url.includes(S)?this.trigger("failed",{originator:"remote",message:"IncomingResponse",cause:h.REJECTED}):(this.trigger("connecting"),setTimeout(()=>{this.trigger("enterRoom",n)},100),setTimeout(()=>{this.trigger("accepted")},200),setTimeout(()=>{this.trigger("confirmed")},300))},g)}terminate({status_code:e}={}){return this.status_code=e,this.trigger("ended",{status_code:e}),this._isEnded=!1,this}terminateRemote({status_code:e}={}){return this.status_code=e,this.trigger("ended",{status_code:e,originator:"remote"}),this}_addStream(e,n="getTracks"){e[n]().forEach(i=>this.connection.addTrack(i))}_forEachSenders(e){const n=this.connection.getSenders();for(const i of n)e(i);return n}_toggleMuteAudio(e){this._forEachSenders(({track:n})=>{n&&n.kind==="audio"&&(n.enabled=!e)})}_toggleMuteVideo(e){this._forEachSenders(({track:n})=>{n&&n.kind==="video"&&(n.enabled=!e)})}mute(e){e.audio&&(this._mutedOptions.audio=!0,this._toggleMuteAudio(this._mutedOptions.audio)),e.video&&(this._mutedOptions.video=!0,this._toggleMuteVideo(this._mutedOptions.video)),this._onmute(e)}unmute(e){e.audio&&(this._mutedOptions.audio=!1),e.video&&(this._mutedOptions.video=!1),this.trigger("unmuted",e)}isMuted(){return this._mutedOptions}async replaceMediaStream(e){return e}_onmute({audio:e,video:n}){this.trigger("muted",{audio:e,video:n})}async sendInfo(){}isEnded(){return this._isEnded}newInfo(e){this.trigger("newInfo",e)}}class U{constructor(){r(this,"extraHeaders")}setExtraHeaders(t){this.extraHeaders=t}setExtraContactParams(){}}const s="PASSWORD_CORRECT",_="PASSWORD_CORRECT_2",v="NAME_INCORRECT",c=400;class z{constructor(t){r(this,"_events");r(this,"_startedTimeout");r(this,"_stopedTimeout");r(this,"session");r(this,"_isRegistered");r(this,"_isConnected");r(this,"configuration");r(this,"_registrator");r(this,"call",jest.fn((t,e)=>{const{mediaStream:n,eventHandlers:i}=e;return this.session=new T({url:t,mediaStream:n,eventHandlers:i,originator:"local"}),this.session.connect(t),this.session}));this._events=new R(h.UA_EVENT_NAMES),this.configuration=t,this._registrator=new U}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(t,e){return this._events.on(t,e),this}trigger(t,e){this._events.trigger(t,e)}terminateSessions(){this.session.terminate()}set(t,e){return this.configuration[t]=e,!0}register(){this._startedTimeout&&clearTimeout(this._startedTimeout);const{password:t,register:e,uri:n}=this.configuration;e&&n.includes(v)?(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Request Timeout"})},c)):!this._isRegistered&&e&&(t===s||t===_)?(this._isRegistered=!0,this._startedTimeout=setTimeout(()=>{this.trigger("registered")},c)):e&&t!==s&&t!==_&&(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Wrong credentials"})},c)),this.trigger("connected"),this._isConnected=!0}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(t){this.trigger("sipEvent",t)}}class q{constructor(t){r(this,"url");this.url=t}}class x extends D.EventEmitter{constructor(e,n){super();r(this,"contentType");r(this,"body");this.contentType=e,this.body=n}}const p="remote",H=(o,t)=>{const e=new C(t),n={originator:p,request:e,info:new x("","")};o.newInfo(n)},B=(o,t)=>{const n={request:new C(t)};o.newSipEvent(n)},$=(o,{incomingNumber:t="1234",displayName:e,host:n})=>{const i=new T({originator:p}),d=new k("sip",t,n);i._remote_identity=new W(d,e),o.trigger("newRTCSession",{originator:p,session:i})},j=(o,t)=>{t?o.trigger("failed",t):o.trigger("failed",o)},y={triggerNewInfo:H,triggerNewSipEvent:B,triggerIncomingSession:$,triggerFailIncomingSession:j,WebSocketInterface:q,UA:z,C:{INVITE:"INVITE"}},m="user",a="displayName",u="SIP_SERVER_URL",w="SIP_WEB_SOCKET_SERVER_URL",K=new y.WebSocketInterface(w),E={userAgent:"Chrome",sipServerUrl:u,sipWebSocketServerURL:w},J={...E},A={...E,user:m,password:s,register:!0},Y={...A,displayName:a},G={...E,displayName:a,register:!1},l={session_timers:!1,sockets:[K],user_agent:"Chrome",sdp_semantics:"plan-b",register_expires:300,connection_recovery_max_interval:6,connection_recovery_min_interval:2},X={...l,password:s,uri:`sip:${m}@${u}`,display_name:"",register:!0},Q={...l,password:s,uri:`sip:${m}@${u}`,display_name:a,register:!0},Z={...l,display_name:a,register:!1},ee={...l,display_name:"",register:!1},I="10.10.10.10",te=[`X-Vinteo-Remote: ${I}`],re=()=>new h.SipConnector({JsSIP:y});exports.FAILED_CONFERENCE_NUMBER=S;exports.NAME_INCORRECT=v;exports.PASSWORD_CORRECT=s;exports.PASSWORD_CORRECT_2=_;exports.SIP_SERVER_URL=u;exports.SIP_WEB_SOCKET_SERVER_URL=w;exports.dataForConnectionWithAuthorization=A;exports.dataForConnectionWithAuthorizationWithDisplayName=Y;exports.dataForConnectionWithoutAuthorization=G;exports.dataForConnectionWithoutAuthorizationWithoutDisplayName=J;exports.default=re;exports.displayName=a;exports.extraHeadersRemoteAddress=te;exports.remoteAddress=I;exports.uaConfigurationWithAuthorization=X;exports.uaConfigurationWithAuthorizationWithDisplayName=Q;exports.uaConfigurationWithoutAuthorization=Z;exports.uaConfigurationWithoutAuthorizationWithoutDisplayName=ee;exports.user=m;
1
+ "use strict";var W=Object.defineProperty;var b=(i,e,t)=>e in i?W(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var n=(i,e,t)=>(b(i,typeof e!="symbol"?e+"":e,t),t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("./SipConnector-4TW1xlov.cjs"),D=require("@krivega/jssip/lib/NameAddrHeader"),k=require("@krivega/jssip/lib/URI"),L=require("node:events"),P=require("@krivega/jssip/lib/SIPMessage"),f=require("events-constructor");require("@krivega/cancelable-promise");require("debug");class R extends P.IncomingRequest{constructor(t){super();n(this,"headers");this.headers=new Headers(t)}getHeader(t){return this.headers.get(t)||""}}var x=Object.defineProperty,F=(i,e,t)=>e in i?x(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,s=(i,e,t)=>(F(i,typeof e!="symbol"?e+"":e,t),t);const m="ended",U="mute",V="isolationchange",z="overconstrained",q="unmute",H=[m,U,q,V,z];class S{constructor(e,{id:t="identifier",constraints:r={}}={}){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={...r},this.events=new f(H)}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 j=i=>new S("audio",i),$=i=>new S("video",i);class B{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 f(u.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,r){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,r])=>this.on(t,r))}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 K{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(r=>({track:r}))}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,r){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,r){throw new Error("Method not implemented.")}removeEventListener(e,t,r){throw new Error("Method not implemented.")}dispatchEvent(e){throw new Error("Method not implemented.")}}function Y(i){const e=i.match(/[\d.]+/g);if(!e)throw new Error("wrong sip url");return e[0]}const p=400,T="777",J=i=>i.getVideoTracks().length>0;class y extends B{constructor({url:t="",mediaStream:r,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)},p)}));this.url=t,this.initPeerconnection(r)}initPeerconnection(t){return t?(this.createPeerconnection(t),!0):!1}createPeerconnection(t){const r=j();r.id="mainaudio1";const o=[r];if(J(t)){const C=$();C.id="mainvideo1",o.push(C)}this._connection=new K(void 0,o),this._addStream(t),setTimeout(()=>{this.trigger("peerconnection",{peerconnection:this.connection})},p)}connect(t){const r=Y(t);setTimeout(()=>{this.url.includes(T)?this.trigger("failed",{originator:"remote",message:"IncomingResponse",cause:u.REJECTED}):(this.trigger("connecting"),setTimeout(()=>{this.trigger("enterRoom",r)},100),setTimeout(()=>{this.trigger("accepted")},200),setTimeout(()=>{this.trigger("confirmed")},300))},p)}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,r="getTracks"){t[r]().forEach(o=>this.connection.addTrack(o))}_forEachSenders(t){const r=this.connection.getSenders();for(const o of r)t(o);return r}_toggleMuteAudio(t){this._forEachSenders(({track:r})=>{r&&r.kind==="audio"&&(r.enabled=!t)})}_toggleMuteVideo(t){this._forEachSenders(({track:r})=>{r&&r.kind==="video"&&(r.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:r}){this.trigger("muted",{audio:t,video:r})}async sendInfo(){}isEnded(){return this._isEnded}newInfo(t){this.trigger("newInfo",t)}}class G{constructor(){n(this,"extraHeaders")}setExtraHeaders(e){this.extraHeaders=e}setExtraContactParams(){}}const d="PASSWORD_CORRECT",w="PASSWORD_CORRECT_2",A="NAME_INCORRECT",c=400;class X{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:r,eventHandlers:o}=t;return this.session=new y({url:e,mediaStream:r,eventHandlers:o,originator:"local"}),this.session.connect(e),this.session}));this._events=new f(u.UA_EVENT_NAMES),this.configuration=e,this._registrator=new G}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}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:r}=this.configuration;t&&r.includes(A)?(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Request Timeout"})},c)):!this._isRegistered&&t&&(e===d||e===w)?(this._isRegistered=!0,this._startedTimeout=setTimeout(()=>{this.trigger("registered")},c)):t&&e!==d&&e!==w&&(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Wrong credentials"})},c)),this.trigger("connected"),this._isConnected=!0}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)}}class Q{constructor(e){n(this,"url");this.url=e}}class Z extends L.EventEmitter{constructor(t,r){super();n(this,"contentType");n(this,"body");this.contentType=t,this.body=r}}const E="remote",ee=(i,e)=>{const t=new R(e),r={originator:E,request:t,info:new Z("","")};i.newInfo(r)},te=(i,e)=>{const r={request:new R(e)};i.newSipEvent(r)},ne=(i,{incomingNumber:e="1234",displayName:t,host:r})=>{const o=new y({originator:E}),a=new k("sip",e,r);o._remote_identity=new D(a,t),i.trigger("newRTCSession",{originator:E,session:o})},re=(i,e)=>{e?i.trigger("failed",e):i.trigger("failed",i)},I={triggerNewInfo:ee,triggerNewSipEvent:te,triggerIncomingSession:ne,triggerFailIncomingSession:re,WebSocketInterface:Q,UA:X,C:{INVITE:"INVITE"}},l="user",h="displayName",g="SIP_SERVER_URL",M="SIP_WEB_SOCKET_SERVER_URL",ie=new I.WebSocketInterface(M),v={userAgent:"Chrome",sipServerUrl:g,sipWebSocketServerURL:M},oe={...v},O={...v,user:l,password:d,register:!0},se={...O,displayName:h},ae={...v,displayName:h,register:!1},_={session_timers:!1,sockets:[ie],user_agent:"Chrome",sdp_semantics:"plan-b",register_expires:300,connection_recovery_max_interval:6,connection_recovery_min_interval:2},de={..._,password:d,uri:`sip:${l}@${g}`,display_name:"",register:!0},he={..._,password:d,uri:`sip:${l}@${g}`,display_name:h,register:!0},ce={..._,display_name:h,register:!1},me={..._,display_name:"",register:!1},N="10.10.10.10",ue=[`X-Vinteo-Remote: ${N}`],le=()=>new u.SipConnector({JsSIP:I});exports.FAILED_CONFERENCE_NUMBER=T;exports.NAME_INCORRECT=A;exports.PASSWORD_CORRECT=d;exports.PASSWORD_CORRECT_2=w;exports.SIP_SERVER_URL=g;exports.SIP_WEB_SOCKET_SERVER_URL=M;exports.dataForConnectionWithAuthorization=O;exports.dataForConnectionWithAuthorizationWithDisplayName=se;exports.dataForConnectionWithoutAuthorization=ae;exports.dataForConnectionWithoutAuthorizationWithoutDisplayName=oe;exports.default=le;exports.displayName=h;exports.extraHeadersRemoteAddress=ue;exports.remoteAddress=N;exports.uaConfigurationWithAuthorization=de;exports.uaConfigurationWithAuthorizationWithDisplayName=he;exports.uaConfigurationWithoutAuthorization=ce;exports.uaConfigurationWithoutAuthorizationWithoutDisplayName=me;exports.user=l;
package/dist/doMock.js CHANGED
@@ -1,34 +1,71 @@
1
- var R = Object.defineProperty;
2
- var S = (o, t, e) => t in o ? R(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
- var r = (o, t, e) => (S(o, typeof t != "symbol" ? t + "" : t, e), e);
4
- import { j as C, R as y, U as I, S as A } from "./SipConnector-Hg44qtgr.js";
5
- import O from "@krivega/jssip/lib/NameAddrHeader";
6
- import k from "@krivega/jssip/lib/URI";
7
- import { EventEmitter as N } from "node:events";
8
- import { IncomingRequest as D } from "@krivega/jssip/lib/SIPMessage";
9
- import { createAudioMediaStreamTrackMock as L, createVideoMediaStreamTrackMock as W } from "webrtc-mock";
10
- import E from "events-constructor";
1
+ var y = Object.defineProperty;
2
+ var I = (i, e, t) => e in i ? y(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var n = (i, e, t) => (I(i, typeof e != "symbol" ? e + "" : e, t), t);
4
+ import { j as b, R as O, U as k, S as A } from "./SipConnector-Hg44qtgr.js";
5
+ import N from "@krivega/jssip/lib/NameAddrHeader";
6
+ import L from "@krivega/jssip/lib/URI";
7
+ import { EventEmitter as D } from "node:events";
8
+ import { IncomingRequest as W } from "@krivega/jssip/lib/SIPMessage";
9
+ import _ from "events-constructor";
11
10
  import "@krivega/cancelable-promise";
12
11
  import "debug";
13
- class f extends D {
14
- constructor(e) {
12
+ class M extends W {
13
+ constructor(t) {
15
14
  super();
16
- r(this, "headers");
17
- this.headers = new Headers(e);
15
+ n(this, "headers");
16
+ this.headers = new Headers(t);
18
17
  }
19
- getHeader(e) {
20
- return this.headers.get(e) || "";
18
+ getHeader(t) {
19
+ return this.headers.get(t) || "";
20
+ }
21
+ }
22
+ var P = Object.defineProperty, x = (i, e, t) => e in i ? P(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, s = (i, e, t) => (x(i, typeof e != "symbol" ? e + "" : e, t), t);
23
+ const c = "ended", U = "mute", V = "isolationchange", F = "overconstrained", j = "unmute", H = [c, U, j, V, F];
24
+ class R {
25
+ constructor(e, { id: t = "identifier", constraints: r = {} } = {}) {
26
+ 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(c) };
28
+ this.events.trigger(c, o), this.readyState = c, this.onended && this.onended(o);
29
+ }), s(this, "addEventListener", (o, a) => {
30
+ this.events.on(o, a);
31
+ }), s(this, "removeEventListener", (o, a) => {
32
+ this.events.off(o, a);
33
+ }), this.id = `${t}-${e}-track`, this.kind = e, this.enabled = !0, this.constraints = { ...r }, this.events = new _(H);
34
+ }
35
+ clone() {
36
+ return { ...this };
37
+ }
38
+ getCapabilities() {
39
+ return {
40
+ width: { min: 352, max: 4096 },
41
+ height: { min: 288, max: 2160 }
42
+ };
43
+ }
44
+ getSettings() {
45
+ let e = 0, t = 0;
46
+ 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), {
47
+ width: e,
48
+ height: t
49
+ };
50
+ }
51
+ async applyConstraints(e) {
52
+ this.constraints = { ...e };
53
+ }
54
+ dispatchEvent(e) {
55
+ const t = e.type;
56
+ return this.events.trigger(t, e), !0;
21
57
  }
22
58
  }
23
- class b {
59
+ const z = (i) => new R("audio", i), $ = (i) => new R("video", i);
60
+ class q {
24
61
  // @ts-expect-error
25
- constructor({ originator: t = "local", eventHandlers: e }) {
26
- r(this, "originator");
27
- r(this, "_connection");
28
- r(this, "_events");
29
- r(this, "_remote_identity");
30
- r(this, "_mutedOptions", { audio: !1, video: !1 });
31
- this.originator = t, this._events = new E(C), this.initEvents(e);
62
+ constructor({ originator: e = "local", eventHandlers: t }) {
63
+ n(this, "originator");
64
+ n(this, "_connection");
65
+ n(this, "_events");
66
+ n(this, "_remote_identity");
67
+ n(this, "_mutedOptions", { audio: !1, video: !1 });
68
+ this.originator = e, this._events = new _(b), this.initEvents(t);
32
69
  }
33
70
  // @ts-expect-error
34
71
  get C() {
@@ -41,7 +78,7 @@ class b {
41
78
  get id() {
42
79
  throw new Error("Method not implemented.");
43
80
  }
44
- set data(t) {
81
+ set data(e) {
45
82
  throw new Error("Method not implemented.");
46
83
  }
47
84
  get data() {
@@ -80,82 +117,82 @@ class b {
80
117
  isReadyToReOffer() {
81
118
  throw new Error("Method not implemented.");
82
119
  }
83
- answer(t) {
120
+ answer(e) {
84
121
  throw new Error("Method not implemented.");
85
122
  }
86
- terminate(t) {
123
+ terminate(e) {
87
124
  throw new Error("Method not implemented.");
88
125
  }
89
- async sendInfo(t, e, n) {
126
+ async sendInfo(e, t, r) {
90
127
  throw new Error("Method not implemented.");
91
128
  }
92
- hold(t, e) {
129
+ hold(e, t) {
93
130
  throw new Error("Method not implemented.");
94
131
  }
95
- unhold(t, e) {
132
+ unhold(e, t) {
96
133
  throw new Error("Method not implemented.");
97
134
  }
98
- async renegotiate(t, e) {
135
+ async renegotiate(e, t) {
99
136
  throw new Error("Method not implemented.");
100
137
  }
101
138
  isOnHold() {
102
139
  throw new Error("Method not implemented.");
103
140
  }
104
- mute(t) {
141
+ mute(e) {
105
142
  throw new Error("Method not implemented.");
106
143
  }
107
- unmute(t) {
144
+ unmute(e) {
108
145
  throw new Error("Method not implemented.");
109
146
  }
110
147
  isMuted() {
111
148
  throw new Error("Method not implemented.");
112
149
  }
113
- refer(t, e) {
150
+ refer(e, t) {
114
151
  throw new Error("Method not implemented.");
115
152
  }
116
153
  resetLocalMedia() {
117
154
  throw new Error("Method not implemented.");
118
155
  }
119
- async replaceMediaStream(t, e) {
156
+ async replaceMediaStream(e, t) {
120
157
  throw new Error("Method not implemented.");
121
158
  }
122
- addListener(t, e) {
159
+ addListener(e, t) {
123
160
  throw new Error("Method not implemented.");
124
161
  }
125
- once(t, e) {
162
+ once(e, t) {
126
163
  throw new Error("Method not implemented.");
127
164
  }
128
- removeListener(t, e) {
165
+ removeListener(e, t) {
129
166
  throw new Error("Method not implemented.");
130
167
  }
131
- off(t, e) {
168
+ off(e, t) {
132
169
  throw new Error("Method not implemented.");
133
170
  }
134
- removeAllListeners(t) {
171
+ removeAllListeners(e) {
135
172
  throw new Error("Method not implemented.");
136
173
  }
137
- setMaxListeners(t) {
174
+ setMaxListeners(e) {
138
175
  throw new Error("Method not implemented.");
139
176
  }
140
177
  getMaxListeners() {
141
178
  throw new Error("Method not implemented.");
142
179
  }
143
- listeners(t) {
180
+ listeners(e) {
144
181
  throw new Error("Method not implemented.");
145
182
  }
146
- rawListeners(t) {
183
+ rawListeners(e) {
147
184
  throw new Error("Method not implemented.");
148
185
  }
149
- emit(t, ...e) {
186
+ emit(e, ...t) {
150
187
  throw new Error("Method not implemented.");
151
188
  }
152
- listenerCount(t) {
189
+ listenerCount(e) {
153
190
  throw new Error("Method not implemented.");
154
191
  }
155
- prependListener(t, e) {
192
+ prependListener(e, t) {
156
193
  throw new Error("Method not implemented.");
157
194
  }
158
- prependOnceListener(t, e) {
195
+ prependOnceListener(e, t) {
159
196
  throw new Error("Method not implemented.");
160
197
  }
161
198
  eventNames() {
@@ -168,15 +205,15 @@ class b {
168
205
  *
169
206
  * @returns {undefined}
170
207
  */
171
- initEvents(t = []) {
172
- Object.entries(t).forEach(([e, n]) => this.on(e, n));
208
+ initEvents(e = []) {
209
+ Object.entries(e).forEach(([t, r]) => this.on(t, r));
173
210
  }
174
211
  // @ts-expect-error
175
- on(t, e) {
176
- return this._events.on(t, e), this;
212
+ on(e, t) {
213
+ return this._events.on(e, t), this;
177
214
  }
178
- trigger(t, e) {
179
- this._events.trigger(t, e);
215
+ trigger(e, t) {
216
+ this._events.trigger(e, t);
180
217
  }
181
218
  /**
182
219
  * sendDTMF
@@ -188,62 +225,62 @@ class b {
188
225
  sendDTMF() {
189
226
  this.trigger("newDTMF", { originator: this.originator });
190
227
  }
191
- async startPresentation(t) {
192
- return t;
228
+ async startPresentation(e) {
229
+ return e;
193
230
  }
194
- async updatePresentation(t) {
195
- return t;
231
+ async updatePresentation(e) {
232
+ return e;
196
233
  }
197
- async stopPresentation(t) {
198
- return t;
234
+ async stopPresentation(e) {
235
+ return e;
199
236
  }
200
237
  isEstablished() {
201
238
  return !0;
202
239
  }
203
240
  }
204
- class P {
205
- constructor(t, e) {
206
- r(this, "_senders", []);
207
- r(this, "_receivers", []);
208
- r(this, "canTrickleIceCandidates");
209
- r(this, "connectionState");
210
- r(this, "currentLocalDescription");
211
- r(this, "currentRemoteDescription");
212
- r(this, "iceConnectionState");
213
- r(this, "iceGatheringState");
214
- r(this, "idpErrorInfo");
215
- r(this, "idpLoginUrl");
216
- r(this, "localDescription");
217
- r(this, "onconnectionstatechange");
218
- r(this, "ondatachannel");
219
- r(this, "onicecandidate");
220
- r(this, "onicecandidateerror", null);
221
- r(this, "oniceconnectionstatechange");
222
- r(this, "onicegatheringstatechange");
223
- r(this, "onnegotiationneeded");
224
- r(this, "onsignalingstatechange");
225
- r(this, "ontrack");
226
- r(this, "peerIdentity");
227
- r(this, "pendingLocalDescription");
228
- r(this, "pendingRemoteDescription");
229
- r(this, "remoteDescription");
230
- r(this, "sctp", null);
231
- r(this, "signalingState");
232
- r(this, "getReceivers", () => this._receivers);
233
- r(this, "getSenders", () => this._senders);
234
- r(this, "addTrack", (t) => {
235
- const e = { track: t };
236
- return this._senders.push(e), e;
241
+ class B {
242
+ constructor(e, t) {
243
+ n(this, "_senders", []);
244
+ n(this, "_receivers", []);
245
+ n(this, "canTrickleIceCandidates");
246
+ n(this, "connectionState");
247
+ n(this, "currentLocalDescription");
248
+ n(this, "currentRemoteDescription");
249
+ n(this, "iceConnectionState");
250
+ n(this, "iceGatheringState");
251
+ n(this, "idpErrorInfo");
252
+ n(this, "idpLoginUrl");
253
+ n(this, "localDescription");
254
+ n(this, "onconnectionstatechange");
255
+ n(this, "ondatachannel");
256
+ n(this, "onicecandidate");
257
+ n(this, "onicecandidateerror", null);
258
+ n(this, "oniceconnectionstatechange");
259
+ n(this, "onicegatheringstatechange");
260
+ n(this, "onnegotiationneeded");
261
+ n(this, "onsignalingstatechange");
262
+ n(this, "ontrack");
263
+ n(this, "peerIdentity");
264
+ n(this, "pendingLocalDescription");
265
+ n(this, "pendingRemoteDescription");
266
+ n(this, "remoteDescription");
267
+ n(this, "sctp", null);
268
+ n(this, "signalingState");
269
+ n(this, "getReceivers", () => this._receivers);
270
+ n(this, "getSenders", () => this._senders);
271
+ n(this, "addTrack", (e) => {
272
+ const t = { track: e };
273
+ return this._senders.push(t), t;
237
274
  });
238
- this._receivers = e.map((n) => ({ track: n }));
275
+ this._receivers = t.map((r) => ({ track: r }));
239
276
  }
240
277
  getRemoteStreams() {
241
278
  throw new Error("Method not implemented.");
242
279
  }
243
- async addIceCandidate(t) {
280
+ async addIceCandidate(e) {
244
281
  throw new Error("Method not implemented.");
245
282
  }
246
- addTransceiver(t, e) {
283
+ addTransceiver(e, t) {
247
284
  throw new Error("Method not implemented.");
248
285
  }
249
286
  close() {
@@ -252,13 +289,13 @@ class P {
252
289
  restartIce() {
253
290
  throw new Error("Method not implemented.");
254
291
  }
255
- async createAnswer(t, e) {
292
+ async createAnswer(e, t) {
256
293
  throw new Error("Method not implemented.");
257
294
  }
258
- createDataChannel(t, e) {
295
+ createDataChannel(e, t) {
259
296
  throw new Error("Method not implemented.");
260
297
  }
261
- async createOffer(t, e, n) {
298
+ async createOffer(e, t, r) {
262
299
  throw new Error("Method not implemented.");
263
300
  }
264
301
  getConfiguration() {
@@ -267,52 +304,52 @@ class P {
267
304
  async getIdentityAssertion() {
268
305
  throw new Error("Method not implemented.");
269
306
  }
270
- async getStats(t) {
307
+ async getStats(e) {
271
308
  throw new Error("Method not implemented.");
272
309
  }
273
310
  getTransceivers() {
274
311
  throw new Error("Method not implemented.");
275
312
  }
276
- removeTrack(t) {
313
+ removeTrack(e) {
277
314
  throw new Error("Method not implemented.");
278
315
  }
279
- setConfiguration(t) {
316
+ setConfiguration(e) {
280
317
  throw new Error("Method not implemented.");
281
318
  }
282
- async setLocalDescription(t) {
319
+ async setLocalDescription(e) {
283
320
  throw new Error("Method not implemented.");
284
321
  }
285
- async setRemoteDescription(t) {
322
+ async setRemoteDescription(e) {
286
323
  throw new Error("Method not implemented.");
287
324
  }
288
- addEventListener(t, e, n) {
325
+ addEventListener(e, t, r) {
289
326
  throw new Error("Method not implemented.");
290
327
  }
291
- removeEventListener(t, e, n) {
328
+ removeEventListener(e, t, r) {
292
329
  throw new Error("Method not implemented.");
293
330
  }
294
- dispatchEvent(t) {
331
+ dispatchEvent(e) {
295
332
  throw new Error("Method not implemented.");
296
333
  }
297
334
  }
298
- function V(o) {
299
- const t = o.match(/[\d.]+/g);
300
- if (!t)
335
+ function K(i) {
336
+ const e = i.match(/[\d.]+/g);
337
+ if (!e)
301
338
  throw new Error("wrong sip url");
302
- return t[0];
339
+ return e[0];
303
340
  }
304
- const m = 400, U = "777", x = (o) => o.getVideoTracks().length > 0;
305
- class M extends b {
341
+ const u = 400, Y = "777", J = (i) => i.getVideoTracks().length > 0;
342
+ class T extends q {
306
343
  constructor({
307
- url: e = "",
308
- mediaStream: n,
309
- eventHandlers: i,
310
- originator: d
344
+ url: t = "",
345
+ mediaStream: r,
346
+ eventHandlers: o,
347
+ originator: a
311
348
  }) {
312
- super({ originator: d, eventHandlers: i });
313
- r(this, "url");
314
- r(this, "status_code");
315
- r(this, "_isEnded", !1);
349
+ super({ originator: a, eventHandlers: o });
350
+ n(this, "url");
351
+ n(this, "status_code");
352
+ n(this, "_isEnded", !1);
316
353
  /**
317
354
  * answer
318
355
  *
@@ -322,94 +359,94 @@ class M extends b {
322
359
 
323
360
  * @returns {undefined}
324
361
  */
325
- r(this, "answer", jest.fn(({ mediaStream: e }) => {
362
+ n(this, "answer", jest.fn(({ mediaStream: t }) => {
326
363
  if (this.originator !== "remote")
327
364
  throw new Error("answer available only for remote sessions");
328
- this.initPeerconnection(e), setTimeout(() => {
365
+ this.initPeerconnection(t), setTimeout(() => {
329
366
  this.trigger("connecting"), setTimeout(() => {
330
367
  this.trigger("accepted");
331
368
  }, 100), setTimeout(() => {
332
369
  this.trigger("confirmed");
333
370
  }, 200);
334
- }, m);
371
+ }, u);
335
372
  }));
336
- this.url = e, this.initPeerconnection(n);
337
- }
338
- initPeerconnection(e) {
339
- return e ? (this.createPeerconnection(e), !0) : !1;
340
- }
341
- createPeerconnection(e) {
342
- const n = L();
343
- n.id = "mainaudio1";
344
- const i = [n];
345
- if (x(e)) {
346
- const p = W();
347
- p.id = "mainvideo1", i.push(p);
373
+ this.url = t, this.initPeerconnection(r);
374
+ }
375
+ initPeerconnection(t) {
376
+ return t ? (this.createPeerconnection(t), !0) : !1;
377
+ }
378
+ createPeerconnection(t) {
379
+ const r = z();
380
+ r.id = "mainaudio1";
381
+ const o = [r];
382
+ if (J(t)) {
383
+ const f = $();
384
+ f.id = "mainvideo1", o.push(f);
348
385
  }
349
- this._connection = new P(void 0, i), this._addStream(e), setTimeout(() => {
386
+ this._connection = new B(void 0, o), this._addStream(t), setTimeout(() => {
350
387
  this.trigger("peerconnection", { peerconnection: this.connection });
351
- }, m);
388
+ }, u);
352
389
  }
353
- connect(e) {
354
- const n = V(e);
390
+ connect(t) {
391
+ const r = K(t);
355
392
  setTimeout(() => {
356
- this.url.includes(U) ? this.trigger("failed", {
393
+ this.url.includes(Y) ? this.trigger("failed", {
357
394
  originator: "remote",
358
395
  message: "IncomingResponse",
359
- cause: y
396
+ cause: O
360
397
  }) : (this.trigger("connecting"), setTimeout(() => {
361
- this.trigger("enterRoom", n);
398
+ this.trigger("enterRoom", r);
362
399
  }, 100), setTimeout(() => {
363
400
  this.trigger("accepted");
364
401
  }, 200), setTimeout(() => {
365
402
  this.trigger("confirmed");
366
403
  }, 300));
367
- }, m);
404
+ }, u);
368
405
  }
369
- terminate({ status_code: e } = {}) {
370
- return this.status_code = e, this.trigger("ended", { status_code: e }), this._isEnded = !1, this;
406
+ terminate({ status_code: t } = {}) {
407
+ return this.status_code = t, this.trigger("ended", { status_code: t }), this._isEnded = !1, this;
371
408
  }
372
- terminateRemote({ status_code: e } = {}) {
373
- return this.status_code = e, this.trigger("ended", { status_code: e, originator: "remote" }), this;
409
+ terminateRemote({ status_code: t } = {}) {
410
+ return this.status_code = t, this.trigger("ended", { status_code: t, originator: "remote" }), this;
374
411
  }
375
- _addStream(e, n = "getTracks") {
376
- e[n]().forEach((i) => this.connection.addTrack(i));
412
+ _addStream(t, r = "getTracks") {
413
+ t[r]().forEach((o) => this.connection.addTrack(o));
377
414
  }
378
- _forEachSenders(e) {
379
- const n = this.connection.getSenders();
380
- for (const i of n)
381
- e(i);
382
- return n;
415
+ _forEachSenders(t) {
416
+ const r = this.connection.getSenders();
417
+ for (const o of r)
418
+ t(o);
419
+ return r;
383
420
  }
384
421
  /* eslint-disable no-param-reassign */
385
- _toggleMuteAudio(e) {
386
- this._forEachSenders(({ track: n }) => {
387
- n && n.kind === "audio" && (n.enabled = !e);
422
+ _toggleMuteAudio(t) {
423
+ this._forEachSenders(({ track: r }) => {
424
+ r && r.kind === "audio" && (r.enabled = !t);
388
425
  });
389
426
  }
390
427
  /* eslint-enable no-param-reassign */
391
428
  /* eslint-disable no-param-reassign */
392
- _toggleMuteVideo(e) {
393
- this._forEachSenders(({ track: n }) => {
394
- n && n.kind === "video" && (n.enabled = !e);
429
+ _toggleMuteVideo(t) {
430
+ this._forEachSenders(({ track: r }) => {
431
+ r && r.kind === "video" && (r.enabled = !t);
395
432
  });
396
433
  }
397
- mute(e) {
398
- e.audio && (this._mutedOptions.audio = !0, this._toggleMuteAudio(this._mutedOptions.audio)), e.video && (this._mutedOptions.video = !0, this._toggleMuteVideo(this._mutedOptions.video)), this._onmute(e);
434
+ mute(t) {
435
+ 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);
399
436
  }
400
- unmute(e) {
401
- e.audio && (this._mutedOptions.audio = !1), e.video && (this._mutedOptions.video = !1), this.trigger("unmuted", e);
437
+ unmute(t) {
438
+ t.audio && (this._mutedOptions.audio = !1), t.video && (this._mutedOptions.video = !1), this.trigger("unmuted", t);
402
439
  }
403
440
  isMuted() {
404
441
  return this._mutedOptions;
405
442
  }
406
- async replaceMediaStream(e) {
407
- return e;
443
+ async replaceMediaStream(t) {
444
+ return t;
408
445
  }
409
- _onmute({ audio: e, video: n }) {
446
+ _onmute({ audio: t, video: r }) {
410
447
  this.trigger("muted", {
411
- audio: e,
412
- video: n
448
+ audio: t,
449
+ video: r
413
450
  });
414
451
  }
415
452
  async sendInfo() {
@@ -417,38 +454,38 @@ class M extends b {
417
454
  isEnded() {
418
455
  return this._isEnded;
419
456
  }
420
- newInfo(e) {
421
- this.trigger("newInfo", e);
457
+ newInfo(t) {
458
+ this.trigger("newInfo", t);
422
459
  }
423
460
  /* eslint-enable no-param-reassign */
424
461
  }
425
- class F {
462
+ class G {
426
463
  constructor() {
427
- r(this, "extraHeaders");
464
+ n(this, "extraHeaders");
428
465
  }
429
- setExtraHeaders(t) {
430
- this.extraHeaders = t;
466
+ setExtraHeaders(e) {
467
+ this.extraHeaders = e;
431
468
  }
432
469
  setExtraContactParams() {
433
470
  }
434
471
  }
435
- const s = "PASSWORD_CORRECT", w = "PASSWORD_CORRECT_2", H = "NAME_INCORRECT", a = 400;
436
- class z {
437
- constructor(t) {
438
- r(this, "_events");
439
- r(this, "_startedTimeout");
440
- r(this, "_stopedTimeout");
441
- r(this, "session");
442
- r(this, "_isRegistered");
443
- r(this, "_isConnected");
444
- r(this, "configuration");
445
- r(this, "_registrator");
472
+ const d = "PASSWORD_CORRECT", v = "PASSWORD_CORRECT_2", X = "NAME_INCORRECT", h = 400;
473
+ class Q {
474
+ constructor(e) {
475
+ n(this, "_events");
476
+ n(this, "_startedTimeout");
477
+ n(this, "_stopedTimeout");
478
+ n(this, "session");
479
+ n(this, "_isRegistered");
480
+ n(this, "_isConnected");
481
+ n(this, "configuration");
482
+ n(this, "_registrator");
446
483
  // @ts-expect-error
447
- r(this, "call", jest.fn((t, e) => {
448
- const { mediaStream: n, eventHandlers: i } = e;
449
- return this.session = new M({ url: t, mediaStream: n, eventHandlers: i, originator: "local" }), this.session.connect(t), this.session;
484
+ n(this, "call", jest.fn((e, t) => {
485
+ const { mediaStream: r, eventHandlers: o } = t;
486
+ return this.session = new T({ url: e, mediaStream: r, eventHandlers: o, originator: "local" }), this.session.connect(e), this.session;
450
487
  }));
451
- this._events = new E(I), this.configuration = t, this._registrator = new F();
488
+ this._events = new _(k), this.configuration = e, this._registrator = new G();
452
489
  }
453
490
  /**
454
491
  * start
@@ -466,14 +503,14 @@ class z {
466
503
  stop() {
467
504
  this._startedTimeout && clearTimeout(this._startedTimeout), this._stopedTimeout && clearTimeout(this._stopedTimeout), this.unregister(), this.isStarted() ? this._stopedTimeout = setTimeout(() => {
468
505
  this.trigger("disconnected", { error: new Error("stoped") });
469
- }, a) : this.trigger("disconnected", { error: new Error("stoped") });
506
+ }, h) : this.trigger("disconnected", { error: new Error("stoped") });
470
507
  }
471
508
  // @ts-expect-error
472
- on(t, e) {
473
- return this._events.on(t, e), this;
509
+ on(e, t) {
510
+ return this._events.on(e, t), this;
474
511
  }
475
- trigger(t, e) {
476
- this._events.trigger(t, e);
512
+ trigger(e, t) {
513
+ this._events.trigger(e, t);
477
514
  }
478
515
  /**
479
516
  * terminateSessions
@@ -491,8 +528,8 @@ class z {
491
528
  *
492
529
  * @returns {boolean} true
493
530
  */
494
- set(t, e) {
495
- return this.configuration[t] = e, !0;
531
+ set(e, t) {
532
+ return this.configuration[e] = t, !0;
496
533
  }
497
534
  /**
498
535
  * register
@@ -501,14 +538,14 @@ class z {
501
538
  */
502
539
  register() {
503
540
  this._startedTimeout && clearTimeout(this._startedTimeout);
504
- const { password: t, register: e, uri: n } = this.configuration;
505
- e && n.includes(H) ? (this._isRegistered = !1, this._isConnected = !1, this._startedTimeout = setTimeout(() => {
541
+ const { password: e, register: t, uri: r } = this.configuration;
542
+ t && r.includes(X) ? (this._isRegistered = !1, this._isConnected = !1, this._startedTimeout = setTimeout(() => {
506
543
  this.trigger("registrationFailed", { response: null, cause: "Request Timeout" });
507
- }, a)) : !this._isRegistered && e && (t === s || t === w) ? (this._isRegistered = !0, this._startedTimeout = setTimeout(() => {
544
+ }, h)) : !this._isRegistered && t && (e === d || e === v) ? (this._isRegistered = !0, this._startedTimeout = setTimeout(() => {
508
545
  this.trigger("registered");
509
- }, a)) : e && t !== s && t !== w && (this._isRegistered = !1, this._isConnected = !1, this._startedTimeout = setTimeout(() => {
546
+ }, h)) : t && e !== d && e !== v && (this._isRegistered = !1, this._isConnected = !1, this._startedTimeout = setTimeout(() => {
510
547
  this.trigger("registrationFailed", { response: null, cause: "Wrong credentials" });
511
- }, a)), this.trigger("connected"), this._isConnected = !0;
548
+ }, h)), this.trigger("connected"), this._isConnected = !0;
512
549
  }
513
550
  /**
514
551
  * unregister
@@ -537,120 +574,120 @@ class z {
537
574
  registrator() {
538
575
  return this._registrator;
539
576
  }
540
- newSipEvent(t) {
541
- this.trigger("sipEvent", t);
577
+ newSipEvent(e) {
578
+ this.trigger("sipEvent", e);
542
579
  }
543
580
  }
544
- class q {
545
- constructor(t) {
546
- r(this, "url");
547
- this.url = t;
581
+ class Z {
582
+ constructor(e) {
583
+ n(this, "url");
584
+ this.url = e;
548
585
  }
549
586
  }
550
- class $ extends N {
551
- constructor(e, n) {
587
+ class ee extends D {
588
+ constructor(t, r) {
552
589
  super();
553
- r(this, "contentType");
554
- r(this, "body");
555
- this.contentType = e, this.body = n;
590
+ n(this, "contentType");
591
+ n(this, "body");
592
+ this.contentType = t, this.body = r;
556
593
  }
557
594
  }
558
- const u = "remote", j = (o, t) => {
559
- const e = new f(t), n = {
560
- originator: u,
561
- request: e,
562
- info: new $("", "")
595
+ const g = "remote", te = (i, e) => {
596
+ const t = new M(e), r = {
597
+ originator: g,
598
+ request: t,
599
+ info: new ee("", "")
563
600
  };
564
- o.newInfo(n);
565
- }, B = (o, t) => {
566
- const n = { request: new f(t) };
567
- o.newSipEvent(n);
568
- }, K = (o, {
569
- incomingNumber: t = "1234",
570
- displayName: e,
571
- host: n
601
+ i.newInfo(r);
602
+ }, ne = (i, e) => {
603
+ const r = { request: new M(e) };
604
+ i.newSipEvent(r);
605
+ }, re = (i, {
606
+ incomingNumber: e = "1234",
607
+ displayName: t,
608
+ host: r
572
609
  }) => {
573
- const i = new M({ originator: u }), d = new k("sip", t, n);
574
- i._remote_identity = new O(d, e), o.trigger("newRTCSession", { originator: u, session: i });
575
- }, J = (o, t) => {
576
- t ? o.trigger("failed", t) : o.trigger("failed", o);
577
- }, T = {
578
- triggerNewInfo: j,
579
- triggerNewSipEvent: B,
580
- triggerIncomingSession: K,
581
- triggerFailIncomingSession: J,
582
- WebSocketInterface: q,
583
- UA: z,
610
+ const o = new T({ originator: g }), a = new L("sip", e, r);
611
+ o._remote_identity = new N(a, t), i.trigger("newRTCSession", { originator: g, session: o });
612
+ }, ie = (i, e) => {
613
+ e ? i.trigger("failed", e) : i.trigger("failed", i);
614
+ }, S = {
615
+ triggerNewInfo: te,
616
+ triggerNewSipEvent: ne,
617
+ triggerIncomingSession: re,
618
+ triggerFailIncomingSession: ie,
619
+ WebSocketInterface: Z,
620
+ UA: Q,
584
621
  C: {
585
622
  INVITE: "INVITE"
586
623
  }
587
- }, l = "user", c = "displayName", g = "SIP_SERVER_URL", v = "SIP_WEB_SOCKET_SERVER_URL", Y = new T.WebSocketInterface(v), _ = {
624
+ }, p = "user", m = "displayName", w = "SIP_SERVER_URL", C = "SIP_WEB_SOCKET_SERVER_URL", oe = new S.WebSocketInterface(C), E = {
588
625
  userAgent: "Chrome",
589
- sipServerUrl: g,
590
- sipWebSocketServerURL: v
591
- }, ae = {
592
- ..._
593
- }, G = {
594
- ..._,
595
- user: l,
596
- password: s,
626
+ sipServerUrl: w,
627
+ sipWebSocketServerURL: C
628
+ }, we = {
629
+ ...E
630
+ }, se = {
631
+ ...E,
632
+ user: p,
633
+ password: d,
597
634
  register: !0
598
- }, ce = {
599
- ...G,
600
- displayName: c
601
- }, he = {
602
- ..._,
603
- displayName: c,
635
+ }, Ee = {
636
+ ...se,
637
+ displayName: m
638
+ }, fe = {
639
+ ...E,
640
+ displayName: m,
604
641
  register: !1
605
- }, h = {
642
+ }, l = {
606
643
  session_timers: !1,
607
- sockets: [Y],
644
+ sockets: [oe],
608
645
  user_agent: "Chrome",
609
646
  sdp_semantics: "plan-b",
610
647
  register_expires: 300,
611
648
  connection_recovery_max_interval: 6,
612
649
  connection_recovery_min_interval: 2
613
- }, me = {
614
- ...h,
615
- password: s,
616
- uri: `sip:${l}@${g}`,
650
+ }, ve = {
651
+ ...l,
652
+ password: d,
653
+ uri: `sip:${p}@${w}`,
617
654
  display_name: "",
618
655
  register: !0
619
- }, ue = {
620
- ...h,
621
- password: s,
622
- uri: `sip:${l}@${g}`,
623
- display_name: c,
656
+ }, Me = {
657
+ ...l,
658
+ password: d,
659
+ uri: `sip:${p}@${w}`,
660
+ display_name: m,
624
661
  register: !0
625
- }, le = {
626
- ...h,
627
- display_name: c,
662
+ }, Re = {
663
+ ...l,
664
+ display_name: m,
628
665
  register: !1
629
- }, ge = {
630
- ...h,
666
+ }, Te = {
667
+ ...l,
631
668
  display_name: "",
632
669
  register: !1
633
- }, X = "10.10.10.10", _e = [`X-Vinteo-Remote: ${X}`], pe = () => new A({
634
- JsSIP: T
670
+ }, ae = "10.10.10.10", Se = [`X-Vinteo-Remote: ${ae}`], Ce = () => new A({
671
+ JsSIP: S
635
672
  });
636
673
  export {
637
- U as FAILED_CONFERENCE_NUMBER,
638
- H as NAME_INCORRECT,
639
- s as PASSWORD_CORRECT,
640
- w as PASSWORD_CORRECT_2,
641
- g as SIP_SERVER_URL,
642
- v as SIP_WEB_SOCKET_SERVER_URL,
643
- G as dataForConnectionWithAuthorization,
644
- ce as dataForConnectionWithAuthorizationWithDisplayName,
645
- he as dataForConnectionWithoutAuthorization,
646
- ae as dataForConnectionWithoutAuthorizationWithoutDisplayName,
647
- pe as default,
648
- c as displayName,
649
- _e as extraHeadersRemoteAddress,
650
- X as remoteAddress,
651
- me as uaConfigurationWithAuthorization,
652
- ue as uaConfigurationWithAuthorizationWithDisplayName,
653
- le as uaConfigurationWithoutAuthorization,
654
- ge as uaConfigurationWithoutAuthorizationWithoutDisplayName,
655
- l as user
674
+ Y as FAILED_CONFERENCE_NUMBER,
675
+ X as NAME_INCORRECT,
676
+ d as PASSWORD_CORRECT,
677
+ v as PASSWORD_CORRECT_2,
678
+ w as SIP_SERVER_URL,
679
+ C as SIP_WEB_SOCKET_SERVER_URL,
680
+ se as dataForConnectionWithAuthorization,
681
+ Ee as dataForConnectionWithAuthorizationWithDisplayName,
682
+ fe as dataForConnectionWithoutAuthorization,
683
+ we as dataForConnectionWithoutAuthorizationWithoutDisplayName,
684
+ Ce as default,
685
+ m as displayName,
686
+ Se as extraHeadersRemoteAddress,
687
+ ae as remoteAddress,
688
+ ve as uaConfigurationWithAuthorization,
689
+ Me as uaConfigurationWithAuthorizationWithDisplayName,
690
+ Re as uaConfigurationWithoutAuthorization,
691
+ Te as uaConfigurationWithoutAuthorizationWithoutDisplayName,
692
+ p as user
656
693
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sip-connector",
3
- "version": "6.22.2",
3
+ "version": "6.22.3",
4
4
  "description": "Module for connect to Vinteo server",
5
5
  "keywords": [
6
6
  "webrtc",
@@ -47,7 +47,6 @@
47
47
  ],
48
48
  "scripts": {
49
49
  "build": "vite build",
50
- "commitlint": "commitlint --edit",
51
50
  "lint": "yarn lint:js && yarn lint:ts",
52
51
  "lint:js": "eslint src --ext ts,tsx --ignore-path .gitignore --report-unused-disable-directives --max-warnings 0",
53
52
  "lint:ts": "tsc",
@@ -98,7 +97,7 @@
98
97
  "jest-extended": "^4.0.2",
99
98
  "jest-junit": "^16.0.0",
100
99
  "lint-staged": "^15.2.1",
101
- "prettier": "^3.2.4",
100
+ "prettier": "^3.2.5",
102
101
  "standard-version": "^9.5.0",
103
102
  "ts-jest": "^29.1.2",
104
103
  "ts-node": "^10.9.2",
@@ -113,8 +112,7 @@
113
112
  "@krivega/jssip": "^3.22.0",
114
113
  "debug": "^4.3.4",
115
114
  "events-constructor": "^1.2.2",
116
- "ts-debounce": "^4.0.0",
117
- "webrtc-mock": "^1.0.2"
115
+ "ts-debounce": "^4.0.0"
118
116
  },
119
117
  "main:src": "src/index.ts"
120
118
  }