sip-connector 19.1.0 → 19.2.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.
@@ -1,4 +1,4 @@
1
1
  import { Events } from 'events-constructor';
2
- export declare const EVENT_NAMES: readonly ("auto-connect:before-attempt" | "auto-connect:succeeded-attempt" | "auto-connect:failed-attempt" | "auto-connect:cancelled-attempt" | "auto-connect:changed-attempt-status" | "connection:connecting" | "connection:connected" | "connection:disconnected" | "connection:disconnecting" | "connection:newRTCSession" | "connection:registered" | "connection:unregistered" | "connection:registrationFailed" | "connection:newMessage" | "connection:sipEvent" | "connection:connect-started" | "connection:connect-succeeded" | "connection:connect-failed" | "call:newDTMF" | "call:peerconnection" | "call:connecting" | "call:sending" | "call:progress" | "call:accepted" | "call:confirmed" | "call:ended" | "call:failed" | "call:newInfo" | "call:reinvite" | "call:update" | "call:refer" | "call:replaces" | "call:sdp" | "call:icecandidate" | "call:getusermediafailed" | "call:peerconnection:createofferfailed" | "call:peerconnection:createanswerfailed" | "call:peerconnection:setlocaldescriptionfailed" | "call:peerconnection:setremotedescriptionfailed" | "call:presentation:start" | "call:presentation:started" | "call:presentation:end" | "call:presentation:ended" | "call:presentation:failed" | "call:peerconnection:confirmed" | "call:peerconnection:ontrack" | "call:ended:fromserver" | "call:call-status-changed" | "api:channels:notify" | "api:participant:added-to-list-moderators" | "api:participant:removed-from-list-moderators" | "api:participant:move-request-to-stream" | "api:participant:move-request-to-spectators" | "api:participant:move-request-to-participants" | "api:participation:accepting-word-request" | "api:participation:cancelling-word-request" | "api:webcast:started" | "api:webcast:stopped" | "api:account:changed" | "api:account:deleted" | "api:conference:participant-token-issued" | "api:channels" | "api:enterRoom" | "api:shareState" | "api:main-cam-control" | "api:useLicense" | "api:admin-start-main-cam" | "api:admin-stop-main-cam" | "api:admin-start-mic" | "api:admin-stop-mic" | "api:admin-force-sync-media-state" | "api:availableSecondRemoteStream" | "api:notAvailableSecondRemoteStream" | "api:mustStopPresentation" | "api:newDTMF" | "api:restart" | "incoming-call:incomingCall" | "incoming-call:declinedIncomingCall" | "incoming-call:terminatedIncomingCall" | "incoming-call:failedIncomingCall" | "presentation:presentation:start" | "presentation:presentation:started" | "presentation:presentation:end" | "presentation:presentation:ended" | "presentation:presentation:failed" | "stats:collected" | "video-balancer:balancing-scheduled" | "video-balancer:balancing-started" | "video-balancer:balancing-stopped" | "video-balancer:parameters-updated")[];
2
+ export declare const EVENT_NAMES: readonly ("auto-connect:before-attempt" | "auto-connect:succeeded-attempt" | "auto-connect:failed-attempt" | "auto-connect:cancelled-attempt" | "auto-connect:changed-attempt-status" | "connection:connecting" | "connection:connected" | "connection:disconnected" | "connection:disconnecting" | "connection:newRTCSession" | "connection:registered" | "connection:unregistered" | "connection:registrationFailed" | "connection:newMessage" | "connection:sipEvent" | "connection:connect-started" | "connection:connect-succeeded" | "connection:connect-failed" | "connection:connect-parameters-resolve-failed" | "call:newDTMF" | "call:peerconnection" | "call:connecting" | "call:sending" | "call:progress" | "call:accepted" | "call:confirmed" | "call:ended" | "call:failed" | "call:newInfo" | "call:reinvite" | "call:update" | "call:refer" | "call:replaces" | "call:sdp" | "call:icecandidate" | "call:getusermediafailed" | "call:peerconnection:createofferfailed" | "call:peerconnection:createanswerfailed" | "call:peerconnection:setlocaldescriptionfailed" | "call:peerconnection:setremotedescriptionfailed" | "call:presentation:start" | "call:presentation:started" | "call:presentation:end" | "call:presentation:ended" | "call:presentation:failed" | "call:peerconnection:confirmed" | "call:peerconnection:ontrack" | "call:ended:fromserver" | "call:call-status-changed" | "api:channels:notify" | "api:participant:added-to-list-moderators" | "api:participant:removed-from-list-moderators" | "api:participant:move-request-to-stream" | "api:participant:move-request-to-spectators" | "api:participant:move-request-to-participants" | "api:participation:accepting-word-request" | "api:participation:cancelling-word-request" | "api:webcast:started" | "api:webcast:stopped" | "api:account:changed" | "api:account:deleted" | "api:conference:participant-token-issued" | "api:channels" | "api:enterRoom" | "api:shareState" | "api:main-cam-control" | "api:useLicense" | "api:admin-start-main-cam" | "api:admin-stop-main-cam" | "api:admin-start-mic" | "api:admin-stop-mic" | "api:admin-force-sync-media-state" | "api:availableSecondRemoteStream" | "api:notAvailableSecondRemoteStream" | "api:mustStopPresentation" | "api:newDTMF" | "api:restart" | "incoming-call:incomingCall" | "incoming-call:declinedIncomingCall" | "incoming-call:terminatedIncomingCall" | "incoming-call:failedIncomingCall" | "presentation:presentation:start" | "presentation:presentation:started" | "presentation:presentation:end" | "presentation:presentation:ended" | "presentation:presentation:failed" | "stats:collected" | "video-balancer:balancing-scheduled" | "video-balancer:balancing-started" | "video-balancer:balancing-stopped" | "video-balancer:parameters-updated")[];
3
3
  export type TEvent = (typeof EVENT_NAMES)[number];
