sip-connector 7.0.5 → 7.0.6
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/__fixtures__/Session.mock.d.ts +3 -0
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +3 -0
- package/package.json +17 -17
|
@@ -28,6 +28,9 @@ declare class Session extends BaseSession {
|
|
|
28
28
|
terminate({ status_code }?: {
|
|
29
29
|
status_code?: number;
|
|
30
30
|
}): this;
|
|
31
|
+
terminateAsync({ status_code }?: {
|
|
32
|
+
status_code?: number;
|
|
33
|
+
}): Promise<void>;
|
|
31
34
|
terminateRemote({ status_code }?: {
|
|
32
35
|
status_code?: number;
|
|
33
36
|
}): this;
|
package/dist/doMock.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var k=Object.defineProperty;var D=(o,t,e)=>t in o?k(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var r=(o,t,e)=>(D(o,typeof t!="symbol"?t+"":t,e),e);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("./SipConnector-DxGNVRHG.cjs"),b=require("@krivega/jssip/lib/NameAddrHeader"),L=require("@krivega/jssip/lib/URI"),P=require("node:events"),F=require("@krivega/jssip/lib/SIPMessage"),C=require("webrtc-mock"),T=require("events-constructor"),M=require("@krivega/jssip");class S extends F.IncomingRequest{constructor(e){super();r(this,"headers");this.headers=new Headers(e)}getHeader(e){return this.headers.get(e)||""}}class U{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 T(u.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 V{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 z(o){const t=o.match(/(purgatory)|[\d.]+/g);if(!t)throw new Error("wrong sip url");return t[0]}const p=400,y="777",q=o=>o.getVideoTracks().length>0;class A extends U{constructor({url:e="",mediaStream:n,eventHandlers:i,originator:s}){super({originator:s,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)},p)}));this.url=e,this.initPeerconnection(n)}initPeerconnection(e){return e?(this.createPeerconnection(e),!0):!1}createPeerconnection(e){const n=C.createAudioMediaStreamTrackMock();n.id="mainaudio1";const i=[n];if(q(e)){const c=C.createVideoMediaStreamTrackMock();c.id="mainvideo1",i.push(c)}this._connection=new V(void 0,i),this._addStream(e),setTimeout(()=>{this.trigger("peerconnection",{peerconnection:this.connection})},p)}connect(e){const n=z(e);setTimeout(()=>{this.url.includes(y)?this.trigger("failed",{originator:"remote",message:"IncomingResponse",cause:u.REJECTED}):(this.trigger("connecting"),setTimeout(()=>{this.trigger("enterRoom",{room:n})},100),setTimeout(()=>{this.trigger("accepted")},200),setTimeout(()=>{this.trigger("confirmed")},300))},p)}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 x{constructor(){r(this,"extraHeaders")}setExtraHeaders(t){this.extraHeaders=t}setExtraContactParams(){}}const a="PASSWORD_CORRECT",w="PASSWORD_CORRECT_2",I="NAME_INCORRECT",h=400,m=class m{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 A({url:t,mediaStream:n,eventHandlers:i,originator:"local"}),this.session.connect(t),this.session}));this._events=new T(u.UA_EVENT_NAMES);const[e,n]=t.uri.split(":"),[i,s]=n.split("@"),c={...t,uri:new M.URI(e,i,s)};this.configuration=c,this._registrator=new x}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")})},h):this.trigger("disconnected",{error:new Error("stoped")})}on(t,e){return this._events.on(t,e),this}once(t,e){return this._events.once(t,e),this}off(t,e){return this._events.off(t,e),this}removeAllListeners(){return this._events.removeEventHandlers(),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.user.includes(I)?(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Request Timeout"})},h)):!this._isRegistered&&e&&(t===a||t===w)?(this._isRegistered=!0,this._startedTimeout=setTimeout(()=>{this.trigger("registered")},h)):e&&t!==a&&t!==w&&(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Wrong credentials"})},h)),m.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(t){this.trigger("sipEvent",t)}};r(m,"isAvailableTelephony",!0);let E=m;class H{constructor(t){r(this,"url");this.url=t}}class j extends P.EventEmitter{constructor(e,n){super();r(this,"contentType");r(this,"body");this.contentType=e,this.body=n}}const f="remote",B=(o,t)=>{const e=new S(t),n={originator:f,request:e,info:new j("","")};o.newInfo(n)},K=(o,t)=>{const n={request:new S(t)};o.newSipEvent(n)},$=(o,{incomingNumber:t="1234",displayName:e,host:n})=>{const i=new A({originator:f}),s=new L("sip",t,n);i._remote_identity=new b(s,e),o.trigger("newRTCSession",{originator:f,session:i})},J=(o,t)=>{t?o.trigger("failed",t):o.trigger("failed",o)},N={triggerNewInfo:B,triggerNewSipEvent:K,triggerIncomingSession:$,triggerFailIncomingSession:J,WebSocketInterface:H,UA:E,C:{INVITE:"INVITE"}},l="user",d="displayName",g="SIP_SERVER_URL",R="SIP_WEB_SOCKET_SERVER_URL",Y=new N.WebSocketInterface(R),v={userAgent:"Chrome",sipServerUrl:g,sipWebSocketServerURL:R},G={...v},O={...v,user:l,password:a,register:!0},X={...O,displayName:d},Q={...v,displayName:d,register:!1},_={session_timers:!1,sockets:[Y],user_agent:"Chrome",sdp_semantics:"plan-b",register_expires:300,connection_recovery_max_interval:6,connection_recovery_min_interval:2},Z={..._,password:a,uri:new M.URI("sip",l,g),display_name:"",register:!0},ee={..._,password:a,uri:new M.URI("sip",l,g),display_name:d,register:!0},te={..._,display_name:d,register:!1},re={..._,display_name:"",register:!1},W="10.10.10.10",ne=[`X-Vinteo-Remote: ${W}`],oe=()=>new u.SipConnector({JsSIP:N});exports.FAILED_CONFERENCE_NUMBER=y;exports.NAME_INCORRECT=I;exports.PASSWORD_CORRECT=a;exports.PASSWORD_CORRECT_2=w;exports.SIP_SERVER_URL=g;exports.SIP_WEB_SOCKET_SERVER_URL=R;exports.dataForConnectionWithAuthorization=O;exports.dataForConnectionWithAuthorizationWithDisplayName=X;exports.dataForConnectionWithoutAuthorization=Q;exports.dataForConnectionWithoutAuthorizationWithoutDisplayName=G;exports.default=oe;exports.displayName=d;exports.extraHeadersRemoteAddress=ne;exports.remoteAddress=W;exports.uaConfigurationWithAuthorization=Z;exports.uaConfigurationWithAuthorizationWithDisplayName=ee;exports.uaConfigurationWithoutAuthorization=te;exports.uaConfigurationWithoutAuthorizationWithoutDisplayName=re;exports.user=l;
|
|
1
|
+
"use strict";var k=Object.defineProperty;var D=(o,t,e)=>t in o?k(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var r=(o,t,e)=>(D(o,typeof t!="symbol"?t+"":t,e),e);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("./SipConnector-DxGNVRHG.cjs"),b=require("@krivega/jssip/lib/NameAddrHeader"),L=require("@krivega/jssip/lib/URI"),P=require("node:events"),F=require("@krivega/jssip/lib/SIPMessage"),C=require("webrtc-mock"),T=require("events-constructor"),M=require("@krivega/jssip");class S extends F.IncomingRequest{constructor(e){super();r(this,"headers");this.headers=new Headers(e)}getHeader(e){return this.headers.get(e)||""}}class U{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 T(u.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 V{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 z(o){const t=o.match(/(purgatory)|[\d.]+/g);if(!t)throw new Error("wrong sip url");return t[0]}const p=400,y="777",q=o=>o.getVideoTracks().length>0;class A extends U{constructor({url:e="",mediaStream:n,eventHandlers:i,originator:s}){super({originator:s,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)},p)}));this.url=e,this.initPeerconnection(n)}initPeerconnection(e){return e?(this.createPeerconnection(e),!0):!1}createPeerconnection(e){const n=C.createAudioMediaStreamTrackMock();n.id="mainaudio1";const i=[n];if(q(e)){const c=C.createVideoMediaStreamTrackMock();c.id="mainvideo1",i.push(c)}this._connection=new V(void 0,i),this._addStream(e),setTimeout(()=>{this.trigger("peerconnection",{peerconnection:this.connection})},p)}connect(e){const n=z(e);setTimeout(()=>{this.url.includes(y)?this.trigger("failed",{originator:"remote",message:"IncomingResponse",cause:u.REJECTED}):(this.trigger("connecting"),setTimeout(()=>{this.trigger("enterRoom",{room:n})},100),setTimeout(()=>{this.trigger("accepted")},200),setTimeout(()=>{this.trigger("confirmed")},300))},p)}terminate({status_code:e}={}){return this.status_code=e,this.trigger("ended",{status_code:e}),this._isEnded=!1,this}async terminateAsync({status_code:e}={}){this.terminate({status_code:e})}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 x{constructor(){r(this,"extraHeaders")}setExtraHeaders(t){this.extraHeaders=t}setExtraContactParams(){}}const a="PASSWORD_CORRECT",w="PASSWORD_CORRECT_2",I="NAME_INCORRECT",h=400,m=class m{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 A({url:t,mediaStream:n,eventHandlers:i,originator:"local"}),this.session.connect(t),this.session}));this._events=new T(u.UA_EVENT_NAMES);const[e,n]=t.uri.split(":"),[i,s]=n.split("@"),c={...t,uri:new M.URI(e,i,s)};this.configuration=c,this._registrator=new x}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")})},h):this.trigger("disconnected",{error:new Error("stoped")})}on(t,e){return this._events.on(t,e),this}once(t,e){return this._events.once(t,e),this}off(t,e){return this._events.off(t,e),this}removeAllListeners(){return this._events.removeEventHandlers(),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.user.includes(I)?(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Request Timeout"})},h)):!this._isRegistered&&e&&(t===a||t===w)?(this._isRegistered=!0,this._startedTimeout=setTimeout(()=>{this.trigger("registered")},h)):e&&t!==a&&t!==w&&(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Wrong credentials"})},h)),m.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(t){this.trigger("sipEvent",t)}};r(m,"isAvailableTelephony",!0);let E=m;class H{constructor(t){r(this,"url");this.url=t}}class j extends P.EventEmitter{constructor(e,n){super();r(this,"contentType");r(this,"body");this.contentType=e,this.body=n}}const f="remote",B=(o,t)=>{const e=new S(t),n={originator:f,request:e,info:new j("","")};o.newInfo(n)},K=(o,t)=>{const n={request:new S(t)};o.newSipEvent(n)},$=(o,{incomingNumber:t="1234",displayName:e,host:n})=>{const i=new A({originator:f}),s=new L("sip",t,n);i._remote_identity=new b(s,e),o.trigger("newRTCSession",{originator:f,session:i})},J=(o,t)=>{t?o.trigger("failed",t):o.trigger("failed",o)},N={triggerNewInfo:B,triggerNewSipEvent:K,triggerIncomingSession:$,triggerFailIncomingSession:J,WebSocketInterface:H,UA:E,C:{INVITE:"INVITE"}},l="user",d="displayName",g="SIP_SERVER_URL",R="SIP_WEB_SOCKET_SERVER_URL",Y=new N.WebSocketInterface(R),v={userAgent:"Chrome",sipServerUrl:g,sipWebSocketServerURL:R},G={...v},O={...v,user:l,password:a,register:!0},X={...O,displayName:d},Q={...v,displayName:d,register:!1},_={session_timers:!1,sockets:[Y],user_agent:"Chrome",sdp_semantics:"plan-b",register_expires:300,connection_recovery_max_interval:6,connection_recovery_min_interval:2},Z={..._,password:a,uri:new M.URI("sip",l,g),display_name:"",register:!0},ee={..._,password:a,uri:new M.URI("sip",l,g),display_name:d,register:!0},te={..._,display_name:d,register:!1},re={..._,display_name:"",register:!1},W="10.10.10.10",ne=[`X-Vinteo-Remote: ${W}`],oe=()=>new u.SipConnector({JsSIP:N});exports.FAILED_CONFERENCE_NUMBER=y;exports.NAME_INCORRECT=I;exports.PASSWORD_CORRECT=a;exports.PASSWORD_CORRECT_2=w;exports.SIP_SERVER_URL=g;exports.SIP_WEB_SOCKET_SERVER_URL=R;exports.dataForConnectionWithAuthorization=O;exports.dataForConnectionWithAuthorizationWithDisplayName=X;exports.dataForConnectionWithoutAuthorization=Q;exports.dataForConnectionWithoutAuthorizationWithoutDisplayName=G;exports.default=oe;exports.displayName=d;exports.extraHeadersRemoteAddress=ne;exports.remoteAddress=W;exports.uaConfigurationWithAuthorization=Z;exports.uaConfigurationWithAuthorizationWithDisplayName=ee;exports.uaConfigurationWithoutAuthorization=te;exports.uaConfigurationWithoutAuthorizationWithoutDisplayName=re;exports.user=l;
|
package/dist/doMock.js
CHANGED
|
@@ -368,6 +368,9 @@ class R extends U {
|
|
|
368
368
|
terminate({ status_code: e } = {}) {
|
|
369
369
|
return this.status_code = e, this.trigger("ended", { status_code: e }), this._isEnded = !1, this;
|
|
370
370
|
}
|
|
371
|
+
async terminateAsync({ status_code: e } = {}) {
|
|
372
|
+
this.terminate({ status_code: e });
|
|
373
|
+
}
|
|
371
374
|
terminateRemote({ status_code: e } = {}) {
|
|
372
375
|
return this.status_code = e, this.trigger("ended", { status_code: e, originator: "remote" }), this;
|
|
373
376
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sip-connector",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.6",
|
|
4
4
|
"description": "Module for connect to Vinteo server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webrtc",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"import": "./dist/doMock.js"
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
|
-
"main": "./dist/index.
|
|
33
|
+
"main": "./dist/index.cjs",
|
|
34
34
|
"types": "dist/index.d.ts",
|
|
35
35
|
"typesVersions": {
|
|
36
36
|
"*": {
|
|
@@ -62,14 +62,14 @@
|
|
|
62
62
|
"test:coverage": "yarn test:ci --coverage --reporters=default --reporters=jest-junit"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@krivega/cancelable-promise": "^1.1.
|
|
66
|
-
"@krivega/jssip": "^3.24.
|
|
65
|
+
"@krivega/cancelable-promise": "^1.1.3",
|
|
66
|
+
"@krivega/jssip": "^3.24.2",
|
|
67
67
|
"debug": "^4.3.4",
|
|
68
|
-
"events-constructor": "^1.2.
|
|
69
|
-
"sequent-promises": "^2.0.
|
|
70
|
-
"stack-promises": "^2.0.
|
|
68
|
+
"events-constructor": "^1.2.3",
|
|
69
|
+
"sequent-promises": "^2.0.1",
|
|
70
|
+
"stack-promises": "^2.0.2",
|
|
71
71
|
"ts-debounce": "^4.0.0",
|
|
72
|
-
"webrtc-mock": "^1.0.
|
|
72
|
+
"webrtc-mock": "^1.0.4"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@babel/preset-typescript": "^7.24.1",
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
"@nabla/vite-plugin-eslint": "^2.0.4",
|
|
79
79
|
"@types/debug": "^4.1.12",
|
|
80
80
|
"@types/jest": "^29.5.12",
|
|
81
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
82
|
-
"@typescript-eslint/parser": "^7.
|
|
81
|
+
"@typescript-eslint/eslint-plugin": "^7.10.0",
|
|
82
|
+
"@typescript-eslint/parser": "^7.10.0",
|
|
83
83
|
"cross-env": "^7.0.3",
|
|
84
84
|
"eslint": "^8.57.0",
|
|
85
85
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"lint-staged": "^15.2.2",
|
|
100
100
|
"prettier": "^3.2.5",
|
|
101
101
|
"standard-version": "^9.5.0",
|
|
102
|
-
"ts-jest": "^29.1.
|
|
102
|
+
"ts-jest": "^29.1.3",
|
|
103
103
|
"ts-node": "^10.9.2",
|
|
104
104
|
"tsc-files": "^1.1.4",
|
|
105
105
|
"typescript": "^5.4.5",
|
|
@@ -108,14 +108,14 @@
|
|
|
108
108
|
"vite-tsconfig-paths": "^4.3.2"
|
|
109
109
|
},
|
|
110
110
|
"peerDependencies": {
|
|
111
|
-
"@krivega/cancelable-promise": "^1.1.
|
|
112
|
-
"@krivega/jssip": "^3.24.
|
|
111
|
+
"@krivega/cancelable-promise": "^1.1.3",
|
|
112
|
+
"@krivega/jssip": "^3.24.2",
|
|
113
113
|
"debug": "^4.3.4",
|
|
114
|
-
"events-constructor": "^1.2.
|
|
115
|
-
"sequent-promises": "^2.0.
|
|
116
|
-
"stack-promises": "^2.0.
|
|
114
|
+
"events-constructor": "^1.2.3",
|
|
115
|
+
"sequent-promises": "^2.0.1",
|
|
116
|
+
"stack-promises": "^2.0.2",
|
|
117
117
|
"ts-debounce": "^4.0.0",
|
|
118
|
-
"webrtc-mock": "^1.0.
|
|
118
|
+
"webrtc-mock": "^1.0.4"
|
|
119
119
|
},
|
|
120
120
|
"main:src": "src/index.ts"
|
|
121
121
|
}
|