sip-connector 19.2.2 → 19.3.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/{@SipConnector-D6QDb2P8.js → @SipConnector-BBoS4GNN.js} +0 -1
- package/dist/{@SipConnector-BblW4F3Y.cjs → @SipConnector-Bfb_x_4D.cjs} +1 -1
- package/dist/AutoConnectorManager/types.d.ts +2 -3
- package/dist/ConnectionManager/@ConnectionManager.d.ts +2 -2
- package/dist/ConnectionManager/ConnectionFlow.d.ts +4 -4
- package/dist/ConnectionManager/index.d.ts +2 -1
- package/dist/SipConnectorFacade/@SipConnectorFacade.d.ts +2 -11
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +233 -259
- package/dist/tools/__fixtures__/connectToServer.d.ts +14 -14
- package/dist/tools/__fixtures__/permissions.d.ts +3 -3
- package/dist/tools/__fixtures__/processRequest.d.ts +2 -2
- package/package.json +4 -4
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-BblW4F3Y.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-Bfb_x_4D.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
|
@@ -5,7 +5,7 @@ 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
7
|
import { Events as T } from "events-constructor";
|
|
8
|
-
import { O as H, S as x } from "./@SipConnector-
|
|
8
|
+
import { O as H, S as x } from "./@SipConnector-BBoS4GNN.js";
|
|
9
9
|
class _ extends k {
|
|
10
10
|
headers;
|
|
11
11
|
constructor(e) {
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("events-constructor");const r=require("./@SipConnector-BblW4F3Y.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===r.ECallCause.REQUEST_TIMEOUT||t===r.ECallCause.REJECTED||e==="local"&&(t===r.ECallCause.CANCELED||t===r.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}},N=n=>{const{url:e,cause:t}=n;let o=e;return(t===r.ECallCause.BAD_MEDIA_DESCRIPTION||t===r.ECallCause.NOT_FOUND)&&(o=`${n.message.to.uri.user}@${n.message.to.uri.host}`),o};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 o="CONNECT_SERVER_FAILED";switch(e){case"Forbidden":{o="WRONG_USER_OR_PASSWORD";break}case r.ECallCause.BAD_MEDIA_DESCRIPTION:{o="BAD_MEDIA_ERROR";break}case r.ECallCause.NOT_FOUND:{o="NOT_FOUND_ERROR";break}default:t!==void 0&&t._ws?.readyState===3?o="WS_CONNECTION_FAILED":N(n)!==void 0&&N(n)!==""&&(o="CONNECT_SERVER_FAILED_BY_LINK")}return o},ee=n=>{let e="";try{e=JSON.stringify(n)}catch(t){r.logger("failed to stringify message",t)}return e},ne=new Error("Unknown error"),te=(n=ne)=>{const{code:e,cause:t,message:o}=n,s=N(n),a={code:"",cause:"",message:""};return typeof o=="object"&&o!==null?a.message=ee(o):o&&(a.message=String(o)),s!==void 0&&s!==""&&(a.link=s),e!==void 0&&e!==""&&(a.code=e),t!==void 0&&t!==""&&(a.cause=t),a},re=Object.freeze(Object.defineProperty({__proto__:null,EErrorTypes:B,getLinkError:N,getTypeFromError:Z,getValuesFromError:te},Symbol.toStringTag,{value:"Module"})),oe=({sessionId:n,remoteAddress:e,isMutedAudio:t,isMutedVideo:o,isRegistered:s,isPresentationCall:a})=>{const c=[],l=t?"0":"1",u=o?"0":"1";return c.push(`X-Vinteo-Mic-State: ${l}`,`X-Vinteo-MainCam-State: ${u}`),(s===!1||s===void 0)&&c.push("X-Vinteo-Purgatory-Call: yes"),n!==void 0&&n!==""&&c.push(`X-Vinteo-Session: ${n}`),a===!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:o})=>{const a=`${ce(n)} ${e}`;return`ChromeNew - ${t===void 0?a:`${t} ${o}, ${a}`}`},le=({isUnifiedSdpSemantic:n,appVersion:e,browserName:t,browserVersion:o,appName:s})=>n?ie({appVersion:e,browserName:t,browserVersion:o,appName:s}):"Chrome",$="purgatory",D=n=>n===$,ue=n=>e=>[...e].map(o=>async()=>n(o)),de=async({accumulatedKeys:n,sendKey:e,canRunTask:t})=>{const s=ue(e)(n);return X.sequentPromises(s,t)},ge=n=>t=>(r.logger("onStartMainCam"),n.on("api:admin-start-main-cam",t)),Ce=n=>t=>(r.logger("onStartMic"),n.on("api:admin-start-mic",t)),Se=n=>t=>(r.logger("onStopMainCam"),n.on("api:admin-stop-main-cam",t)),me=n=>t=>(r.logger("onStopMic"),n.on("api:admin-stop-mic",t)),fe=({sipConnector:n})=>{const e=(d,C)=>({isSyncForced:g})=>{if(g===!0){d();return}C()},t=ge(n),o=Se(n),s=Ce(n),a=me(n);let c,l,u,m;const f=({onStartMainCamForced:d,onStartMainCamNotForced:C,onStopMainCamForced:g,onStopMainCamNotForced:h,onStartMicForced:b,onStartMicNotForced:v,onStopMicForced:O,onStopMicNotForced:P})=>{const y=e(d,C);c=t(y);const _=e(g,h);l=o(_);const M=e(b,v);u=s(M);const S=e(O,P);m=a(S)},p=()=>{c?.(),l?.(),u?.(),m?.()};return{start:d=>{f(d)},stop:()=>{p()}}},pe=Object.freeze(Object.defineProperty({__proto__:null,PURGATORY_CONFERENCE_NUMBER:$,createSyncMediaState:fe,createUaParser:x,error:re,getExtraHeaders:oe,getUserAgent:le,hasPurgatory:D,prepareMediaStream:r.prepareMediaStream,sendDtmfAccumulated:de,setEncodingsToSender:r.setEncodingsToSender,setParametersToSender:r.setParametersToSender},Symbol.toStringTag,{value:"Module"})),he=()=>x().isChrome,Re=n=>{if(!V.isCanceledError(n)&&!W.hasCanceledError(n)&&!r.hasNotReadyForConnectionError(n))throw n;return{isSuccessful:!1}},Ee=({kind:n,readyState:e})=>n==="video"&&e==="live",U=(n,e,{onEnterPurgatory:t,onEnterConference:o})=>{D(n)?t&&t():o&&o({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,o,s)=>{if(typeof o=="string"&&be.has(o)&&o in this.sipConnector){const c=Reflect.get(this.sipConnector,o,this.sipConnector);return typeof c=="function"?c.bind(this.sipConnector):c}const a=Reflect.get(t,o,s);return typeof a=="function"?a.bind(t):a}})}connectToServer=async(e,t)=>{const o=async()=>{const s=await r.resolveParameters(e);r.logger("connectToServer",s);const{userAgent:a,sipWebSocketServerURL:c,sipServerUrl:l,remoteAddress:u,displayName:m,name:f,password:p,isRegisteredUser:E}=s;return{userAgent:a,sipWebSocketServerURL:c,sipServerUrl:l,remoteAddress:u,displayName:m,password:p,user:f,register:E}};return this.sipConnector.connect(o,t).then(s=>(r.logger("connectToServer then"),{ua:s,isSuccessful:!0})).catch(async s=>(r.logger("connectToServer catch: error",s),Re(s)))};callToServer=async e=>{const{conference:t,mediaStream:o,extraHeaders:s,iceServers:a,contentHint:c,degradationPreference:l,sendEncodings:u,offerToReceiveAudio:m,offerToReceiveVideo:f,directionVideo:p,directionAudio:E,setRemoteStreams:T,onBeforeProgressCall:d,onSuccessProgressCall:C,onEnterPurgatory:g,onEnterConference:h,onFailProgressCall:b,onFinishProgressCall:v,onEndedCall:O,onAddedTransceiver:P}=e,y=this.resolveHandleReadyRemoteStreamsDebounced({onReadyRemoteStreams:T}),_=this.resolveHandleReadyRemoteStreams({onReadyRemoteStreams:()=>{y().catch(r.logger)}});r.logger("callToServer",e);const M=async()=>(r.logger("startCall"),this.sipConnector.call({mediaStream:o,extraHeaders:s,iceServers:a,contentHint:c,offerToReceiveAudio:m,offerToReceiveVideo:f,directionVideo:p,directionAudio:E,degradationPreference:l,onAddedTransceiver:P,sendEncodings:u,number:t,ontrack:_}));let S=!1,R;const A=(r.logger("subscribeEnterConference: onEnterConference",h),this.sipConnector.on("api:enterRoom",({room:i})=>{r.logger("enterRoom",{_room:i,isSuccessProgressCall:S}),R=i,(g??h)&&U(R,S,{onEnterPurgatory:g,onEnterConference:h})})),F=i=>(r.logger("onSuccess"),S=!0,y().catch(r.logger),C&&C({isPurgatory:D(R)}),this.sipConnector.onceRace(["call:ended","call:failed"],()=>{k(A,O)}),i),w=i=>(r.logger("onFail"),L(b,A,i)),I=()=>{r.logger("onFinish"),v&&v()};return r.logger("onBeforeProgressCall"),d&&d(t),M().then(F).catch(i=>w(i)).finally(I)};disconnectFromServer=async()=>this.sipConnector.disconnect().then(()=>(r.logger("disconnectFromServer: then"),{isSuccessful:!0})).catch(e=>(r.logger("disconnectFromServer: catch",e),{isSuccessful:!1}));answerToIncomingCall=async e=>{const{mediaStream:t,extraHeaders:o,iceServers:s,contentHint:a,degradationPreference:c,sendEncodings:l,offerToReceiveAudio:u,offerToReceiveVideo:m,directionVideo:f,directionAudio:p,setRemoteStreams:E,onBeforeProgressCall:T,onSuccessProgressCall:d,onEnterPurgatory:C,onEnterConference:g,onFailProgressCall:h,onFinishProgressCall:b,onEndedCall:v,onAddedTransceiver:O}=e,P=this.resolveHandleReadyRemoteStreamsDebounced({onReadyRemoteStreams:E}),y=this.resolveHandleReadyRemoteStreams({onReadyRemoteStreams:()=>{P().catch(r.logger)}});r.logger("answerToIncomingCall",e);const _=async()=>this.sipConnector.answerToIncomingCall({mediaStream:t,extraHeaders:o,iceServers:s,contentHint:a,offerToReceiveAudio:u,offerToReceiveVideo:m,directionVideo:f,directionAudio:p,degradationPreference:c,onAddedTransceiver:O,sendEncodings:l,ontrack:y}),M=()=>{const{remoteCallerData:i}=this.sipConnector;return i.incomingNumber};let S=!1,R;const A=(r.logger("subscribeEnterConference: onEnterConference",g),this.sipConnector.on("api:enterRoom",i=>{r.logger("enterRoom",{_room:i,isSuccessProgressCall:S}),R=i,(C??g)&&U(R,S,{onEnterPurgatory:C,onEnterConference:g})})),F=i=>(r.logger("onSuccess"),S=!0,P().catch(r.logger),d&&d({isPurgatory:D(R)}),this.sipConnector.onceRace(["call:ended","call:failed"],()=>{k(A,v)}),i),w=i=>(r.logger("onFail"),L(h,A,i)),I=()=>{r.logger("onFinish"),b&&b()};if(r.logger("onBeforeProgressCall"),T){const i=M();T(i)}return _().then(F).catch(i=>w(i)).finally(I)};updatePresentation=async({mediaStream:e,isP2P:t,contentHint:o,degradationPreference:s,sendEncodings:a,onAddedTransceiver:c})=>(r.logger("updatePresentation"),this.sipConnector.updatePresentation(e,{isP2P:t,contentHint:o,degradationPreference:s,onAddedTransceiver:c,sendEncodings:a}));startPresentation=async({mediaStream:e,isP2P:t,contentHint:o,degradationPreference:s,sendEncodings:a,callLimit:c,onAddedTransceiver:l})=>(r.logger("startPresentation"),this.sipConnector.startPresentation(e,{isP2P:t,contentHint:o,callLimit:c,degradationPreference:s,onAddedTransceiver:l,sendEncodings:a}));stopShareSipConnector=async({isP2P:e=!1}={})=>(r.logger("stopShareSipConnector"),this.sipConnector.stopPresentation({isP2P:e}).catch(t=>{r.logger(t)}));sendRefusalToTurnOnMic=async()=>{r.logger("sendRefusalToTurnOnMic"),await this.sipConnector.sendRefusalToTurnOnMic().catch(e=>{r.logger("sendRefusalToTurnOnMic: error",e)})};sendRefusalToTurnOnCam=async()=>{r.logger("sendRefusalToTurnOnCam"),await this.sipConnector.sendRefusalToTurnOnCam().catch(e=>{r.logger("sendRefusalToTurnOnCam: error",e)})};sendMediaState=async({isEnabledCam:e,isEnabledMic:t})=>{r.logger("sendMediaState"),await this.sipConnector.sendMediaState({cam:e,mic:t})};replaceMediaStream=async(e,{deleteExisting:t,addMissing:o,forceRenegotiation:s,contentHint:a,degradationPreference:c,sendEncodings:l,onAddedTransceiver:u})=>(r.logger("replaceMediaStream"),this.sipConnector.replaceMediaStream(e,{deleteExisting:t,addMissing:o,forceRenegotiation:s,contentHint:a,degradationPreference:c,onAddedTransceiver:u,sendEncodings:l}));askPermissionToEnableCam=async()=>{r.logger("askPermissionToEnableCam"),await this.sipConnector.askPermissionToEnableCam()};resolveHandleReadyRemoteStreamsDebounced=({onReadyRemoteStreams:e})=>j.debounce(()=>{const t=this.sipConnector.getRemoteStreams();r.logger("remoteStreams",t),t&&e(t)},200);resolveHandleReadyRemoteStreams=({onReadyRemoteStreams:e})=>({track:t})=>{Ee(t)&&e()};getRemoteStreams=()=>(r.logger("getRemoteStreams"),this.sipConnector.getRemoteStreams());onUseLicense=e=>(r.logger("onUseLicense"),this.sipConnector.on("api:useLicense",e));onMustStopPresentation=e=>(r.logger("onMustStopPresentation"),this.sipConnector.on("api:mustStopPresentation",e));onMoveToSpectators=e=>(r.logger("onMoveToSpectators"),this.sipConnector.on("api:participant:move-request-to-spectators",e));onMoveToParticipants=e=>(r.logger("onMoveToParticipants"),this.sipConnector.on("api:participant:move-request-to-participants",e));onStats=e=>(r.logger("onStats"),this.sipConnector.on("stats:collected",e));offStats=e=>{r.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=r.ECallCause;exports.EStatsTypes=r.EStatsTypes;exports.EUseLicense=r.EUseLicense;exports.SipConnector=r.SipConnector;exports.StatsPeerConnection=r.StatsPeerConnection;exports.disableDebug=r.disableDebug;exports.enableDebug=r.enableDebug;exports.getCodecFromSender=r.getCodecFromSender;exports.hasCanceledStartPresentationError=r.hasCanceledStartPresentationError;Object.defineProperty(exports,"hasConnectionPromiseIsNotActualError",{enumerable:!0,get:()=>Y.isPromiseIsNotActualError});exports.EMimeTypesVideoCodecs=H;exports.SipConnectorFacade=ve;exports.hasAvailableStats=he;exports.hasCanceledCallError=J;exports.tools=pe;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("events-constructor");const o=require("./@SipConnector-Bfb_x_4D.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 P=({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)},T=()=>{c?.(),l?.(),d?.(),h?.()};return{start:u=>{P(u)},stop:()=>{T()}}},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{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 Pe{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"),{ua: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:P,directionVideo:T,directionAudio:N,setRemoteStreams:v,onBeforeProgressCall:u,onSuccessProgressCall:C,onEnterPurgatory:g,onEnterConference:m,onFailProgressCall:p,onFinishProgressCall:R,onEndedCall:y,onAddedTransceiver:E}=e,b=this.resolveHandleReadyRemoteStreamsDebounced({onReadyRemoteStreams:v}),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:P,directionVideo:T,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:P,directionAudio:T,setRemoteStreams:N,onBeforeProgressCall:v,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:P,directionAudio:T,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"),v){const i=_();v(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=Pe;exports.hasAvailableStats=pe;exports.hasCanceledCallError=J;exports.tools=he;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { EUseLicense } from './ApiManager';
|
|
2
2
|
export { ECallCause, hasCanceledCallError } from './CallManager';
|
|
3
3
|
export type { TCustomError } from './CallManager';
|
|
4
|
+
export type { TParametersConnection } from './ConnectionManager';
|
|
4
5
|
export { disableDebug, enableDebug } from './logger';
|
|
5
6
|
export { hasCanceledStartPresentationError } from './PresentationManager';
|
|
6
7
|
export type { TContentHint } from './PresentationManager';
|