4
4
  export type TEvents = Events<typeof EVENT_NAMES>;
@@ -1,4 +1,4 @@
1
- import { NameAddrHeader, IncomingInfoEvent } from '@krivega/jssip';
1
+ import { NameAddrHeader, SessionStatus, IncomingInfoEvent } from '@krivega/jssip';
2
2
  import { default as BaseSession, TEventHandlers } from './BaseSession.mock';
3
3
  export declare const FAILED_CONFERENCE_NUMBER = "777";
4
4
  export declare const createDeclineStartPresentationError: () => Error;
@@ -22,6 +22,8 @@ declare class RTCSessionMock extends BaseSession {
22
22
  mediaStream: MediaStream;
23
23
  }], any>;
24
24
  replaceMediaStream: jest.Mock<Promise<void>, [_mediaStream: MediaStream], any>;
25
+ _isReadyToReOffer: jest.Mock<boolean, [], any>;
26
+ addTransceiver: jest.Mock<RTCRtpTransceiver, [_trackOrKind: string | MediaStreamTrack, _init?: RTCRtpTransceiverInit | undefined], any>;
25
27
  restartIce: jest.Mock<Promise<boolean>, [_options?: {
26
28
  useUpdate?: boolean;
27
29
  extraHeaders?: string[];
@@ -42,6 +44,7 @@ declare class RTCSessionMock extends BaseSession {
42
44
  remoteIdentity?: NameAddrHeader;
43
45
  delayStartPresentation?: number;
44
46
  });
47
+ static get C(): typeof SessionStatus;
45
48
  static setPresentationError(presentationError: Error): void;
46
49
  static resetPresentationError(): void;
47
50
  static setStartPresentationError(startPresentationError: Error, { count }?: {
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-CQnPH_xV.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=>{});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 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-4vrb2RbW.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;
package/dist/doMock.js CHANGED
@@ -2,10 +2,10 @@ import { EventEmitter as L } from "node:events";
2
2
  import F from "@krivega/jssip/lib/NameAddrHeader";
3
3
  import b from "@krivega/jssip/lib/URI";
4
4
  import { IncomingRequest as k } from "@krivega/jssip/lib/SIPMessage";
5
- import { NameAddrHeader as V, URI as E, C as N } from "@krivega/jssip";
6
- import { createAudioMediaStreamTrackMock as W, createVideoMediaStreamTrackMock as U } from "webrtc-mock";
5
+ import { NameAddrHeader as V, URI as E, SessionStatus as W, C as N } from "@krivega/jssip";
6
+ import { createAudioMediaStreamTrackMock as U, createVideoMediaStreamTrackMock as G } from "webrtc-mock";
7
7
  import { Events as T } from "events-constructor";
8
- import { O as G, S as H } from "./@SipConnector-BOCUgqab.js";
8
+ import { O as H, S as x } from "./@SipConnector-BRWV-qDT.js";
9
9
  class _ extends k {
10
10
  headers;
11
11
  constructor(e) {
@@ -15,34 +15,33 @@ class _ extends k {
15
15
  return this.headers.get(e) ?? "";
16
16
  }
17
17
  }
18
- const x = "incomingCall", q = "declinedIncomingCall", Y = "failedIncomingCall", j = "terminatedIncomingCall", P = "connecting", z = "connected", B = "disconnected", $ = "newRTCSession", J = "registered", K = "unregistered", Q = "registrationFailed", X = "newMessage", Z = "sipEvent", ee = "availableSecondRemoteStream", te = "notAvailableSecondRemoteStream", re = "mustStopPresentation", ne = "shareState", oe = "enterRoom", se = "useLicense", ie = "peerconnection:confirmed", ae = "peerconnection:ontrack", ce = "channels", de = "channels:notify", Ee = "ended:fromserver", he = "main-cam-control", me = "admin-stop-main-cam", ue = "admin-start-main-cam", le = "admin-stop-mic", pe = "admin-start-mic", ge = "admin-force-sync-media-state", Te = "participant:added-to-list-moderators", _e = "participant:removed-from-list-moderators", Ie = "participant:move-request-to-stream", we = "participant:move-request-to-spectators", Se = "participant:move-request-to-participants", Ne = "participation:accepting-word-request", fe = "participation:cancelling-word-request", Ce = "webcast:started", Re = "webcast:stopped", Me = "account:changed", Ae = "account:deleted", Oe = "conference:participant-token-issued", Pe = "ended", ve = "sending", De = "reinvite", ye = "replaces", Le = "refer", Fe = "progress", be = "accepted", ke = "confirmed", Ve = "peerconnection", We = "failed", Ue = "muted", Ge = "unmuted", He = "newDTMF", xe = "newInfo", qe = "hold", Ye = "unhold", je = "update", ze = "sdp", Be = "icecandidate", $e = "getusermediafailed", Je = "peerconnection:createofferfailed", Ke = "peerconnection:createanswerfailed", Qe = "peerconnection:setlocaldescriptionfailed", Xe = "peerconnection:setremotedescriptionfailed", Ze = "presentation:start", et = "presentation:started", tt = "presentation:end", rt = "presentation:ended", nt = "presentation:failed", ot = [
19
- x,
20
- q,
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 = [
21
19
  j,
20
+ q,
21
+ z,
22
22
  Y,
23
- Ne,
24
23
  fe,
25
- Ie,
26
- de,
27
- Oe,
28
- Me,
29
- Ae,
30
24
  Ce,
25
+ Se,
26
+ Ee,
27
+ ve,
28
+ Ae,
29
+ Oe,
31
30
  Re,
32
- Te,
33
- _e
34
- ], v = [
35
- P,
36
- z,
31
+ Me,
32
+ _e,
33
+ Ie
34
+ ], P = [
35
+ v,
37
36
  B,
37
+ K,
38
38
  $,
39
39
  J,
40
- K,
41
40
  Q,
42
41
  X,
43
- Z
44
- ], st = [
45
- ee,
42
+ Z,
43
+ ee
44
+ ], it = [
46
45
  te,
47
46
  re,
48
47
  ne,
@@ -51,19 +50,19 @@ const x = "incomingCall", q = "declinedIncomingCall", Y = "failedIncomingCall",
51
50
  ie,
52
51
  ae,
53
52
  ce,
54
- Ee,
53
+ de,
55
54
  he,
56
- ue,
57
55
  me,
58
56
  le,
57
+ ue,
59
58
  pe,
60
59
  ge,
60
+ Te,
61
61
  we,
62
- Se
62
+ Ne
63
63
  ], p = [
64
64
  Pe,
65
- P,
66
- ve,
65
+ v,
67
66
  De,
68
67
  ye,
69
68
  Le,
@@ -76,28 +75,29 @@ const x = "incomingCall", q = "declinedIncomingCall", Y = "failedIncomingCall",
76
75
  Ge,
77
76
  He,
78
77
  xe,
78
+ je,
79
79
  qe,
80
80
  Ye,
81
- je,
82
81
  ze,
83
82
  Be,
83
+ Ke,
84
84
  $e,
85
85
  Je,
86
- Ke,
87
86
  Qe,
88
87
  Xe,
89
88
  Ze,
90
89
  et,
91
90
  tt,
92
91
  rt,
93
- nt
92
+ nt,
93
+ ot
94
94
  ];
95
- [...v, ...ot];
95
+ [...P, ...st];
96
96
  [
97
97
  ...p,
98
- ...st
98
+ ...it
99
99
  ];
100
- class it {
100
+ class at {
101
101
  originator;
102
102
  connection;
103
103
  events;
@@ -329,8 +329,8 @@ class C {
329
329
  stop() {
330
330
  }
331
331
  }
332
- const at = ["track"];
333
- class ct {
332
+ const ct = ["track"];
333
+ class dt {
334
334
  senders = [];
335
335
  receivers = [];
336
336
  canTrickleIceCandidates;
@@ -361,7 +361,7 @@ class ct {
361
361
  signalingState;
362
362
  events;
363
363
  constructor(e, t) {
364
- this.events = new T(at), this.receivers = t.map((r) => ({ track: r }));
364
+ this.events = new T(ct), this.receivers = t.map((r) => ({ track: r }));
365
365
  }
366
366
  getRemoteStreams() {
367
367
  throw new Error("Method not implemented.");
@@ -432,14 +432,14 @@ class ct {
432
432
  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;
433
433
  };
434
434
  }
435
- function dt(o) {
435
+ function Et(o) {
436
436
  const e = o.match(/(purgatory)|[\d.]+/g);
437
437
  if (!e)
438
438
  throw new Error("wrong sip url");
439
439
  return e[0];
440
440
  }
441
- const R = 400, Et = "777", ht = (o) => o.getVideoTracks().length > 0;
442
- class i extends it {
441
+ const R = 400, ht = "777", mt = (o) => o.getVideoTracks().length > 0;
442
+ class i extends at {
443
443
  static presentationError;
444
444
  static startPresentationError;
445
445
  static countStartPresentationError = Number.POSITIVE_INFINITY;
@@ -468,6 +468,10 @@ class i extends it {
468
468
  });
469
469
  replaceMediaStream = jest.fn(async (e) => {
470
470
  });
471
+ _isReadyToReOffer = jest.fn(() => !0);
472
+ addTransceiver = jest.fn(
473
+ (e, t) => ({})
474
+ );
471
475
  restartIce = jest.fn(
472
476
  async (e) => !0
473
477
  );
@@ -489,6 +493,9 @@ class i extends it {
489
493
  }) {
490
494
  super({ originator: t, eventHandlers: e, remoteIdentity: r }), this.delayStartPresentation = n;
491
495
  }
496
+ static get C() {
497
+ return W;
498
+ }
492
499
  static setPresentationError(e) {
493
500
  this.presentationError = e;
494
501
  }
@@ -523,25 +530,25 @@ class i extends it {
523
530
  return e ? (this.createPeerconnection(e), !0) : !1;
524
531
  }
525
532
  createPeerconnection(e) {
526
- const t = W();
533
+ const t = U();
527
534
  t.id = "mainaudio1";
528
535
  const r = [t];
529
- if (ht(e)) {
530
- const a = U();
536
+ if (mt(e)) {
537
+ const a = G();
531
538
  a.id = "mainvideo1", r.push(a);
532
539
  }
533
- this.connection = new ct(void 0, r), this.addStream(e), this.trigger("peerconnection", { peerconnection: this.connection });
540
+ this.connection = new dt(void 0, r), this.addStream(e), this.trigger("peerconnection", { peerconnection: this.connection });
534
541
  }
535
542
  connect(e, { mediaStream: t } = {}) {
536
- const r = dt(e);
543
+ const r = Et(e);
537
544
  return this.initPeerconnection(t), this.timeoutConnect = setTimeout(() => {
538
- e.includes(Et) ? this.trigger("failed", {
545
+ e.includes(ht) ? this.trigger("failed", {
539
546
  originator: "remote",
540
547
  message: "IncomingResponse",
541
548
  cause: "Rejected"
542
549
  }) : (this.trigger("connecting"), this.timeoutNewInfo = setTimeout(() => {
543
550
  this.newInfo({
544
- originator: G.REMOTE,
551
+ originator: H.REMOTE,
545
552
  // @ts-expect-error
546
553
  request: {
547
554
  getHeader: (n) => n === "content-type" ? "application/vinteo.webrtc.roomname" : n === "x-webrtc-enter-room" ? r : n === "x-webrtc-participant-name" ? "Test Caller 1" : ""
@@ -575,14 +582,11 @@ class i extends it {
575
582
  e(r);
576
583
  return t;
577
584
  }
578
- /* eslint-disable no-param-reassign */
579
585
  toggleMuteAudio(e) {
580
586
  this.forEachSenders(({ track: t }) => {
581
587
  t?.kind === "audio" && (t.enabled = !e);
582
588
  });
583
589
  }
584
- /* eslint-enable no-param-reassign */
585
- /* eslint-disable no-param-reassign */
586
590
  toggleMuteVideo(e) {
587
591
  this.forEachSenders(({ track: t }) => {
588
592
  t?.kind === "video" && (t.enabled = !e);
@@ -615,9 +619,8 @@ class i extends it {
615
619
  clear() {
616
620
  clearTimeout(this.timeoutStartPresentation), clearTimeout(this.timeoutConnect), clearTimeout(this.timeoutNewInfo), clearTimeout(this.timeoutAccepted), clearTimeout(this.timeoutConfirmed);
617
621
  }
618
- /* eslint-enable no-param-reassign */
619
622
  }
620
- class mt {
623
+ class ut {
621
624
  extraHeaders = [];
622
625
  setExtraHeaders(e) {
623
626
  this.extraHeaders = e;
@@ -626,7 +629,7 @@ class mt {
626
629
  setExtraContactParams() {
627
630
  }
628
631
  }
629
- const c = "PASSWORD_CORRECT", M = "PASSWORD_CORRECT_2", ut = "NAME_INCORRECT", d = 400, l = {
632
+ const c = "PASSWORD_CORRECT", M = "PASSWORD_CORRECT_2", lt = "NAME_INCORRECT", d = 400, l = {
630
633
  url: "wss://sipServerUrl/webrtc/wss/",
631
634
  sip_uri: "sip:sipServerUrl;transport=ws",
632
635
  via_transport: "WSS"
@@ -683,12 +686,12 @@ class s {
683
686
  isConnectedInner;
684
687
  configuration;
685
688
  constructor(e) {
686
- this.events = new T(v);
689
+ this.events = new T(P);
687
690
  const [t, r] = e.uri.split(":"), [n, a] = r.split("@"), u = {
688
691
  ...e,
689
692
  uri: new E(t, n, a)
690
693
  };
691
- this.configuration = u, this.registratorInner = new mt();
694
+ this.configuration = u, this.registratorInner = new ut();
692
695
  }
693
696
  static setStartError(e, { count: t = Number.POSITIVE_INFINITY } = {}) {
694
697
  s.startError = e, s.countStartError = t;
@@ -733,7 +736,7 @@ class s {
733
736
  register() {
734
737
  this.startedTimeout && clearTimeout(this.startedTimeout);
735
738
  const { password: e, register: t, uri: r } = this.configuration;
736
- t === !0 && r.user.includes(ut) ? (this.isRegisteredInner = !1, this.isConnectedInner = !1, this.startedTimeout = setTimeout(() => {
739
+ t === !0 && r.user.includes(lt) ? (this.isRegisteredInner = !1, this.isConnectedInner = !1, this.startedTimeout = setTimeout(() => {
737
740
  this.trigger("registrationFailed", { response: O, cause: N.causes.REJECTED });
738
741
  }, d)) : !this.isRegistered() && t === !0 && (e === c || e === M) ? (this.isRegisteredInner = !0, this.startedTimeout = setTimeout(() => {
739
742
  this.trigger("registered", { response: A });
@@ -770,30 +773,30 @@ class s {
770
773
  return this.registratorInner;
771
774
  }
772
775
  }
773
- class lt {
776
+ class pt {
774
777
  url;
775
778
  constructor(e) {
776
779
  this.url = e;
777
780
  }
778
781
  }
779
- class pt extends L {
782
+ class gt extends L {
780
783
  contentType;
781
784
  body;
782
785
  constructor(e, t) {
783
786
  super(), this.contentType = e, this.body = t;
784
787
  }
785
788
  }
786
- const g = "remote", gt = (o, e) => {
789
+ const g = "remote", Tt = (o, e) => {
787
790
  const t = new _(e), r = {
788
791
  originator: g,
789
792
  request: t,
790
- info: new pt("", "")
793
+ info: new gt("", "")
791
794
  };
792
795
  o.newInfo(r);
793
- }, Tt = (o, e) => {
796
+ }, _t = (o, e) => {
794
797
  const r = { event: "sipEvent", request: new _(e) };
795
798
  o.newSipEvent(r);
796
- }, _t = (o, {
799
+ }, It = (o, {
797
800
  incomingNumber: e = "1234",
798
801
  displayName: t,
799
802
  host: r
@@ -806,34 +809,34 @@ const g = "remote", gt = (o, e) => {
806
809
  session: n,
807
810
  request: u
808
811
  });
809
- }, It = (o, e) => {
812
+ }, St = (o, e) => {
810
813
  e ? o.trigger("failed", e) : o.trigger("failed", o);
811
814
  }, D = {
812
- triggerNewInfo: gt,
813
- triggerNewSipEvent: Tt,
814
- triggerIncomingSession: _t,
815
- triggerFailIncomingSession: It,
816
- WebSocketInterface: lt,
815
+ triggerNewInfo: Tt,
816
+ triggerNewSipEvent: _t,
817
+ triggerIncomingSession: It,
818
+ triggerFailIncomingSession: St,
819
+ WebSocketInterface: pt,
817
820
  UA: s,
818
821
  C: {
819
822
  INVITE: "INVITE"
820
823
  }
821
- }, I = "user", h = "displayName", w = "SIP_SERVER_URL", y = "SIP_WEB_SOCKET_SERVER_URL", wt = new D.WebSocketInterface(y), S = {
824
+ }, I = "user", h = "displayName", S = "SIP_SERVER_URL", y = "SIP_WEB_SOCKET_SERVER_URL", wt = new D.WebSocketInterface(y), w = {
822
825
  userAgent: "Chrome",
823
- sipServerUrl: w,
826
+ sipServerUrl: S,
824
827
  sipWebSocketServerURL: y
825
- }, Dt = {
826
- ...S
827
- }, St = {
828
- ...S,
828
+ }, yt = {
829
+ ...w
830
+ }, Nt = {
831
+ ...w,
829
832
  user: I,
830
833
  password: c,
831
834
  register: !0
832
- }, yt = {
833
- ...St,
834
- displayName: h
835
835
  }, Lt = {
836
- ...S,
836
+ ...Nt,
837
+ displayName: h
838
+ }, Ft = {
839
+ ...w,
837
840
  displayName: h,
838
841
  register: !1
839
842
  }, m = {
@@ -844,48 +847,48 @@ const g = "remote", gt = (o, e) => {
844
847
  register_expires: 300,
845
848
  connection_recovery_max_interval: 6,
846
849
  connection_recovery_min_interval: 2
847
- }, Ft = {
850
+ }, bt = {
848
851
  ...m,
849
852
  password: c,
850
- uri: new E("sip", I, w),
853
+ uri: new E("sip", I, S),
851
854
  display_name: "",
852
855
  register: !0
853
- }, bt = {
856
+ }, kt = {
854
857
  ...m,
855
858
  password: c,
856
- uri: new E("sip", I, w),
859
+ uri: new E("sip", I, S),
857
860
  display_name: h,
858
861
  register: !0
859
- }, kt = {
862
+ }, Vt = {
860
863
  ...m,
861
864
  display_name: h,
862
865
  register: !1
863
- }, Vt = {
866
+ }, Wt = {
864
867
  ...m,
865
868
  display_name: "",
866
869
  register: !1
867
- }, Nt = "10.10.10.10", Wt = [`X-Vinteo-Remote: ${Nt}`], Ut = () => new H({
870
+ }, ft = "10.10.10.10", Ut = [`X-Vinteo-Remote: ${ft}`], Gt = () => new x({
868
871
  JsSIP: D
869
872
  });
870
873
  export {
871
- Et as FAILED_CONFERENCE_NUMBER,
874
+ ht as FAILED_CONFERENCE_NUMBER,
872
875
  D as JsSIP,
873
- ut as NAME_INCORRECT,
876
+ lt as NAME_INCORRECT,
874
877
  c as PASSWORD_CORRECT,
875
878
  M as PASSWORD_CORRECT_2,
876
- w as SIP_SERVER_URL,
879
+ S as SIP_SERVER_URL,
877
880
  y as SIP_WEB_SOCKET_SERVER_URL,
878
- St as dataForConnectionWithAuthorization,
879
- yt as dataForConnectionWithAuthorizationWithDisplayName,
880
- Lt as dataForConnectionWithoutAuthorization,
881
- Dt as dataForConnectionWithoutAuthorizationWithoutDisplayName,
881
+ Nt as dataForConnectionWithAuthorization,
882
+ Lt as dataForConnectionWithAuthorizationWithDisplayName,
883
+ Ft as dataForConnectionWithoutAuthorization,
884
+ yt as dataForConnectionWithoutAuthorizationWithoutDisplayName,
882
885
  h as displayName,
883
- Ut as doMockSipConnector,
884
- Wt as extraHeadersRemoteAddress,
885
- Nt as remoteAddress,
886
- Ft as uaConfigurationWithAuthorization,
887
- bt as uaConfigurationWithAuthorizationWithDisplayName,
888
- kt as uaConfigurationWithoutAuthorization,
889
- Vt as uaConfigurationWithoutAuthorizationWithoutDisplayName,
886
+ Gt as doMockSipConnector,
887
+ Ut as extraHeadersRemoteAddress,
888
+ ft as remoteAddress,
889
+ bt as uaConfigurationWithAuthorization,
890
+ kt as uaConfigurationWithAuthorizationWithDisplayName,
891
+ Vt as uaConfigurationWithoutAuthorization,
892
+ Wt as uaConfigurationWithoutAuthorizationWithoutDisplayName,
890
893
  I as user
891
894
  };