sip-connector 19.4.0 → 19.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/doMock.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("node:events"),U=require("@krivega/jssip/lib/NameAddrHeader"),H=require("@krivega/jssip/lib/URI"),q=require("@krivega/jssip/lib/SIPMessage"),a=require("@krivega/jssip"),f=require("webrtc-mock"),S=require("events-constructor"),D=require("./@SipConnector-hbSoVizf.cjs");class w extends q.IncomingRequest{headers;constructor(e){super(),this.headers=new Headers(e)}getHeader(e){return this.headers.get(e)??""}}const G="incomingCall",x="declinedIncomingCall",z="failedIncomingCall",j="terminatedIncomingCall",y="connecting",Y="connected",B="disconnected",K="newRTCSession",J="registered",$="unregistered",Q="registrationFailed",X="newMessage",Z="sipEvent",ee="availableSecondRemoteStream",te="notAvailableSecondRemoteStream",re="mustStopPresentation",ne="shareState",oe="enterRoom",ie="useLicense",se="peerconnection:confirmed",ae="peerconnection:ontrack",ce="channels",de="channels:notify",he="ended:fromserver",Ee="main-cam-control",ue="admin-stop-main-cam",me="admin-start-main-cam",le="admin-stop-mic",pe="admin-start-mic",ge="admin-force-sync-media-state",_e="participant:added-to-list-moderators",Te="participant:removed-from-list-moderators",Ie="participant:move-request-to-stream",Se="participant:move-request-to-spectators",we="participant:move-request-to-participants",Ne="participation:accepting-word-request",Ce="participation:cancelling-word-request",Re="webcast:started",fe="webcast:stopped",Ae="account:changed",Me="account:deleted",Oe="conference:participant-token-issued",Pe="ended",ve="sending",De="reinvite",ye="replaces",Le="refer",Fe="progress",We="accepted",be="confirmed",ke="peerconnection",Ve="failed",Ue="muted",He="unmuted",qe="newDTMF",Ge="newInfo",xe="hold",ze="unhold",je="update",Ye="sdp",Be="icecandidate",Ke="getusermediafailed",Je="peerconnection:createofferfailed",$e="peerconnection:createanswerfailed",Qe="peerconnection:setlocaldescriptionfailed",Xe="peerconnection:setremotedescriptionfailed",Ze="presentation:start",et="presentation:started",tt="presentation:end",rt="presentation:ended",nt="presentation:failed",ot=[G,x,j,z,Ne,Ce,Ie,de,Oe,Ae,Me,Re,fe,_e,Te],L=[y,Y,B,K,J,$,Q,X,Z],it=[ee,te,re,ne,oe,ie,se,ae,ce,he,Ee,me,ue,le,pe,ge,Se,we],_=[Pe,y,ve,De,ye,Le,Fe,We,be,ke,Ve,Ue,He,qe,Ge,xe,ze,je,Ye,Be,Ke,Je,$e,Qe,Xe,Ze,et,tt,rt,nt];[...L,...ot];[..._,...it];class st{originator;connection;events;remote_identity;mutedOptions={audio:!1,video:!1};constructor({originator:e="local",eventHandlers:t,remoteIdentity:r}){this.originator=e,this.events=new S.Events(_),this.initEvents(t),this.remote_identity=r}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 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.")}get C(){throw new Error("Method not implemented.")}get causes(){throw new Error("Method not implemented.")}get id(){throw new Error("Method not implemented.")}get data(){throw new Error("Method not implemented.")}set data(e){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){return this.events.off(e,t),this}removeAllListeners(e){return console.warn("Method not implemented. Event:",e),this}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){e&&Object.entries(e).forEach(([t,r])=>{this.on(t,r)})}on(e,t){return _.includes(e)&&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 this.trigger("presentation:start",e),this.trigger("presentation:started",e),e}async stopPresentation(e){return this.trigger("presentation:end",e),this.trigger("presentation:ended",e),e}isEstablished(){return!0}}class A{stats=new Map().set("codec",{mimeType:"video/h264"});dtmf=null;track=null;transport=null;transform=null;parameters={encodings:[{}],transactionId:"0",codecs:[],headerExtensions:[],rtcp:{}};parametersGets;constructor({track:e}={}){this.track=e??null}async getStats(){return this.stats}async replaceTrack(e){this.track=e??null}async setParameters(e){if(e!==this.parametersGets)throw new Error("Failed to execute 'setParameters' on 'RTCRtpSender': Read-only field modified in setParameters().");const{transactionId:t}=this.parameters;this.parameters={...this.parameters,...e,transactionId:`${Number(t)+1}`}}getParameters(){return this.parametersGets={...this.parameters},this.parametersGets}setStreams(){throw new Error("Method not implemented.")}}class M{currentDirection="sendrecv";direction="sendrecv";mid=null;receiver;sender;stopped=!1;constructor(e){this.sender=e}setCodecPreferences(e){}stop(){}}const at=["track"];class ct{senders=[];receivers=[];canTrickleIceCandidates;connectionState;currentLocalDescription;currentRemoteDescription;iceConnectionState;iceGatheringState;idpErrorInfo;idpLoginUrl;localDescription;onconnectionstatechange;ondatachannel;onicecandidate;onicecandidateerror=null;oniceconnectionstatechange;onicegatheringstatechange;onnegotiationneeded;onsignalingstatechange;ontrack;peerIdentity=void 0;pendingLocalDescription;pendingRemoteDescription;remoteDescription;sctp=null;signalingState;events;constructor(e,t){this.events=new S.Events(at),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){this.events.on(e,t)}removeEventListener(e,t,r){this.events.off(e,t)}dispatchEvent(e){throw new Error("Method not implemented.")}getReceivers=()=>this.receivers;getSenders=()=>this.senders;addTrack=(e,...t)=>{const r=new A({track:e}),n=new M(r);return n.mid=e.kind==="audio"?"0":"1",this.senders.push(r),this.events.trigger("track",{track:e,transceiver:n}),r};addTrackWithMid=(e,t)=>{const r=new A({track:e}),n=new M(r);return t===void 0?n.mid=e.kind==="audio"?"0":"1":n.mid=t,this.senders.push(r),this.events.trigger("track",{track:e,transceiver:n}),r}}function dt(o){const e=o.match(/(purgatory)|[\d.]+/g);if(!e)throw new Error("wrong sip url");return e[0]}const O=400,F="777",ht=o=>o.getVideoTracks().length>0;class s extends st{static presentationError;static startPresentationError;static countStartPresentationError=Number.POSITIVE_INFINITY;static countStartsPresentation=0;url;status_code;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)},O)});replaceMediaStream=jest.fn(async e=>{});_isReadyToReOffer=jest.fn(()=>!0);addTransceiver=jest.fn((e,t)=>({}));restartIce=jest.fn(async e=>!0);isEndedInner=!1;delayStartPresentation=0;timeoutStartPresentation;timeoutConnect;timeoutNewInfo;timeoutAccepted;timeoutConfirmed;constructor({eventHandlers:e,originator:t,remoteIdentity:r=new a.NameAddrHeader(new a.URI("sip","caller1","test1.com",5060),"Test Caller 1"),delayStartPresentation:n=0}){super({originator:t,eventHandlers:e,remoteIdentity:r}),this.delayStartPresentation=n}static get C(){return a.SessionStatus}static setPresentationError(e){this.presentationError=e}static resetPresentationError(){this.presentationError=void 0}static setStartPresentationError(e,{count:t=Number.POSITIVE_INFINITY}={}){this.startPresentationError=e,this.countStartPresentationError=t}static resetStartPresentationError(){this.startPresentationError=void 0,this.countStartPresentationError=Number.POSITIVE_INFINITY,this.countStartsPresentation=0}startPresentation=async e=>(s.countStartsPresentation+=1,new Promise((t,r)=>{this.timeoutStartPresentation=setTimeout(()=>{if(s.presentationError){this.trigger("presentation:start",e),this.trigger("presentation:failed",e),r(s.presentationError);return}if(s.startPresentationError&&s.countStartsPresentation<s.countStartPresentationError){this.trigger("presentation:start",e),this.trigger("presentation:failed",e),r(s.startPresentationError);return}t(super.startPresentation(e))},this.delayStartPresentation)}));stopPresentation=async e=>{if(s.presentationError)throw this.trigger("presentation:end",e),this.trigger("presentation:failed",e),s.presentationError;return super.stopPresentation(e)};initPeerconnection(e){return e?(this.createPeerconnection(e),!0):!1}createPeerconnection(e){const t=f.createAudioMediaStreamTrackMock();t.id="mainaudio1";const r=[t];if(ht(e)){const c=f.createVideoMediaStreamTrackMock();c.id="mainvideo1",r.push(c)}this.connection=new ct(void 0,r),this.addStream(e),this.trigger("peerconnection",{peerconnection:this.connection})}connect(e,{mediaStream:t}={}){const r=dt(e);return this.initPeerconnection(t),this.timeoutConnect=setTimeout(()=>{e.includes(F)?this.trigger("failed",{originator:"remote",message:"IncomingResponse",cause:"Rejected"}):(this.trigger("connecting"),this.timeoutNewInfo=setTimeout(()=>{this.newInfo({originator:D.Originator.REMOTE,request:{getHeader:n=>n==="content-type"?"application/vinteo.webrtc.roomname":n==="x-webrtc-enter-room"?r:n==="x-webrtc-participant-name"?"Test Caller 1":""}})},100),this.timeoutAccepted=setTimeout(()=>{this.trigger("accepted")},200),this.timeoutConfirmed=setTimeout(()=>{this.trigger("confirmed")},300))},O),this.connection}terminate({status_code:e,cause:t}={}){return this.status_code=e,this.trigger("ended",{status_code:e,cause:t,originator:"local"}),this.isEndedInner=!1,this}async terminateAsync({status_code:e,cause:t}={}){this.terminate({status_code:e,cause:t})}terminateRemote({status_code:e}={}){return this.status_code=e,this.trigger("ended",{status_code:e,originator:"remote"}),this}addStream(e,t="getTracks"){e[t]().forEach(r=>this.connection.addTrack(r))}forEachSenders(e){const t=this.connection.getSenders();for(const r of t)e(r);return t}toggleMuteAudio(e){this.forEachSenders(({track:t})=>{t?.kind==="audio"&&(t.enabled=!e)})}toggleMuteVideo(e){this.forEachSenders(({track:t})=>{t?.kind==="video"&&(t.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}onmute({audio:e,video:t}){this.trigger("muted",{audio:e,video:t})}async sendInfo(){}isEnded(){return this.isEndedInner}newInfo(e){this.trigger("newInfo",e)}clear(){clearTimeout(this.timeoutStartPresentation),clearTimeout(this.timeoutConnect),clearTimeout(this.timeoutNewInfo),clearTimeout(this.timeoutAccepted),clearTimeout(this.timeoutConfirmed)}}class Et{extraHeaders=[];setExtraHeaders(e){this.extraHeaders=e}setExtraContactParams(){}}const d="PASSWORD_CORRECT",T="PASSWORD_CORRECT_2",W="NAME_INCORRECT",E=400,g={url:"wss://sipServerUrl/webrtc/wss/",sip_uri:"sip:sipServerUrl;transport=ws",via_transport:"WSS"},P={status_code:200,reason_phrase:"OK"},v={status_code:401,reason_phrase:"Unauthorized"};class i{static isAvailableTelephony=!0;static startError;static countStartError=Number.POSITIVE_INFINITY;static countStarts=0;events;registratorInner;call=jest.fn((e,t)=>{const{mediaStream:r,eventHandlers:n}=t;return this.session=new s({eventHandlers:n,originator:"local"}),this.session.connect(e,{mediaStream:r}),this.session});sendOptions=jest.fn((e,t,r)=>{console.log("sendOptions",e,t,r)});start=jest.fn(()=>{if(i.countStarts+=1,i.startError&&i.countStarts<i.countStartError){this.trigger("disconnected",i.startError);return}this.register()});stop=jest.fn(()=>{this.startedTimeout&&clearTimeout(this.startedTimeout),this.stopedTimeout&&clearTimeout(this.stopedTimeout),this.unregister(),this.isStarted()?this.stopedTimeout=setTimeout(()=>{this.trigger("disconnected",{error:!0,socket:g})},E):this.trigger("disconnected",{error:!0,socket:g})});removeAllListeners=jest.fn(()=>(this.events.removeEventHandlers(),this));once=jest.fn((e,t)=>(this.events.once(e,t),this));startedTimeout;stopedTimeout;session;isRegisteredInner;isConnectedInner;configuration;constructor(e){this.events=new S.Events(L);const[t,r]=e.uri.split(":"),[n,c]=r.split("@"),p={...e,uri:new a.URI(t,n,c)};this.configuration=p,this.registratorInner=new Et}static setStartError(e,{count:t=Number.POSITIVE_INFINITY}={}){i.startError=e,i.countStartError=t}static resetStartError(){i.startError=void 0,i.countStartError=Number.POSITIVE_INFINITY,i.countStarts=0}static setAvailableTelephony(){i.isAvailableTelephony=!0}static setNotAvailableTelephony(){i.isAvailableTelephony=!1}static reset(){i.resetStartError(),i.setAvailableTelephony()}on(e,t){return this.events.on(e,t),this}off(e,t){return this.events.off(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===!0&&r.user.includes(W)?(this.isRegisteredInner=!1,this.isConnectedInner=!1,this.startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:v,cause:a.C.causes.REJECTED})},E)):!this.isRegistered()&&t===!0&&(e===d||e===T)?(this.isRegisteredInner=!0,this.startedTimeout=setTimeout(()=>{this.trigger("registered",{response:P})},E)):t===!0&&e!==d&&e!==T&&(this.isRegisteredInner=!1,this.isConnectedInner=!1,this.startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:v,cause:a.C.causes.REJECTED})},E)),i.isAvailableTelephony?(this.trigger("connected",{socket:g}),this.isConnectedInner=!0):this.stop()}unregister(){this.isRegisteredInner=!1,this.isConnectedInner=!1,this.trigger("unregistered",{response:P})}isRegistered(){return this.isRegisteredInner===!0}isConnected(){return this.isConnectedInner===!0}isStarted(){return this.configuration.register===!0&&this.isRegisteredInner===!0||this.configuration.register!==!0&&this.isConnectedInner===!0}newSipEvent(e){this.trigger("sipEvent",e)}registrator(){return this.registratorInner}}class ut{url;constructor(e){this.url=e}}class mt extends V.EventEmitter{contentType;body;constructor(e,t){super(),this.contentType=e,this.body=t}}const I="remote",lt=(o,e)=>{const t=new w(e),r={originator:I,request:t,info:new mt("","")};o.newInfo(r)},pt=(o,e)=>{const r={event:"sipEvent",request:new w(e)};o.newSipEvent(r)},gt=(o,{incomingNumber:e="1234",displayName:t,host:r})=>{const n=new s({originator:I,eventHandlers:{}}),c=new H("sip",e,r);n.remote_identity=new U(c,t);const p=new w([]);o.trigger("newRTCSession",{originator:I,session:n,request:p})},_t=(o,e)=>{e?o.trigger("failed",e):o.trigger("failed",o)},N={triggerNewInfo:lt,triggerNewSipEvent:pt,triggerIncomingSession:gt,triggerFailIncomingSession:_t,WebSocketInterface:ut,UA:i,C:{INVITE:"INVITE"}},u="user",h="displayName",m="SIP_SERVER_URL",C="SIP_WEB_SOCKET_SERVER_URL",Tt=new N.WebSocketInterface(C),R={userAgent:"Chrome",sipServerUrl:m,sipWebSocketServerURL:C},It={...R},b={...R,user:u,password:d,register:!0},St={...b,displayName:h},wt={...R,displayName:h,register:!1},l={session_timers:!1,sockets:[Tt],user_agent:"Chrome",sdpSemantics:"unified-plan",register_expires:300,connection_recovery_max_interval:6,connection_recovery_min_interval:2},Nt={...l,password:d,uri:new a.URI("sip",u,m),display_name:"",register:!0},Ct={...l,password:d,uri:new a.URI("sip",u,m),display_name:h,register:!0},Rt={...l,display_name:h,register:!1},ft={...l,display_name:"",register:!1},k="10.10.10.10",At=[`X-Vinteo-Remote: ${k}`],Mt=()=>new D.SipConnector({JsSIP:N});exports.FAILED_CONFERENCE_NUMBER=F;exports.JsSIP=N;exports.NAME_INCORRECT=W;exports.PASSWORD_CORRECT=d;exports.PASSWORD_CORRECT_2=T;exports.SIP_SERVER_URL=m;exports.SIP_WEB_SOCKET_SERVER_URL=C;exports.dataForConnectionWithAuthorization=b;exports.dataForConnectionWithAuthorizationWithDisplayName=St;exports.dataForConnectionWithoutAuthorization=wt;exports.dataForConnectionWithoutAuthorizationWithoutDisplayName=It;exports.displayName=h;exports.doMockSipConnector=Mt;exports.extraHeadersRemoteAddress=At;exports.remoteAddress=k;exports.uaConfigurationWithAuthorization=Nt;exports.uaConfigurationWithAuthorizationWithDisplayName=Ct;exports.uaConfigurationWithoutAuthorization=Rt;exports.uaConfigurationWithoutAuthorizationWithoutDisplayName=ft;exports.user=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("node:events"),U=require("@krivega/jssip/lib/NameAddrHeader"),H=require("@krivega/jssip/lib/URI"),q=require("@krivega/jssip/lib/SIPMessage"),a=require("@krivega/jssip"),f=require("webrtc-mock"),S=require("events-constructor"),D=require("./@SipConnector-1uu5lXCq.cjs");class N extends q.IncomingRequest{headers;constructor(e){super(),this.headers=new Headers(e)}getHeader(e){return this.headers.get(e)??""}}const G="incomingCall",x="declinedIncomingCall",z="failedIncomingCall",Y="terminatedIncomingCall",y="connecting",j="connected",B="disconnected",K="newRTCSession",J="registered",$="unregistered",Q="registrationFailed",X="newMessage",Z="sipEvent",ee="availableSecondRemoteStream",te="notAvailableSecondRemoteStream",re="mustStopPresentation",ne="shareState",oe="enterRoom",ie="useLicense",se="peerconnection:confirmed",ae="peerconnection:ontrack",ce="channels",de="channels:notify",Ee="ended:fromserver",he="main-cam-control",ue="admin-stop-main-cam",me="admin-start-main-cam",le="admin-stop-mic",pe="admin-start-mic",ge="admin-force-sync-media-state",_e="participant:added-to-list-moderators",Te="participant:removed-from-list-moderators",Ie="participant:move-request-to-stream",Se="participant:move-request-to-spectators",Ne="participant:move-request-to-participants",we="participation:accepting-word-request",Ce="participation:cancelling-word-request",Re="webcast:started",fe="webcast:stopped",Ae="account:changed",Me="account:deleted",Oe="conference:participant-token-issued",Pe="ended",ve="sending",De="reinvite",ye="replaces",Le="refer",Fe="progress",We="accepted",be="confirmed",ke="peerconnection",Ve="failed",Ue="muted",He="unmuted",qe="newDTMF",Ge="newInfo",xe="hold",ze="unhold",Ye="update",je="sdp",Be="icecandidate",Ke="getusermediafailed",Je="peerconnection:createofferfailed",$e="peerconnection:createanswerfailed",Qe="peerconnection:setlocaldescriptionfailed",Xe="peerconnection:setremotedescriptionfailed",Ze="presentation:start",et="presentation:started",tt="presentation:end",rt="presentation:ended",nt="presentation:failed",ot=[G,x,Y,z,we,Ce,Ie,de,Oe,Ae,Me,Re,fe,_e,Te],L=[y,j,B,K,J,$,Q,X,Z],it=[ee,te,re,ne,oe,ie,se,ae,ce,Ee,he,me,ue,le,pe,ge,Se,Ne],_=[Pe,y,ve,De,ye,Le,Fe,We,be,ke,Ve,Ue,He,qe,Ge,xe,ze,Ye,je,Be,Ke,Je,$e,Qe,Xe,Ze,et,tt,rt,nt];[...L,...ot];[..._,...it];class st{originator;connection;events;remote_identity;mutedOptions={audio:!1,video:!1};constructor({originator:e="local",eventHandlers:t,remoteIdentity:r}){this.originator=e,this.events=new S.Events(_),this.initEvents(t),this.remote_identity=r}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 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.")}get C(){throw new Error("Method not implemented.")}get causes(){throw new Error("Method not implemented.")}get id(){throw new Error("Method not implemented.")}get data(){throw new Error("Method not implemented.")}set data(e){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){return this.events.off(e,t),this}removeAllListeners(e){return console.warn("Method not implemented. Event:",e),this}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){e&&Object.entries(e).forEach(([t,r])=>{this.on(t,r)})}on(e,t){return _.includes(e)&&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 this.trigger("presentation:start",e),this.trigger("presentation:started",e),e}async stopPresentation(e){return this.trigger("presentation:end",e),this.trigger("presentation:ended",e),e}isEstablished(){return!0}}class A{stats=new Map().set("codec",{mimeType:"video/h264"});dtmf=null;track=null;transport=null;transform=null;parameters={encodings:[{}],transactionId:"0",codecs:[],headerExtensions:[],rtcp:{}};parametersGets;constructor({track:e}={}){this.track=e??null}async getStats(){return this.stats}async replaceTrack(e){this.track=e??null}async setParameters(e){if(e!==this.parametersGets)throw new Error("Failed to execute 'setParameters' on 'RTCRtpSender': Read-only field modified in setParameters().");const{transactionId:t}=this.parameters;this.parameters={...this.parameters,...e,transactionId:`${Number(t)+1}`}}getParameters(){return this.parametersGets={...this.parameters},this.parametersGets}setStreams(){throw new Error("Method not implemented.")}}class M{currentDirection="sendrecv";direction="sendrecv";mid=null;receiver;sender;stopped=!1;constructor(e){this.sender=e}setCodecPreferences(e){}stop(){}}const at=["track"];class ct{senders=[];receivers=[];canTrickleIceCandidates;connectionState;currentLocalDescription;currentRemoteDescription;iceConnectionState;iceGatheringState;idpErrorInfo;idpLoginUrl;localDescription;onconnectionstatechange;ondatachannel;onicecandidate;onicecandidateerror=null;oniceconnectionstatechange;onicegatheringstatechange;onnegotiationneeded;onsignalingstatechange;ontrack;peerIdentity=void 0;pendingLocalDescription;pendingRemoteDescription;remoteDescription;sctp=null;signalingState;events;constructor(e,t){this.events=new S.Events(at),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){this.events.on(e,t)}removeEventListener(e,t,r){this.events.off(e,t)}dispatchEvent(e){throw new Error("Method not implemented.")}getReceivers=()=>this.receivers;getSenders=()=>this.senders;addTrack=(e,...t)=>{const r=new A({track:e}),n=new M(r);return n.mid=e.kind==="audio"?"0":"1",this.senders.push(r),this.events.trigger("track",{track:e,transceiver:n}),r};addTrackWithMid=(e,t)=>{const r=new A({track:e}),n=new M(r);return t===void 0?n.mid=e.kind==="audio"?"0":"1":n.mid=t,this.senders.push(r),this.events.trigger("track",{track:e,transceiver:n}),r}}function dt(o){const e=o.match(/(purgatory)|[\d.]+/g);if(!e)throw new Error("wrong sip url");return e[0]}const O=400,F="777",Et=o=>o.getVideoTracks().length>0;class s extends st{static presentationError;static startPresentationError;static countStartPresentationError=Number.POSITIVE_INFINITY;static countStartsPresentation=0;url;status_code;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)},O)});replaceMediaStream=jest.fn(async e=>{});_isReadyToReOffer=jest.fn(()=>!0);addTransceiver=jest.fn((e,t)=>({}));restartIce=jest.fn(async e=>!0);isEndedInner=!1;delayStartPresentation=0;timeoutStartPresentation;timeoutConnect;timeoutNewInfo;timeoutAccepted;timeoutConfirmed;constructor({eventHandlers:e,originator:t,remoteIdentity:r=new a.NameAddrHeader(new a.URI("sip","caller1","test1.com",5060),"Test Caller 1"),delayStartPresentation:n=0}){super({originator:t,eventHandlers:e,remoteIdentity:r}),this.delayStartPresentation=n}static get C(){return a.SessionStatus}static setPresentationError(e){this.presentationError=e}static resetPresentationError(){this.presentationError=void 0}static setStartPresentationError(e,{count:t=Number.POSITIVE_INFINITY}={}){this.startPresentationError=e,this.countStartPresentationError=t}static resetStartPresentationError(){this.startPresentationError=void 0,this.countStartPresentationError=Number.POSITIVE_INFINITY,this.countStartsPresentation=0}startPresentation=async e=>(s.countStartsPresentation+=1,new Promise((t,r)=>{this.timeoutStartPresentation=setTimeout(()=>{if(s.presentationError){this.trigger("presentation:start",e),this.trigger("presentation:failed",e),r(s.presentationError);return}if(s.startPresentationError&&s.countStartsPresentation<s.countStartPresentationError){this.trigger("presentation:start",e),this.trigger("presentation:failed",e),r(s.startPresentationError);return}t(super.startPresentation(e))},this.delayStartPresentation)}));stopPresentation=async e=>{if(s.presentationError)throw this.trigger("presentation:end",e),this.trigger("presentation:failed",e),s.presentationError;return super.stopPresentation(e)};initPeerconnection(e){return e?(this.createPeerconnection(e),!0):!1}createPeerconnection(e){const t=f.createAudioMediaStreamTrackMock();t.id="mainaudio1";const r=[t];if(Et(e)){const c=f.createVideoMediaStreamTrackMock();c.id="mainvideo1",r.push(c)}this.connection=new ct(void 0,r),this.addStream(e),this.trigger("peerconnection",{peerconnection:this.connection})}connect(e,{mediaStream:t}={}){const r=dt(e);return this.initPeerconnection(t),this.timeoutConnect=setTimeout(()=>{e.includes(F)?this.trigger("failed",{originator:"remote",message:"IncomingResponse",cause:"Rejected"}):(this.trigger("connecting"),this.timeoutNewInfo=setTimeout(()=>{this.newInfo({originator:D.Originator.REMOTE,request:{getHeader:n=>n==="content-type"?"application/vinteo.webrtc.roomname":n==="x-webrtc-enter-room"?r:n==="x-webrtc-participant-name"?"Test Caller 1":""}})},100),this.timeoutAccepted=setTimeout(()=>{this.trigger("accepted")},200),this.timeoutConfirmed=setTimeout(()=>{this.trigger("confirmed")},300))},O),this.connection}terminate({status_code:e,cause:t}={}){return this.status_code=e,this.trigger("ended",{status_code:e,cause:t,originator:"local"}),this.isEndedInner=!1,this}async terminateAsync({status_code:e,cause:t}={}){this.terminate({status_code:e,cause:t})}terminateRemote({status_code:e}={}){return this.status_code=e,this.trigger("ended",{status_code:e,originator:"remote"}),this}addStream(e,t="getTracks"){e[t]().forEach(r=>this.connection.addTrack(r))}forEachSenders(e){const t=this.connection.getSenders();for(const r of t)e(r);return t}toggleMuteAudio(e){this.forEachSenders(({track:t})=>{t?.kind==="audio"&&(t.enabled=!e)})}toggleMuteVideo(e){this.forEachSenders(({track:t})=>{t?.kind==="video"&&(t.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}onmute({audio:e,video:t}){this.trigger("muted",{audio:e,video:t})}async sendInfo(){}isEnded(){return this.isEndedInner}newInfo(e){this.trigger("newInfo",e)}clear(){clearTimeout(this.timeoutStartPresentation),clearTimeout(this.timeoutConnect),clearTimeout(this.timeoutNewInfo),clearTimeout(this.timeoutAccepted),clearTimeout(this.timeoutConfirmed)}}class ht{extraHeaders=[];setExtraHeaders(e){this.extraHeaders=e}setExtraContactParams(){}}const d="PASSWORD_CORRECT",T="PASSWORD_CORRECT_2",W="NAME_INCORRECT",h=400,g={url:"wss://sipServerUrl/webrtc/wss/",sip_uri:"sip:sipServerUrl;transport=ws",via_transport:"WSS"},P={status_code:200,reason_phrase:"OK"},v={status_code:401,reason_phrase:"Unauthorized"};class i{static isAvailableTelephony=!0;static startError;static countStartError=Number.POSITIVE_INFINITY;static countStarts=0;events;registratorInner;call=jest.fn((e,t)=>{const{mediaStream:r,eventHandlers:n}=t;return this.session=new s({eventHandlers:n,originator:"local"}),this.session.connect(e,{mediaStream:r}),this.session});sendOptions=jest.fn((e,t,r)=>{console.log("sendOptions",e,t,r)});start=jest.fn(()=>{if(i.countStarts+=1,i.startError&&i.countStarts<i.countStartError){this.trigger("disconnected",i.startError);return}this.register()});stop=jest.fn(()=>{this.startedTimeout&&clearTimeout(this.startedTimeout),this.stopedTimeout&&clearTimeout(this.stopedTimeout),this.unregister(),this.isStarted()?this.stopedTimeout=setTimeout(()=>{this.trigger("disconnected",{error:!0,socket:g})},h):this.trigger("disconnected",{error:!0,socket:g})});removeAllListeners=jest.fn(()=>(this.events.removeEventHandlers(),this));once=jest.fn((e,t)=>(this.events.once(e,t),this));startedTimeout;stopedTimeout;session;isRegisteredInner;isConnectedInner;configuration;constructor(e){this.events=new S.Events(L);const[t,r]=e.uri.split(":"),[n,c]=r.split("@"),p={...e,uri:new a.URI(t,n,c)};this.configuration=p,this.registratorInner=new ht}static setStartError(e,{count:t=Number.POSITIVE_INFINITY}={}){i.startError=e,i.countStartError=t}static resetStartError(){i.startError=void 0,i.countStartError=Number.POSITIVE_INFINITY,i.countStarts=0}static setAvailableTelephony(){i.isAvailableTelephony=!0}static setNotAvailableTelephony(){i.isAvailableTelephony=!1}static reset(){i.resetStartError(),i.setAvailableTelephony()}on(e,t){return this.events.on(e,t),this}off(e,t){return this.events.off(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===!0&&r.user.includes(W)?(this.isRegisteredInner=!1,this.isConnectedInner=!1,this.startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:v,cause:a.C.causes.REJECTED})},h)):!this.isRegistered()&&t===!0&&(e===d||e===T)?(this.isRegisteredInner=!0,this.startedTimeout=setTimeout(()=>{this.trigger("registered",{response:P})},h)):t===!0&&e!==d&&e!==T&&(this.isRegisteredInner=!1,this.isConnectedInner=!1,this.startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:v,cause:a.C.causes.REJECTED})},h)),i.isAvailableTelephony?(this.trigger("connected",{socket:g}),this.isConnectedInner=!0):this.stop()}unregister(){this.isRegisteredInner=!1,this.isConnectedInner=!1,this.trigger("unregistered",{response:P})}isRegistered(){return this.isRegisteredInner===!0}isConnected(){return this.isConnectedInner===!0}isStarted(){return this.configuration.register===!0&&this.isRegisteredInner===!0||this.configuration.register!==!0&&this.isConnectedInner===!0}newSipEvent(e){this.trigger("sipEvent",e)}registrator(){return this.registratorInner}}class ut{url;constructor(e){this.url=e}}class mt extends V.EventEmitter{contentType;body;constructor(e,t){super(),this.contentType=e,this.body=t}}const I="remote",lt=(o,e)=>{const t=new N(e),r={originator:I,request:t,info:new mt("","")};o.newInfo(r)},pt=(o,e)=>{const r={event:"sipEvent",request:new N(e)};o.newSipEvent(r)},gt=(o,{incomingNumber:e="1234",displayName:t,host:r})=>{const n=new s({originator:I,eventHandlers:{}}),c=new H("sip",e,r);n.remote_identity=new U(c,t);const p=new N([]);o.trigger("newRTCSession",{originator:I,session:n,request:p})},_t=(o,e)=>{e?o.trigger("failed",e):o.trigger("failed",o)},w={triggerNewInfo:lt,triggerNewSipEvent:pt,triggerIncomingSession:gt,triggerFailIncomingSession:_t,WebSocketInterface:ut,UA:i,C:{INVITE:"INVITE"}},u="user",E="displayName",m="SIP_SERVER_URL",C="SIP_WEB_SOCKET_SERVER_URL",Tt=new w.WebSocketInterface(C),R={displayName:"DISPLAY_NAME",userAgent:"Chrome",sipServerUrl:m,sipWebSocketServerURL:C},It={...R,displayName:"DISPLAY_NAME",register:!1},b={...R,user:u,password:d,register:!0},St={...b,displayName:E},Nt={...R,displayName:E,register:!1},l={session_timers:!1,sockets:[Tt],user_agent:"Chrome",sdpSemantics:"unified-plan",register_expires:300,connection_recovery_max_interval:6,connection_recovery_min_interval:2},wt={...l,password:d,uri:new a.URI("sip",u,m),display_name:"DISPLAY_NAME",register:!0},Ct={...l,password:d,uri:new a.URI("sip",u,m),display_name:E,register:!0},Rt={...l,display_name:E,register:!1},ft={...l,display_name:"DISPLAY_NAME",register:!1},k="10.10.10.10",At=[`X-Vinteo-Remote: ${k}`],Mt=()=>new D.SipConnector({JsSIP:w});exports.FAILED_CONFERENCE_NUMBER=F;exports.JsSIP=w;exports.NAME_INCORRECT=W;exports.PASSWORD_CORRECT=d;exports.PASSWORD_CORRECT_2=T;exports.SIP_SERVER_URL=m;exports.SIP_WEB_SOCKET_SERVER_URL=C;exports.dataForConnectionWithAuthorization=b;exports.dataForConnectionWithAuthorizationWithDisplayName=St;exports.dataForConnectionWithoutAuthorization=Nt;exports.dataForConnectionWithoutAuthorizationWithoutDisplayName=It;exports.displayName=E;exports.doMockSipConnector=Mt;exports.extraHeadersRemoteAddress=At;exports.remoteAddress=k;exports.uaConfigurationWithAuthorization=wt;exports.uaConfigurationWithAuthorizationWithDisplayName=Ct;exports.uaConfigurationWithoutAuthorization=Rt;exports.uaConfigurationWithoutAuthorizationWithoutDisplayName=ft;exports.user=u;
package/dist/doMock.js CHANGED
@@ -4,9 +4,9 @@ import b from "@krivega/jssip/lib/URI";
4
4
  import { IncomingRequest as k } from "@krivega/jssip/lib/SIPMessage";
5
5
  import { NameAddrHeader as V, URI as E, SessionStatus as W, C as N } from "@krivega/jssip";
6
6
  import { createAudioMediaStreamTrackMock as U, createVideoMediaStreamTrackMock as G } from "webrtc-mock";
7
- import { Events as T } from "events-constructor";
8
- import { O as H, S as x } from "./@SipConnector-DIeMny8m.js";
9
- class _ extends k {
7
+ import { Events as _ } from "events-constructor";
8
+ import { O as H, S as x } from "./@SipConnector-JzZVT23M.js";
9
+ class T extends k {
10
10
  headers;
11
11
  constructor(e) {
12
12
  super(), this.headers = new Headers(e);
@@ -15,24 +15,24 @@ class _ extends k {
15
15
  return this.headers.get(e) ?? "";
16
16
  }
17
17
  }
18
- const j = "incomingCall", q = "declinedIncomingCall", Y = "failedIncomingCall", z = "terminatedIncomingCall", v = "connecting", B = "connected", K = "disconnected", $ = "newRTCSession", J = "registered", Q = "unregistered", X = "registrationFailed", Z = "newMessage", ee = "sipEvent", te = "availableSecondRemoteStream", re = "notAvailableSecondRemoteStream", ne = "mustStopPresentation", oe = "shareState", se = "enterRoom", ie = "useLicense", ae = "peerconnection:confirmed", ce = "peerconnection:ontrack", de = "channels", Ee = "channels:notify", he = "ended:fromserver", me = "main-cam-control", ue = "admin-stop-main-cam", le = "admin-start-main-cam", pe = "admin-stop-mic", ge = "admin-start-mic", Te = "admin-force-sync-media-state", _e = "participant:added-to-list-moderators", Ie = "participant:removed-from-list-moderators", Se = "participant:move-request-to-stream", we = "participant:move-request-to-spectators", Ne = "participant:move-request-to-participants", fe = "participation:accepting-word-request", Ce = "participation:cancelling-word-request", Re = "webcast:started", Me = "webcast:stopped", Ae = "account:changed", Oe = "account:deleted", ve = "conference:participant-token-issued", Pe = "ended", De = "sending", ye = "reinvite", Le = "replaces", Fe = "refer", be = "progress", ke = "accepted", Ve = "confirmed", We = "peerconnection", Ue = "failed", Ge = "muted", He = "unmuted", xe = "newDTMF", je = "newInfo", qe = "hold", Ye = "unhold", ze = "update", Be = "sdp", Ke = "icecandidate", $e = "getusermediafailed", Je = "peerconnection:createofferfailed", Qe = "peerconnection:createanswerfailed", Xe = "peerconnection:setlocaldescriptionfailed", Ze = "peerconnection:setremotedescriptionfailed", et = "presentation:start", tt = "presentation:started", rt = "presentation:end", nt = "presentation:ended", ot = "presentation:failed", st = [
18
+ const Y = "incomingCall", j = "declinedIncomingCall", q = "failedIncomingCall", z = "terminatedIncomingCall", P = "connecting", B = "connected", K = "disconnected", $ = "newRTCSession", J = "registered", Q = "unregistered", X = "registrationFailed", Z = "newMessage", ee = "sipEvent", te = "availableSecondRemoteStream", re = "notAvailableSecondRemoteStream", ne = "mustStopPresentation", oe = "shareState", se = "enterRoom", ie = "useLicense", ae = "peerconnection:confirmed", ce = "peerconnection:ontrack", de = "channels", Ee = "channels:notify", he = "ended:fromserver", me = "main-cam-control", ue = "admin-stop-main-cam", le = "admin-start-main-cam", pe = "admin-stop-mic", ge = "admin-start-mic", _e = "admin-force-sync-media-state", Te = "participant:added-to-list-moderators", Ie = "participant:removed-from-list-moderators", Se = "participant:move-request-to-stream", we = "participant:move-request-to-spectators", Ne = "participant:move-request-to-participants", fe = "participation:accepting-word-request", Ce = "participation:cancelling-word-request", Re = "webcast:started", Ae = "webcast:stopped", Me = "account:changed", Oe = "account:deleted", Pe = "conference:participant-token-issued", ve = "ended", De = "sending", ye = "reinvite", Le = "replaces", Fe = "refer", be = "progress", ke = "accepted", Ve = "confirmed", We = "peerconnection", Ue = "failed", Ge = "muted", He = "unmuted", xe = "newDTMF", Ye = "newInfo", je = "hold", qe = "unhold", ze = "update", Be = "sdp", Ke = "icecandidate", $e = "getusermediafailed", Je = "peerconnection:createofferfailed", Qe = "peerconnection:createanswerfailed", Xe = "peerconnection:setlocaldescriptionfailed", Ze = "peerconnection:setremotedescriptionfailed", et = "presentation:start", tt = "presentation:started", rt = "presentation:end", nt = "presentation:ended", ot = "presentation:failed", st = [
19
+ Y,
19
20
  j,
20
- q,
21
21
  z,
22
- Y,
22
+ q,
23
23
  fe,
24
24
  Ce,
25
25
  Se,
26
26
  Ee,
27
- ve,
28
- Ae,
27
+ Pe,
28
+ Me,
29
29
  Oe,
30
30
  Re,
31
- Me,
32
- _e,
31
+ Ae,
32
+ Te,
33
33
  Ie
34
- ], P = [
35
- v,
34
+ ], v = [
35
+ P,
36
36
  B,
37
37
  K,
38
38
  $,
@@ -57,12 +57,12 @@ const j = "incomingCall", q = "declinedIncomingCall", Y = "failedIncomingCall",
57
57
  ue,
58
58
  pe,
59
59
  ge,
60
- Te,
60
+ _e,
61
61
  we,
62
62
  Ne
63
63
  ], p = [
64
- Pe,
65
- v,
64
+ ve,
65
+ P,
66
66
  De,
67
67
  ye,
68
68
  Le,
@@ -75,9 +75,9 @@ const j = "incomingCall", q = "declinedIncomingCall", Y = "failedIncomingCall",
75
75
  Ge,
76
76
  He,
77
77
  xe,
78
+ Ye,
78
79
  je,
79
80
  qe,
80
- Ye,
81
81
  ze,
82
82
  Be,
83
83
  Ke,
@@ -92,7 +92,7 @@ const j = "incomingCall", q = "declinedIncomingCall", Y = "failedIncomingCall",
92
92
  nt,
93
93
  ot
94
94
  ];
95
- [...P, ...st];
95
+ [...v, ...st];
96
96
  [
97
97
  ...p,
98
98
  ...it
@@ -108,7 +108,7 @@ class at {
108
108
  eventHandlers: t,
109
109
  remoteIdentity: r
110
110
  }) {
111
- this.originator = e, this.events = new T(p), this.initEvents(t), this.remote_identity = r;
111
+ this.originator = e, this.events = new _(p), this.initEvents(t), this.remote_identity = r;
112
112
  }
113
113
  get contact() {
114
114
  throw new Error("Method not implemented.");
@@ -361,7 +361,7 @@ class dt {
361
361
  signalingState;
362
362
  events;
363
363
  constructor(e, t) {
364
- this.events = new T(ct), this.receivers = t.map((r) => ({ track: r }));
364
+ this.events = new _(ct), this.receivers = t.map((r) => ({ track: r }));
365
365
  }
366
366
  getRemoteStreams() {
367
367
  throw new Error("Method not implemented.");
@@ -629,11 +629,11 @@ class ut {
629
629
  setExtraContactParams() {
630
630
  }
631
631
  }
632
- const c = "PASSWORD_CORRECT", M = "PASSWORD_CORRECT_2", lt = "NAME_INCORRECT", d = 400, l = {
632
+ const c = "PASSWORD_CORRECT", A = "PASSWORD_CORRECT_2", lt = "NAME_INCORRECT", d = 400, l = {
633
633
  url: "wss://sipServerUrl/webrtc/wss/",
634
634
  sip_uri: "sip:sipServerUrl;transport=ws",
635
635
  via_transport: "WSS"
636
- }, A = {
636
+ }, M = {
637
637
  status_code: 200,
638
638
  reason_phrase: "OK"
639
639
  }, O = {
@@ -686,7 +686,7 @@ class s {
686
686
  isConnectedInner;
687
687
  configuration;
688
688
  constructor(e) {
689
- this.events = new T(P);
689
+ this.events = new _(v);
690
690
  const [t, r] = e.uri.split(":"), [n, a] = r.split("@"), u = {
691
691
  ...e,
692
692
  uri: new E(t, n, a)
@@ -738,9 +738,9 @@ class s {
738
738
  const { password: e, register: t, uri: r } = this.configuration;
739
739
  t === !0 && r.user.includes(lt) ? (this.isRegisteredInner = !1, this.isConnectedInner = !1, this.startedTimeout = setTimeout(() => {
740
740
  this.trigger("registrationFailed", { response: O, cause: N.causes.REJECTED });
741
- }, d)) : !this.isRegistered() && t === !0 && (e === c || e === M) ? (this.isRegisteredInner = !0, this.startedTimeout = setTimeout(() => {
742
- this.trigger("registered", { response: A });
743
- }, d)) : t === !0 && e !== c && e !== M && (this.isRegisteredInner = !1, this.isConnectedInner = !1, this.startedTimeout = setTimeout(() => {
741
+ }, d)) : !this.isRegistered() && t === !0 && (e === c || e === A) ? (this.isRegisteredInner = !0, this.startedTimeout = setTimeout(() => {
742
+ this.trigger("registered", { response: M });
743
+ }, d)) : t === !0 && e !== c && e !== A && (this.isRegisteredInner = !1, this.isConnectedInner = !1, this.startedTimeout = setTimeout(() => {
744
744
  this.trigger("registrationFailed", { response: O, cause: N.causes.REJECTED });
745
745
  }, d)), s.isAvailableTelephony ? (this.trigger("connected", { socket: l }), this.isConnectedInner = !0) : this.stop();
746
746
  }
@@ -750,7 +750,7 @@ class s {
750
750
  * @returns {undefined}
751
751
  */
752
752
  unregister() {
753
- this.isRegisteredInner = !1, this.isConnectedInner = !1, this.trigger("unregistered", { response: A });
753
+ this.isRegisteredInner = !1, this.isConnectedInner = !1, this.trigger("unregistered", { response: M });
754
754
  }
755
755
  isRegistered() {
756
756
  return this.isRegisteredInner === !0;
@@ -786,15 +786,15 @@ class gt extends L {
786
786
  super(), this.contentType = e, this.body = t;
787
787
  }
788
788
  }
789
- const g = "remote", Tt = (o, e) => {
790
- const t = new _(e), r = {
789
+ const g = "remote", _t = (o, e) => {
790
+ const t = new T(e), r = {
791
791
  originator: g,
792
792
  request: t,
793
793
  info: new gt("", "")
794
794
  };
795
795
  o.newInfo(r);
796
- }, _t = (o, e) => {
797
- const r = { event: "sipEvent", request: new _(e) };
796
+ }, Tt = (o, e) => {
797
+ const r = { event: "sipEvent", request: new T(e) };
798
798
  o.newSipEvent(r);
799
799
  }, It = (o, {
800
800
  incomingNumber: e = "1234",
@@ -803,7 +803,7 @@ const g = "remote", Tt = (o, e) => {
803
803
  }) => {
804
804
  const n = new i({ originator: g, eventHandlers: {} }), a = new b("sip", e, r);
805
805
  n.remote_identity = new F(a, t);
806
- const u = new _([]);
806
+ const u = new T([]);
807
807
  o.trigger("newRTCSession", {
808
808
  originator: g,
809
809
  session: n,
@@ -812,8 +812,8 @@ const g = "remote", Tt = (o, e) => {
812
812
  }, St = (o, e) => {
813
813
  e ? o.trigger("failed", e) : o.trigger("failed", o);
814
814
  }, D = {
815
- triggerNewInfo: Tt,
816
- triggerNewSipEvent: _t,
815
+ triggerNewInfo: _t,
816
+ triggerNewSipEvent: Tt,
817
817
  triggerIncomingSession: It,
818
818
  triggerFailIncomingSession: St,
819
819
  WebSocketInterface: pt,
@@ -822,11 +822,14 @@ const g = "remote", Tt = (o, e) => {
822
822
  INVITE: "INVITE"
823
823
  }
824
824
  }, I = "user", h = "displayName", S = "SIP_SERVER_URL", y = "SIP_WEB_SOCKET_SERVER_URL", wt = new D.WebSocketInterface(y), w = {
825
+ displayName: "DISPLAY_NAME",
825
826
  userAgent: "Chrome",
826
827
  sipServerUrl: S,
827
828
  sipWebSocketServerURL: y
828
829
  }, yt = {
829
- ...w
830
+ ...w,
831
+ displayName: "DISPLAY_NAME",
832
+ register: !1
830
833
  }, Nt = {
831
834
  ...w,
832
835
  user: I,
@@ -851,7 +854,7 @@ const g = "remote", Tt = (o, e) => {
851
854
  ...m,
852
855
  password: c,
853
856
  uri: new E("sip", I, S),
854
- display_name: "",
857
+ display_name: "DISPLAY_NAME",
855
858
  register: !0
856
859
  }, kt = {
857
860
  ...m,
@@ -865,7 +868,7 @@ const g = "remote", Tt = (o, e) => {
865
868
  register: !1
866
869
  }, Wt = {
867
870
  ...m,
868
- display_name: "",
871
+ display_name: "DISPLAY_NAME",
869
872
  register: !1
870
873
  }, ft = "10.10.10.10", Ut = [`X-Vinteo-Remote: ${ft}`], Gt = () => new x({
871
874
  JsSIP: D
@@ -875,7 +878,7 @@ export {
875
878
  D as JsSIP,
876
879
  lt as NAME_INCORRECT,
877
880
  c as PASSWORD_CORRECT,
878
- M as PASSWORD_CORRECT_2,
881
+ A as PASSWORD_CORRECT_2,
879
882
  S as SIP_SERVER_URL,
880
883
  y as SIP_WEB_SOCKET_SERVER_URL,
881
884
  Nt as dataForConnectionWithAuthorization,
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("events-constructor");const o=require("./@SipConnector-hbSoVizf.cjs"),V=require("@krivega/cancelable-promise"),W=require("repeated-calls"),j=require("ts-debounce"),K=require("ua-parser-js"),X=require("sequent-promises"),Y=require("stack-promises"),G=n=>n instanceof Object&&("originator"in n||"cause"in n),J=n=>{if(V.isCanceledError(n))return!0;if(!G(n))return!1;const{originator:e,cause:t}=n;return typeof t=="string"?t===o.ECallCause.REQUEST_TIMEOUT||t===o.ECallCause.REJECTED||e==="local"&&(t===o.ECallCause.CANCELED||t===o.ECallCause.BYE):!1},z=()=>globalThis.process?.versions?.electron!==void 0,x=()=>{const n=new K.UAParser,{name:e}=n.getBrowser(),t=z();return{isChrome:e==="Chrome"||t}},A=n=>{const{url:e,cause:t}=n;let r=e;return(t===o.ECallCause.BAD_MEDIA_DESCRIPTION||t===o.ECallCause.NOT_FOUND)&&(r=`${n.message.to.uri.user}@${n.message.to.uri.host}`),r};var B=(n=>(n.CONNECT_SERVER_FAILED="CONNECT_SERVER_FAILED",n.WRONG_USER_OR_PASSWORD="WRONG_USER_OR_PASSWORD",n.BAD_MEDIA_ERROR="BAD_MEDIA_ERROR",n.NOT_FOUND_ERROR="NOT_FOUND_ERROR",n.WS_CONNECTION_FAILED="WS_CONNECTION_FAILED",n.CONNECT_SERVER_FAILED_BY_LINK="CONNECT_SERVER_FAILED_BY_LINK",n))(B||{});const Q=new Error("Unknown error"),Z=(n=Q)=>{const{cause:e,socket:t}=n;let r="CONNECT_SERVER_FAILED";switch(e){case"Forbidden":{r="WRONG_USER_OR_PASSWORD";break}case o.ECallCause.BAD_MEDIA_DESCRIPTION:{r="BAD_MEDIA_ERROR";break}case o.ECallCause.NOT_FOUND:{r="NOT_FOUND_ERROR";break}default:t!==void 0&&t._ws?.readyState===3?r="WS_CONNECTION_FAILED":A(n)!==void 0&&A(n)!==""&&(r="CONNECT_SERVER_FAILED_BY_LINK")}return r},ee=n=>{let e="";try{e=JSON.stringify(n)}catch(t){o.logger("failed to stringify message",t)}return e},ne=new Error("Unknown error"),te=(n=ne)=>{const{code:e,cause:t,message:r}=n,a=A(n),s={code:"",cause:"",message:""};return typeof r=="object"&&r!==null?s.message=ee(r):r&&(s.message=String(r)),a!==void 0&&a!==""&&(s.link=a),e!==void 0&&e!==""&&(s.code=e),t!==void 0&&t!==""&&(s.cause=t),s},oe=Object.freeze(Object.defineProperty({__proto__:null,EErrorTypes:B,getLinkError:A,getTypeFromError:Z,getValuesFromError:te},Symbol.toStringTag,{value:"Module"})),re=({sessionId:n,remoteAddress:e,isMutedAudio:t,isMutedVideo:r,isRegistered:a,isPresentationCall:s})=>{const c=[],l=t?"0":"1",d=r?"0":"1";return c.push(`X-Vinteo-Mic-State: ${l}`,`X-Vinteo-MainCam-State: ${d}`),(a===!1||a===void 0)&&c.push("X-Vinteo-Purgatory-Call: yes"),n!==void 0&&n!==""&&c.push(`X-Vinteo-Session: ${n}`),s===!0&&c.push("X-Vinteo-Presentation-Call: yes"),e!==void 0&&e!==""&&c.push(`X-Vinteo-Remote: ${e}`),c},se="[@*!|]",ae="_",ce=n=>{let e=n;return e=e.replaceAll(new RegExp(se,"g"),ae),e},ie=({appName:n,appVersion:e,browserName:t,browserVersion:r})=>{const s=`${ce(n)} ${e}`;return`ChromeNew - ${t===void 0?s:`${t} ${r}, ${s}`}`},le=({isUnifiedSdpSemantic:n,appVersion:e,browserName:t,browserVersion:r,appName:a})=>n?ie({appVersion:e,browserName:t,browserVersion:r,appName:a}):"Chrome",$="purgatory",D=n=>n===$,ue=n=>e=>[...e].map(r=>async()=>n(r)),de=async({accumulatedKeys:n,sendKey:e,canRunTask:t})=>{const a=ue(e)(n);return X.sequentPromises(a,t)},ge=n=>t=>(o.logger("onStartMainCam"),n.on("api:admin-start-main-cam",t)),Ce=n=>t=>(o.logger("onStartMic"),n.on("api:admin-start-mic",t)),Se=n=>t=>(o.logger("onStopMainCam"),n.on("api:admin-stop-main-cam",t)),me=n=>t=>(o.logger("onStopMic"),n.on("api:admin-stop-mic",t)),fe=({sipConnector:n})=>{const e=(u,C)=>({isSyncForced:g})=>{if(g===!0){u();return}C()},t=ge(n),r=Se(n),a=Ce(n),s=me(n);let c,l,d,h;const v=({onStartMainCamForced:u,onStartMainCamNotForced:C,onStopMainCamForced:g,onStopMainCamNotForced:m,onStartMicForced:p,onStartMicNotForced:R,onStopMicForced:y,onStopMicNotForced:E})=>{const b=e(u,C);c=t(b);const O=e(g,m);l=r(O);const _=e(p,R);d=a(_);const S=e(y,E);h=s(S)},P=()=>{c?.(),l?.(),d?.(),h?.()};return{start:u=>{v(u)},stop:()=>{P()}}},he=Object.freeze(Object.defineProperty({__proto__:null,PURGATORY_CONFERENCE_NUMBER:$,createSyncMediaState:fe,createUaParser:x,error:oe,getExtraHeaders:re,getUserAgent:le,hasPurgatory:D,prepareMediaStream:o.prepareMediaStream,sendDtmfAccumulated:de,setEncodingsToSender:o.setEncodingsToSender,setParametersToSender:o.setParametersToSender},Symbol.toStringTag,{value:"Module"})),pe=()=>x().isChrome,Re=n=>{if(!V.isCanceledError(n)&&!W.hasCanceledError(n)&&!o.hasNotReadyForConnectionError(n))throw n;return{configuration:void 0,isSuccessful:!1}},Ee=({kind:n,readyState:e})=>n==="video"&&e==="live",U=(n,e,{onEnterPurgatory:t,onEnterConference:r})=>{D(n)?t&&t():r&&r({isSuccessProgressCall:e})},k=(n,e)=>{n(),e&&e()},L=(n,e,t)=>{throw n&&n(),e(),t},be=new Set(["on","once","onceRace","wait","off","sendDTMF","hangUp","declineToIncomingCall","sendChannels","checkTelephony","waitChannels","ping","startAutoConnect","stopAutoConnect","connection","isConfigured","isRegistered"]);class ve{on;once;onceRace;wait;off;sendDTMF;hangUp;declineToIncomingCall;sendChannels;checkTelephony;waitChannels;ping;startAutoConnect;stopAutoConnect;connection;isConfigured;isRegistered;sipConnector;constructor(e){return this.sipConnector=e,new Proxy(this,{get:(t,r,a)=>{if(typeof r=="string"&&be.has(r)&&r in this.sipConnector){const c=Reflect.get(this.sipConnector,r,this.sipConnector);return typeof c=="function"?c.bind(this.sipConnector):c}const s=Reflect.get(t,r,a);return typeof s=="function"?s.bind(t):s}})}connectToServer=async(e,t)=>this.sipConnector.connect(e,t).then(r=>(o.logger("connectToServer then"),{configuration:r,isSuccessful:!0})).catch(async r=>(o.logger("connectToServer catch: error",r),Re(r)));callToServer=async e=>{const{conference:t,mediaStream:r,extraHeaders:a,iceServers:s,contentHint:c,degradationPreference:l,sendEncodings:d,offerToReceiveAudio:h,offerToReceiveVideo:v,directionVideo:P,directionAudio:N,setRemoteStreams:T,onBeforeProgressCall:u,onSuccessProgressCall:C,onEnterPurgatory:g,onEnterConference:m,onFailProgressCall:p,onFinishProgressCall:R,onEndedCall:y,onAddedTransceiver:E}=e,b=this.resolveHandleReadyRemoteStreamsDebounced({onReadyRemoteStreams:T}),O=this.resolveHandleReadyRemoteStreams({onReadyRemoteStreams:()=>{b().catch(o.logger)}});o.logger("callToServer",e);const _=async()=>(o.logger("startCall"),this.sipConnector.call({mediaStream:r,extraHeaders:a,iceServers:s,contentHint:c,offerToReceiveAudio:h,offerToReceiveVideo:v,directionVideo:P,directionAudio:N,degradationPreference:l,onAddedTransceiver:E,sendEncodings:d,number:t,ontrack:O}));let S=!1,f;const M=(o.logger("subscribeEnterConference: onEnterConference",m),this.sipConnector.on("api:enterRoom",({room:i})=>{o.logger("enterRoom",{_room:i,isSuccessProgressCall:S}),f=i,(g??m)&&U(f,S,{onEnterPurgatory:g,onEnterConference:m})})),F=i=>(o.logger("onSuccess"),S=!0,b().catch(o.logger),C&&C({isPurgatory:D(f)}),this.sipConnector.onceRace(["call:ended","call:failed"],()=>{k(M,y)}),i),w=i=>(o.logger("onFail"),L(p,M,i)),I=()=>{o.logger("onFinish"),R&&R()};return o.logger("onBeforeProgressCall"),u&&u(t),_().then(F).catch(i=>w(i)).finally(I)};disconnectFromServer=async()=>this.sipConnector.disconnect().then(()=>(o.logger("disconnectFromServer: then"),{isSuccessful:!0})).catch(e=>(o.logger("disconnectFromServer: catch",e),{isSuccessful:!1}));answerToIncomingCall=async e=>{const{mediaStream:t,extraHeaders:r,iceServers:a,contentHint:s,degradationPreference:c,sendEncodings:l,offerToReceiveAudio:d,offerToReceiveVideo:h,directionVideo:v,directionAudio:P,setRemoteStreams:N,onBeforeProgressCall:T,onSuccessProgressCall:u,onEnterPurgatory:C,onEnterConference:g,onFailProgressCall:m,onFinishProgressCall:p,onEndedCall:R,onAddedTransceiver:y}=e,E=this.resolveHandleReadyRemoteStreamsDebounced({onReadyRemoteStreams:N}),b=this.resolveHandleReadyRemoteStreams({onReadyRemoteStreams:()=>{E().catch(o.logger)}});o.logger("answerToIncomingCall",e);const O=async()=>this.sipConnector.answerToIncomingCall({mediaStream:t,extraHeaders:r,iceServers:a,contentHint:s,offerToReceiveAudio:d,offerToReceiveVideo:h,directionVideo:v,directionAudio:P,degradationPreference:c,onAddedTransceiver:y,sendEncodings:l,ontrack:b}),_=()=>{const{remoteCallerData:i}=this.sipConnector;return i.incomingNumber};let S=!1,f;const M=(o.logger("subscribeEnterConference: onEnterConference",g),this.sipConnector.on("api:enterRoom",i=>{o.logger("enterRoom",{_room:i,isSuccessProgressCall:S}),f=i,(C??g)&&U(f,S,{onEnterPurgatory:C,onEnterConference:g})})),F=i=>(o.logger("onSuccess"),S=!0,E().catch(o.logger),u&&u({isPurgatory:D(f)}),this.sipConnector.onceRace(["call:ended","call:failed"],()=>{k(M,R)}),i),w=i=>(o.logger("onFail"),L(m,M,i)),I=()=>{o.logger("onFinish"),p&&p()};if(o.logger("onBeforeProgressCall"),T){const i=_();T(i)}return O().then(F).catch(i=>w(i)).finally(I)};updatePresentation=async({mediaStream:e,isP2P:t,contentHint:r,degradationPreference:a,sendEncodings:s,onAddedTransceiver:c})=>(o.logger("updatePresentation"),this.sipConnector.updatePresentation(e,{isP2P:t,contentHint:r,degradationPreference:a,onAddedTransceiver:c,sendEncodings:s}));startPresentation=async({mediaStream:e,isP2P:t,contentHint:r,degradationPreference:a,sendEncodings:s,callLimit:c,onAddedTransceiver:l})=>(o.logger("startPresentation"),this.sipConnector.startPresentation(e,{isP2P:t,contentHint:r,callLimit:c,degradationPreference:a,onAddedTransceiver:l,sendEncodings:s}));stopShareSipConnector=async({isP2P:e=!1}={})=>(o.logger("stopShareSipConnector"),this.sipConnector.stopPresentation({isP2P:e}).catch(t=>{o.logger(t)}));sendRefusalToTurnOnMic=async()=>{o.logger("sendRefusalToTurnOnMic"),await this.sipConnector.sendRefusalToTurnOnMic().catch(e=>{o.logger("sendRefusalToTurnOnMic: error",e)})};sendRefusalToTurnOnCam=async()=>{o.logger("sendRefusalToTurnOnCam"),await this.sipConnector.sendRefusalToTurnOnCam().catch(e=>{o.logger("sendRefusalToTurnOnCam: error",e)})};sendMediaState=async({isEnabledCam:e,isEnabledMic:t})=>{o.logger("sendMediaState"),await this.sipConnector.sendMediaState({cam:e,mic:t})};replaceMediaStream=async(e,{deleteExisting:t,addMissing:r,forceRenegotiation:a,contentHint:s,degradationPreference:c,sendEncodings:l,onAddedTransceiver:d})=>(o.logger("replaceMediaStream"),this.sipConnector.replaceMediaStream(e,{deleteExisting:t,addMissing:r,forceRenegotiation:a,contentHint:s,degradationPreference:c,onAddedTransceiver:d,sendEncodings:l}));askPermissionToEnableCam=async()=>{o.logger("askPermissionToEnableCam"),await this.sipConnector.askPermissionToEnableCam()};resolveHandleReadyRemoteStreamsDebounced=({onReadyRemoteStreams:e})=>j.debounce(()=>{const t=this.sipConnector.getRemoteStreams();o.logger("remoteStreams",t),t&&e(t)},200);resolveHandleReadyRemoteStreams=({onReadyRemoteStreams:e})=>({track:t})=>{Ee(t)&&e()};getRemoteStreams=()=>(o.logger("getRemoteStreams"),this.sipConnector.getRemoteStreams());onUseLicense=e=>(o.logger("onUseLicense"),this.sipConnector.on("api:useLicense",e));onMustStopPresentation=e=>(o.logger("onMustStopPresentation"),this.sipConnector.on("api:mustStopPresentation",e));onMoveToSpectators=e=>(o.logger("onMoveToSpectators"),this.sipConnector.on("api:participant:move-request-to-spectators",e));onMoveToParticipants=e=>(o.logger("onMoveToParticipants"),this.sipConnector.on("api:participant:move-request-to-participants",e));onStats=e=>(o.logger("onStats"),this.sipConnector.on("stats:collected",e));offStats=e=>{o.logger("offStats"),this.sipConnector.off("stats:collected",e)}}var H=(n=>(n.VP8="video/VP8",n.VP9="video/VP9",n.H264="video/H264",n.AV1="video/AV1",n.rtx="video/rtx",n.red="video/red",n.flexfec03="video/flexfec-03",n))(H||{});exports.ECallCause=o.ECallCause;exports.EStatsTypes=o.EStatsTypes;exports.EUseLicense=o.EUseLicense;exports.SipConnector=o.SipConnector;exports.StatsPeerConnection=o.StatsPeerConnection;exports.disableDebug=o.disableDebug;exports.enableDebug=o.enableDebug;exports.getCodecFromSender=o.getCodecFromSender;exports.hasCanceledStartPresentationError=o.hasCanceledStartPresentationError;Object.defineProperty(exports,"hasConnectionPromiseIsNotActualError",{enumerable:!0,get:()=>Y.isPromiseIsNotActualError});exports.EMimeTypesVideoCodecs=H;exports.SipConnectorFacade=ve;exports.hasAvailableStats=pe;exports.hasCanceledCallError=J;exports.tools=he;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("events-constructor");const o=require("./@SipConnector-1uu5lXCq.cjs"),V=require("@krivega/cancelable-promise"),W=require("repeated-calls"),j=require("ts-debounce"),K=require("ua-parser-js"),X=require("sequent-promises"),Y=require("stack-promises"),G=n=>n instanceof Object&&("originator"in n||"cause"in n),J=n=>{if(V.isCanceledError(n))return!0;if(!G(n))return!1;const{originator:e,cause:t}=n;return typeof t=="string"?t===o.ECallCause.REQUEST_TIMEOUT||t===o.ECallCause.REJECTED||e==="local"&&(t===o.ECallCause.CANCELED||t===o.ECallCause.BYE):!1},z=()=>globalThis.process?.versions?.electron!==void 0,x=()=>{const n=new K.UAParser,{name:e}=n.getBrowser(),t=z();return{isChrome:e==="Chrome"||t}},A=n=>{const{url:e,cause:t}=n;let r=e;return(t===o.ECallCause.BAD_MEDIA_DESCRIPTION||t===o.ECallCause.NOT_FOUND)&&(r=`${n.message.to.uri.user}@${n.message.to.uri.host}`),r};var B=(n=>(n.CONNECT_SERVER_FAILED="CONNECT_SERVER_FAILED",n.WRONG_USER_OR_PASSWORD="WRONG_USER_OR_PASSWORD",n.BAD_MEDIA_ERROR="BAD_MEDIA_ERROR",n.NOT_FOUND_ERROR="NOT_FOUND_ERROR",n.WS_CONNECTION_FAILED="WS_CONNECTION_FAILED",n.CONNECT_SERVER_FAILED_BY_LINK="CONNECT_SERVER_FAILED_BY_LINK",n))(B||{});const Q=new Error("Unknown error"),Z=(n=Q)=>{const{cause:e,socket:t}=n;let r="CONNECT_SERVER_FAILED";switch(e){case"Forbidden":{r="WRONG_USER_OR_PASSWORD";break}case o.ECallCause.BAD_MEDIA_DESCRIPTION:{r="BAD_MEDIA_ERROR";break}case o.ECallCause.NOT_FOUND:{r="NOT_FOUND_ERROR";break}default:t!==void 0&&t._ws?.readyState===3?r="WS_CONNECTION_FAILED":A(n)!==void 0&&A(n)!==""&&(r="CONNECT_SERVER_FAILED_BY_LINK")}return r},ee=n=>{let e="";try{e=JSON.stringify(n)}catch(t){o.logger("failed to stringify message",t)}return e},ne=new Error("Unknown error"),te=(n=ne)=>{const{code:e,cause:t,message:r}=n,a=A(n),s={code:"",cause:"",message:""};return typeof r=="object"&&r!==null?s.message=ee(r):r&&(s.message=String(r)),a!==void 0&&a!==""&&(s.link=a),e!==void 0&&e!==""&&(s.code=e),t!==void 0&&t!==""&&(s.cause=t),s},oe=Object.freeze(Object.defineProperty({__proto__:null,EErrorTypes:B,getLinkError:A,getTypeFromError:Z,getValuesFromError:te},Symbol.toStringTag,{value:"Module"})),re=({sessionId:n,remoteAddress:e,isMutedAudio:t,isMutedVideo:r,isRegistered:a,isPresentationCall:s})=>{const c=[],l=t?"0":"1",d=r?"0":"1";return c.push(`X-Vinteo-Mic-State: ${l}`,`X-Vinteo-MainCam-State: ${d}`),(a===!1||a===void 0)&&c.push("X-Vinteo-Purgatory-Call: yes"),n!==void 0&&n!==""&&c.push(`X-Vinteo-Session: ${n}`),s===!0&&c.push("X-Vinteo-Presentation-Call: yes"),e!==void 0&&e!==""&&c.push(`X-Vinteo-Remote: ${e}`),c},se="[@*!|]",ae="_",ce=n=>{let e=n;return e=e.replaceAll(new RegExp(se,"g"),ae),e},ie=({appName:n,appVersion:e,browserName:t,browserVersion:r})=>{const s=`${ce(n)} ${e}`;return`ChromeNew - ${t===void 0?s:`${t} ${r}, ${s}`}`},le=({isUnifiedSdpSemantic:n,appVersion:e,browserName:t,browserVersion:r,appName:a})=>n?ie({appVersion:e,browserName:t,browserVersion:r,appName:a}):"Chrome",$="purgatory",D=n=>n===$,ue=n=>e=>[...e].map(r=>async()=>n(r)),de=async({accumulatedKeys:n,sendKey:e,canRunTask:t})=>{const a=ue(e)(n);return X.sequentPromises(a,t)},ge=n=>t=>(o.logger("onStartMainCam"),n.on("api:admin-start-main-cam",t)),Ce=n=>t=>(o.logger("onStartMic"),n.on("api:admin-start-mic",t)),Se=n=>t=>(o.logger("onStopMainCam"),n.on("api:admin-stop-main-cam",t)),me=n=>t=>(o.logger("onStopMic"),n.on("api:admin-stop-mic",t)),fe=({sipConnector:n})=>{const e=(u,C)=>({isSyncForced:g})=>{if(g===!0){u();return}C()},t=ge(n),r=Se(n),a=Ce(n),s=me(n);let c,l,d,h;const v=({onStartMainCamForced:u,onStartMainCamNotForced:C,onStopMainCamForced:g,onStopMainCamNotForced:m,onStartMicForced:p,onStartMicNotForced:R,onStopMicForced:y,onStopMicNotForced:E})=>{const b=e(u,C);c=t(b);const O=e(g,m);l=r(O);const _=e(p,R);d=a(_);const S=e(y,E);h=s(S)},P=()=>{c?.(),l?.(),d?.(),h?.()};return{start:u=>{v(u)},stop:()=>{P()}}},he=Object.freeze(Object.defineProperty({__proto__:null,PURGATORY_CONFERENCE_NUMBER:$,createSyncMediaState:fe,createUaParser:x,error:oe,getExtraHeaders:re,getUserAgent:le,hasPurgatory:D,prepareMediaStream:o.prepareMediaStream,sendDtmfAccumulated:de,setEncodingsToSender:o.setEncodingsToSender,setParametersToSender:o.setParametersToSender},Symbol.toStringTag,{value:"Module"})),pe=()=>x().isChrome,Re=n=>{if(!V.isCanceledError(n)&&!W.hasCanceledError(n)&&!o.hasNotReadyForConnectionError(n))throw n;return{configuration:void 0,isSuccessful:!1}},Ee=({kind:n,readyState:e})=>n==="video"&&e==="live",U=(n,e,{onEnterPurgatory:t,onEnterConference:r})=>{D(n)?t&&t():r&&r({isSuccessProgressCall:e})},k=(n,e)=>{n(),e&&e()},L=(n,e,t)=>{throw n&&n(),e(),t},be=new Set(["on","once","onceRace","wait","off","sendDTMF","hangUp","declineToIncomingCall","sendChannels","checkTelephony","waitChannels","ping","startAutoConnect","stopAutoConnect","connection","isConfigured","isRegistered"]);class ve{on;once;onceRace;wait;off;sendDTMF;hangUp;declineToIncomingCall;sendChannels;checkTelephony;waitChannels;ping;startAutoConnect;stopAutoConnect;connection;isConfigured;isRegistered;sipConnector;constructor(e){return this.sipConnector=e,new Proxy(this,{get:(t,r,a)=>{if(typeof r=="string"&&be.has(r)&&r in this.sipConnector){const c=Reflect.get(this.sipConnector,r,this.sipConnector);return typeof c=="function"?c.bind(this.sipConnector):c}const s=Reflect.get(t,r,a);return typeof s=="function"?s.bind(t):s}})}connectToServer=async(e,t)=>this.sipConnector.connect(e,t).then(r=>(o.logger("connectToServer then"),{configuration:r,isSuccessful:!0})).catch(async r=>(o.logger("connectToServer catch: error",r),Re(r)));callToServer=async e=>{const{conference:t,mediaStream:r,extraHeaders:a,iceServers:s,contentHint:c,degradationPreference:l,sendEncodings:d,offerToReceiveAudio:h,offerToReceiveVideo:v,directionVideo:P,directionAudio:N,setRemoteStreams:T,onBeforeProgressCall:u,onSuccessProgressCall:C,onEnterPurgatory:g,onEnterConference:m,onFailProgressCall:p,onFinishProgressCall:R,onEndedCall:y,onAddedTransceiver:E}=e,b=this.resolveHandleReadyRemoteStreamsDebounced({onReadyRemoteStreams:T}),O=this.resolveHandleReadyRemoteStreams({onReadyRemoteStreams:()=>{b().catch(o.logger)}});o.logger("callToServer",e);const _=async()=>(o.logger("startCall"),this.sipConnector.call({mediaStream:r,extraHeaders:a,iceServers:s,contentHint:c,offerToReceiveAudio:h,offerToReceiveVideo:v,directionVideo:P,directionAudio:N,degradationPreference:l,onAddedTransceiver:E,sendEncodings:d,number:t,ontrack:O}));let S=!1,f;const M=(o.logger("subscribeEnterConference: onEnterConference",m),this.sipConnector.on("api:enterRoom",({room:i})=>{o.logger("enterRoom",{_room:i,isSuccessProgressCall:S}),f=i,(g??m)&&U(f,S,{onEnterPurgatory:g,onEnterConference:m})})),F=i=>(o.logger("onSuccess"),S=!0,b().catch(o.logger),C&&C({isPurgatory:D(f)}),this.sipConnector.onceRace(["call:ended","call:failed"],()=>{k(M,y)}),i),w=i=>(o.logger("onFail"),L(p,M,i)),I=()=>{o.logger("onFinish"),R&&R()};return o.logger("onBeforeProgressCall"),u&&u(t),_().then(F).catch(i=>w(i)).finally(I)};disconnectFromServer=async()=>this.sipConnector.disconnect().then(()=>(o.logger("disconnectFromServer: then"),{isSuccessful:!0})).catch(e=>(o.logger("disconnectFromServer: catch",e),{isSuccessful:!1}));answerToIncomingCall=async e=>{const{mediaStream:t,extraHeaders:r,iceServers:a,contentHint:s,degradationPreference:c,sendEncodings:l,offerToReceiveAudio:d,offerToReceiveVideo:h,directionVideo:v,directionAudio:P,setRemoteStreams:N,onBeforeProgressCall:T,onSuccessProgressCall:u,onEnterPurgatory:C,onEnterConference:g,onFailProgressCall:m,onFinishProgressCall:p,onEndedCall:R,onAddedTransceiver:y}=e,E=this.resolveHandleReadyRemoteStreamsDebounced({onReadyRemoteStreams:N}),b=this.resolveHandleReadyRemoteStreams({onReadyRemoteStreams:()=>{E().catch(o.logger)}});o.logger("answerToIncomingCall",e);const O=async()=>this.sipConnector.answerToIncomingCall({mediaStream:t,extraHeaders:r,iceServers:a,contentHint:s,offerToReceiveAudio:d,offerToReceiveVideo:h,directionVideo:v,directionAudio:P,degradationPreference:c,onAddedTransceiver:y,sendEncodings:l,ontrack:b}),_=()=>{const{remoteCallerData:i}=this.sipConnector;return i.incomingNumber};let S=!1,f;const M=(o.logger("subscribeEnterConference: onEnterConference",g),this.sipConnector.on("api:enterRoom",i=>{o.logger("enterRoom",{_room:i,isSuccessProgressCall:S}),f=i,(C??g)&&U(f,S,{onEnterPurgatory:C,onEnterConference:g})})),F=i=>(o.logger("onSuccess"),S=!0,E().catch(o.logger),u&&u({isPurgatory:D(f)}),this.sipConnector.onceRace(["call:ended","call:failed"],()=>{k(M,R)}),i),w=i=>(o.logger("onFail"),L(m,M,i)),I=()=>{o.logger("onFinish"),p&&p()};if(o.logger("onBeforeProgressCall"),T){const i=_();T(i)}return O().then(F).catch(i=>w(i)).finally(I)};updatePresentation=async({mediaStream:e,isP2P:t,contentHint:r,degradationPreference:a,sendEncodings:s,onAddedTransceiver:c})=>(o.logger("updatePresentation"),this.sipConnector.updatePresentation(e,{isP2P:t,contentHint:r,degradationPreference:a,onAddedTransceiver:c,sendEncodings:s}));startPresentation=async({mediaStream:e,isP2P:t,contentHint:r,degradationPreference:a,sendEncodings:s,callLimit:c,onAddedTransceiver:l})=>(o.logger("startPresentation"),this.sipConnector.startPresentation(e,{isP2P:t,contentHint:r,callLimit:c,degradationPreference:a,onAddedTransceiver:l,sendEncodings:s}));stopShareSipConnector=async({isP2P:e=!1}={})=>(o.logger("stopShareSipConnector"),this.sipConnector.stopPresentation({isP2P:e}).catch(t=>{o.logger(t)}));sendRefusalToTurnOnMic=async()=>{o.logger("sendRefusalToTurnOnMic"),await this.sipConnector.sendRefusalToTurnOnMic().catch(e=>{o.logger("sendRefusalToTurnOnMic: error",e)})};sendRefusalToTurnOnCam=async()=>{o.logger("sendRefusalToTurnOnCam"),await this.sipConnector.sendRefusalToTurnOnCam().catch(e=>{o.logger("sendRefusalToTurnOnCam: error",e)})};sendMediaState=async({isEnabledCam:e,isEnabledMic:t})=>{o.logger("sendMediaState"),await this.sipConnector.sendMediaState({cam:e,mic:t})};replaceMediaStream=async(e,{deleteExisting:t,addMissing:r,forceRenegotiation:a,contentHint:s,degradationPreference:c,sendEncodings:l,onAddedTransceiver:d})=>(o.logger("replaceMediaStream"),this.sipConnector.replaceMediaStream(e,{deleteExisting:t,addMissing:r,forceRenegotiation:a,contentHint:s,degradationPreference:c,onAddedTransceiver:d,sendEncodings:l}));askPermissionToEnableCam=async()=>{o.logger("askPermissionToEnableCam"),await this.sipConnector.askPermissionToEnableCam()};resolveHandleReadyRemoteStreamsDebounced=({onReadyRemoteStreams:e})=>j.debounce(()=>{const t=this.sipConnector.getRemoteStreams();o.logger("remoteStreams",t),t&&e(t)},200);resolveHandleReadyRemoteStreams=({onReadyRemoteStreams:e})=>({track:t})=>{Ee(t)&&e()};getRemoteStreams=()=>(o.logger("getRemoteStreams"),this.sipConnector.getRemoteStreams());onUseLicense=e=>(o.logger("onUseLicense"),this.sipConnector.on("api:useLicense",e));onMustStopPresentation=e=>(o.logger("onMustStopPresentation"),this.sipConnector.on("api:mustStopPresentation",e));onMoveToSpectators=e=>(o.logger("onMoveToSpectators"),this.sipConnector.on("api:participant:move-request-to-spectators",e));onMoveToParticipants=e=>(o.logger("onMoveToParticipants"),this.sipConnector.on("api:participant:move-request-to-participants",e));onStats=e=>(o.logger("onStats"),this.sipConnector.on("stats:collected",e));offStats=e=>{o.logger("offStats"),this.sipConnector.off("stats:collected",e)}}var H=(n=>(n.VP8="video/VP8",n.VP9="video/VP9",n.H264="video/H264",n.AV1="video/AV1",n.rtx="video/rtx",n.red="video/red",n.flexfec03="video/flexfec-03",n))(H||{});exports.ECallCause=o.ECallCause;exports.EStatsTypes=o.EStatsTypes;exports.EUseLicense=o.EUseLicense;exports.SipConnector=o.SipConnector;exports.StatsPeerConnection=o.StatsPeerConnection;exports.disableDebug=o.disableDebug;exports.enableDebug=o.enableDebug;exports.getCodecFromSender=o.getCodecFromSender;exports.hasCanceledStartPresentationError=o.hasCanceledStartPresentationError;Object.defineProperty(exports,"hasConnectionPromiseIsNotActualError",{enumerable:!0,get:()=>Y.isPromiseIsNotActualError});exports.EMimeTypesVideoCodecs=H;exports.SipConnectorFacade=ve;exports.hasAvailableStats=pe;exports.hasCanceledCallError=J;exports.tools=he;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import "events-constructor";
2
- import { E as C, l as r, p as j, s as K, a as X, h as Y } from "./@SipConnector-DIeMny8m.js";
3
- import { f as ke, b as xe, S as Le, g as Ve, d as Be, e as $e, i as He, c as We } from "./@SipConnector-DIeMny8m.js";
2
+ import { E as C, l as r, p as j, s as K, a as X, h as Y } from "./@SipConnector-JzZVT23M.js";
3
+ import { f as ke, b as xe, S as Le, g as Ve, d as Be, e as $e, i as He, c as We } from "./@SipConnector-JzZVT23M.js";
4
4
  import { isCanceledError as V } from "@krivega/cancelable-promise";
5
5
  import { hasCanceledError as G } from "repeated-calls";
6
6
  import { debounce as q } from "ts-debounce";
@@ -8,6 +8,7 @@ export declare const dataForConnectionWithAuthorization: {
8
8
  sipServerUrl: string;
9
9
  sipWebSocketServerURL: string;
10
10
  userAgent: string;
11
+ displayName: string;
11
12
  };
12
13
  export declare const dataForConnectionWithAuthorizationWithDisplayName: {
13
14
  displayName: string;
@@ -57,6 +58,7 @@ export declare const dataForConnectionWithAuthorizationIncorrectUser: {
57
58
  sipServerUrl: string;
58
59
  sipWebSocketServerURL: string;
59
60
  userAgent: string;
61
+ displayName: string;
60
62
  };
61
63
  export declare const dataForConnectionWithAuthorizationIncorrectPassword: {
62
64
  password: string;
@@ -66,6 +68,7 @@ export declare const dataForConnectionWithAuthorizationIncorrectPassword: {
66
68
  sipServerUrl: string;
67
69
  sipWebSocketServerURL: string;
68
70
  userAgent: string;
71
+ displayName: string;
69
72
  };
70
73
  export declare const withNameChanged: {
71
74
  nameChanged: boolean;
@@ -76,6 +79,7 @@ export declare const withNameChanged: {
76
79
  sipServerUrl: string;
77
80
  sipWebSocketServerURL: string;
78
81
  userAgent: string;
82
+ displayName: string;
79
83
  };
80
84
  export declare const dataForConnectionWithAuthorizationPasswordChanged: {
81
85
  password: string;
@@ -86,6 +90,7 @@ export declare const dataForConnectionWithAuthorizationPasswordChanged: {
86
90
  sipServerUrl: string;
87
91
  sipWebSocketServerURL: string;
88
92
  userAgent: string;
93
+ displayName: string;
89
94
  };
90
95
  export declare const uaConfigurationWithAuthorization: {
91
96
  password: string;
@@ -2,7 +2,7 @@ import { SipConnector } from '../../SipConnector';
2
2
  declare const resolveInitUaPromised: (sipConnector: SipConnector) => (state: {
3
3
  remoteAddress: string | undefined;
4
4
  sipServerUrl: string;
5
- displayName: string | undefined;
5
+ displayName: string;
6
6
  sipWebSocketServerURL: string;
7
7
  user: string;
8
8
  password: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sip-connector",
3
- "version": "19.4.0",
3
+ "version": "19.6.0",
4
4
  "description": "Module for connect to Vinteo server",
5
5
  "keywords": [
6
6
  "webrtc",