sip-connector 19.5.0 → 19.7.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.
@@ -15,6 +15,8 @@ declare class AutoConnectorManager {
15
15
  private readonly cancelableRequestBeforeRetry;
16
16
  private readonly onBeforeRetry;
17
17
  private readonly canRetryOnError;
18
+ private readonly networkInterfacesSubscriber;
19
+ private readonly resumeFromSleepModeSubscriber;
18
20
  constructor({ connectionQueueManager, connectionManager, callManager, }: {
19
21
  connectionQueueManager: ConnectionQueueManager;
20
22
  connectionManager: ConnectionManager;
@@ -27,6 +29,7 @@ declare class AutoConnectorManager {
27
29
  onceRace<T extends keyof TEventMap>(eventNames: T[], handler: (data: TEventMap[T], eventName: string) => void): () => void;
28
30
  wait<T extends keyof TEventMap>(eventName: T): Promise<TEventMap[T]>;
29
31
  off<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): void;
32
+ private shutdown;
30
33
  private stopAttempts;
31
34
  private stopConnectTriggers;
32
35
  private runCheckTelephony;
@@ -35,6 +38,11 @@ declare class AutoConnectorManager {
35
38
  private handleLimitReached;
36
39
  private handleSucceededAttempt;
37
40
  private subscribeToConnectTriggers;
41
+ private subscribeToNetworkInterfaces;
42
+ private unsubscribeFromNetworkInterfaces;
43
+ private restartPingServerIfNotActiveCallRequester;
44
+ private stopPingServerIfNotActiveCallRequester;
45
+ private startPingServerIfNotActiveCallRequester;
38
46
  private connectIfDisconnected;
39
47
  private reconnect;
40
48
  private hasFailedOrDisconnectedConnection;
@@ -3,6 +3,8 @@ import { ConnectionQueueManager } from '../ConnectionQueueManager';
3
3
  export interface IAutoConnectorOptions {
4
4
  checkTelephonyRequestInterval?: number;
5
5
  timeoutBetweenAttempts?: number;
6
+ networkInterfacesSubscriber?: TNetworkInterfacesSubscriber;
7
+ resumeFromSleepModeSubscriber?: TResumeFromSleepModeSubscriber;
6
8
  onBeforeRetry?: () => Promise<void>;
7
9
  canRetryOnError?: (error: unknown) => boolean;
8
10
  }
@@ -10,6 +12,19 @@ export type ISubscriber<T = void> = {
10
12
  subscribe: (callback: (value: T) => void) => void;
11
13
  unsubscribe: () => void;
12
14
  };
15
+ export type TNetworkInterfacesSubscriber = {
16
+ subscribe: (parameters: {
17
+ onChange: () => void;
18
+ onUnavailable: () => void;
19
+ }) => void;
20
+ unsubscribe: () => void;
21
+ };
22
+ export type TResumeFromSleepModeSubscriber = {
23
+ subscribe: ({ onResume }: {
24
+ onResume: () => void;
25
+ }) => void;
26
+ unsubscribe: () => void;
27
+ };
13
28
  export type TParametersCheckTelephony = Parameters<ConnectionManager['checkTelephony']>[0];
14
29
  type TOptionsConnect = Parameters<ConnectionQueueManager['connect']>[1];
15
30
  export type TParametersAutoConnect = {
@@ -46,7 +46,7 @@ export default class ConnectionManager {
46
46
  wait<T extends keyof TEventMap>(eventName: T): Promise<TEventMap[T]>;
47
47
  off<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): void;
48
48
  isConfigured(): boolean;
49
- getConnectionConfiguration: () => import('./ConfigurationManager').IConnectionConfiguration;
49
+ getConnectionConfiguration: () => import('./ConfigurationManager').IConnectionConfiguration | undefined;
50
50
  destroy(): void;
51
51
  getSipServerUrl: TGetServerUrl;
52
52
  readonly getUaProtected: () => UA;
@@ -1,7 +1,7 @@
1
1
  import { UA } from '@krivega/jssip';
2
2
  export interface IConnectionConfiguration {
3
- sipServerUrl?: string;
4
- displayName?: string;
3
+ sipServerUrl: string;
4
+ displayName: string;
5
5
  register?: boolean;
6
6
  user?: string;
7
7
  password?: string;
@@ -20,11 +20,11 @@ export default class ConfigurationManager {
20
20
  /**
21
21
  * Получает текущую конфигурацию подключения
22
22
  */
23
- get(): IConnectionConfiguration;
23
+ get(): IConnectionConfiguration | undefined;
24
24
  /**
25
25
  * Устанавливает конфигурацию подключения
26
26
  */
27
- set(data: IConnectionConfiguration): void;
27
+ set(data: IConnectionConfiguration | undefined): void;
28
28
  /**
29
29
  * Обновляет конфигурацию подключения
30
30
  */
@@ -11,7 +11,7 @@ export type TOptionsExtraHeaders = {
11
11
  export type TParametersConnection = TOptionsExtraHeaders & {
12
12
  sipServerUrl: string;
13
13
  sipWebSocketServerURL: string;
14
- displayName?: string;
14
+ displayName: string;
15
15
  register?: boolean;
16
16
  user?: string;
17
17
  password?: string;
@@ -23,8 +23,8 @@ export type TParametersConnection = TOptionsExtraHeaders & {
23
23
  connectionRecoveryMaxInterval?: number;
24
24
  };
25
25
  export type TConnectionConfiguration = {
26
- sipServerUrl?: string;
27
- displayName?: string;
26
+ sipServerUrl: string;
27
+ displayName: string;
28
28
  register?: boolean;
29
29
  user?: string;
30
30
  password?: string;
@@ -46,8 +46,8 @@ interface IDependencies {
46
46
  registrationManager: RegistrationManager;
47
47
  getUa: () => UA | undefined;
48
48
  setUa: (ua: UA | undefined) => void;
49
- getConnectionConfiguration: () => TConnectionConfiguration;
50
- setConnectionConfiguration: (config: TConnectionConfiguration) => void;
49
+ getConnectionConfiguration: () => TConnectionConfiguration | undefined;
50
+ setConnectionConfiguration: (config: TConnectionConfiguration | undefined) => void;
51
51
  updateConnectionConfiguration: <K extends keyof TConnectionConfiguration>(key: K, value: TConnectionConfiguration[K]) => void;
52
52
  setSipServerUrl: (getSipServerUrl: TGetServerUrl) => void;
53
53
  setSocket: (socket: WebSocketInterface) => void;
@@ -13,7 +13,7 @@ export type TCreateUAParameters = UAConfigurationParams & {
13
13
  };
14
14
  type TParametersCreateUaConfiguration = {
15
15
  sipWebSocketServerURL: string;
16
- displayName?: string;
16
+ displayName: string;
17
17
  sipServerUrl: string;
18
18
  user?: string;
19
19
  register?: boolean;
@@ -62,7 +62,7 @@ declare class SipConnector {
62
62
  ping: (body?: Parameters<ConnectionManager["ping"]>[0], extraHeaders?: Parameters<ConnectionManager["ping"]>[1]) => Promise<void>;
63
63
  checkTelephony: ConnectionManager['checkTelephony'];
64
64
  isConfigured: () => boolean;
65
- getConnectionConfiguration: () => import('../ConnectionManager/ConfigurationManager').IConnectionConfiguration;
65
+ getConnectionConfiguration: () => import('../ConnectionManager/ConfigurationManager').IConnectionConfiguration | undefined;
66
66
  getSipServerUrl: TGetServerUrl;
67
67
  startAutoConnect: AutoConnectorManager['start'];
68
68
  stopAutoConnect: AutoConnectorManager['stop'];
@@ -63,32 +63,6 @@ export type TOutboundRtp = RTCOutboundRtpStreamStats & {
63
63
  targetBitrate?: number;
64
64
  trackId?: string;
65
65
  };
66
- export type TTransport = RTCTransportStats & {
67
- dtlsRole?: string;
68
- iceLocalUsernameFragment?: string;
69
- iceRole?: string;
70
- iceState?: string;
71
- packetsSent?: number;
72
- remoteCertificateId?: string;
73
- selectedCandidatePairChanges?: number;
74
- };
75
- export type TInboundRtp = RTCInboundRtpStreamStats & {
76
- audioLevel?: number;
77
- bytesReceived?: number;
78
- decoderImplementation?: string;
79
- framesDropped?: number;
80
- framesReceived?: number;
81
- headerBytesReceived?: number;
82
- jitterBufferDelay?: number;
83
- jitterBufferEmittedCount?: number;
84
- keyFramesDecoded?: number;
85
- fecPacketsDiscarded?: number;
86
- fecPacketsReceived?: number;
87
- jitterBufferMinimumDelay?: number;
88
- jitterBufferTargetDelay?: number;
89
- lastPacketReceivedTimestamp?: number;
90
- totalSamplesReceived?: number;
91
- };
92
66
  export type TMediaSource = {
93
67
  audioLevel?: number;
94
68
  frames?: number;
@@ -145,15 +119,15 @@ export type TAdditional = {
145
119
  certificate?: TCertificate;
146
120
  localCandidate?: TCandidate;
147
121
  remoteCandidate?: TCandidate;
148
- transport?: TTransport;
122
+ transport?: RTCTransportStats;
149
123
  };
150
124
  export type TInboundVideo = {
151
- inboundRtp?: TInboundRtp;
125
+ inboundRtp?: RTCInboundRtpStreamStats;
152
126
  codec?: RTCRtpCodecParameters;
153
127
  synchronizationSources?: TMedia;
154
128
  };
155
129
  export type TInboundAudio = {
156
- inboundRtp?: TInboundRtp;
130
+ inboundRtp?: RTCInboundRtpStreamStats;
157
131
  codec?: RTCRtpCodecParameters;
158
132
  remoteOutboundRtp?: TRemoteOutboundRtp;
159
133
  synchronizationSources?: TMedia;
@@ -175,7 +149,7 @@ export type TAudioStatistics = {
175
149
  [EStatsTypes.CODEC]?: RTCRtpCodecParameters;
176
150
  [EStatsTypes.MEDIA_SOURCE]?: TMediaSource;
177
151
  [EStatsTypes.REMOTE_INBOUND_RTP]?: TRemoteInboundRtp;
178
- [EStatsTypes.INBOUND_RTP]?: TInboundRtp;
152
+ [EStatsTypes.INBOUND_RTP]?: RTCInboundRtpStreamStats;
179
153
  [EStatsTypes.REMOTE_OUTBOUND_RTP]?: TRemoteOutboundRtp;
180
154
  };
181
155
  export type TVideoStatistics = {
@@ -183,12 +157,12 @@ export type TVideoStatistics = {
183
157
  [EStatsTypes.CODEC]?: RTCRtpCodecParameters;
184
158
  [EStatsTypes.MEDIA_SOURCE]?: TMediaSource;
185
159
  [EStatsTypes.REMOTE_INBOUND_RTP]?: TRemoteInboundRtp;
186
- [EStatsTypes.INBOUND_RTP]?: TInboundRtp;
160
+ [EStatsTypes.INBOUND_RTP]?: RTCInboundRtpStreamStats;
187
161
  };
188
162
  export type TParsedStatistics = {
189
163
  [EStatsTypes.CANDIDATE_PAIR]?: TCandidatePair;
190
164
  [EStatsTypes.CERTIFICATE]?: TCertificate;
191
165
  [EStatsTypes.LOCAL_CANDIDATE]?: TCandidate;
192
166
  [EStatsTypes.REMOTE_CANDIDATE]?: TCandidate;
193
- [EStatsTypes.TRANSPORT]?: TTransport;
167
+ [EStatsTypes.TRANSPORT]?: RTCTransportStats;
194
168
  };
@@ -4,6 +4,8 @@ export declare const displayName = "displayName";
4
4
  export declare const SIP_SERVER_URL = "SIP_SERVER_URL";
5
5
  export declare const SIP_WEB_SOCKET_SERVER_URL = "SIP_WEB_SOCKET_SERVER_URL";
6
6
  export declare const dataForConnectionWithoutAuthorizationWithoutDisplayName: {
7
+ displayName: string;
8
+ register: boolean;
7
9
  userAgent: string;
8
10
  sipServerUrl: string;
9
11
  sipWebSocketServerURL: string;
@@ -12,6 +14,7 @@ export declare const dataForConnectionWithAuthorization: {
12
14
  user: string;
13
15
  password: string;
14
16
  register: boolean;
17
+ displayName: string;
15
18
  userAgent: string;
16
19
  sipServerUrl: string;
17
20
  sipWebSocketServerURL: string;
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-kXwCLeH0.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-CMDm0Voo.cjs");class N extends q.IncomingRequest{headers;constructor(e){super(),this.headers=new Headers(e)}getHeader(e){return this.headers.get(e)??""}}const G="incomingCall",x="declinedIncomingCall",z="failedIncomingCall",Y="terminatedIncomingCall",y="connecting",j="connected",B="disconnected",K="newRTCSession",J="registered",$="unregistered",Q="registrationFailed",X="newMessage",Z="sipEvent",ee="availableSecondRemoteStream",te="notAvailableSecondRemoteStream",re="mustStopPresentation",ne="shareState",oe="enterRoom",ie="useLicense",se="peerconnection:confirmed",ae="peerconnection:ontrack",ce="channels",de="channels:notify",Ee="ended:fromserver",he="main-cam-control",ue="admin-stop-main-cam",me="admin-start-main-cam",le="admin-stop-mic",pe="admin-start-mic",ge="admin-force-sync-media-state",_e="participant:added-to-list-moderators",Te="participant:removed-from-list-moderators",Ie="participant:move-request-to-stream",Se="participant:move-request-to-spectators",Ne="participant:move-request-to-participants",we="participation:accepting-word-request",Ce="participation:cancelling-word-request",Re="webcast:started",fe="webcast:stopped",Ae="account:changed",Me="account:deleted",Oe="conference:participant-token-issued",Pe="ended",ve="sending",De="reinvite",ye="replaces",Le="refer",Fe="progress",We="accepted",be="confirmed",ke="peerconnection",Ve="failed",Ue="muted",He="unmuted",qe="newDTMF",Ge="newInfo",xe="hold",ze="unhold",Ye="update",je="sdp",Be="icecandidate",Ke="getusermediafailed",Je="peerconnection:createofferfailed",$e="peerconnection:createanswerfailed",Qe="peerconnection:setlocaldescriptionfailed",Xe="peerconnection:setremotedescriptionfailed",Ze="presentation:start",et="presentation:started",tt="presentation:end",rt="presentation:ended",nt="presentation:failed",ot=[G,x,Y,z,we,Ce,Ie,de,Oe,Ae,Me,Re,fe,_e,Te],L=[y,j,B,K,J,$,Q,X,Z],it=[ee,te,re,ne,oe,ie,se,ae,ce,Ee,he,me,ue,le,pe,ge,Se,Ne],_=[Pe,y,ve,De,ye,Le,Fe,We,be,ke,Ve,Ue,He,qe,Ge,xe,ze,Ye,je,Be,Ke,Je,$e,Qe,Xe,Ze,et,tt,rt,nt];[...L,...ot];[..._,...it];class st{originator;connection;events;remote_identity;mutedOptions={audio:!1,video:!1};constructor({originator:e="local",eventHandlers:t,remoteIdentity:r}){this.originator=e,this.events=new S.Events(_),this.initEvents(t),this.remote_identity=r}get contact(){throw new Error("Method not implemented.")}get direction(){throw new Error("Method not implemented.")}get local_identity(){throw new Error("Method not implemented.")}get start_time(){throw new Error("Method not implemented.")}get end_time(){throw new Error("Method not implemented.")}get status(){throw new Error("Method not implemented.")}get C(){throw new Error("Method not implemented.")}get causes(){throw new Error("Method not implemented.")}get id(){throw new Error("Method not implemented.")}get data(){throw new Error("Method not implemented.")}set data(e){throw new Error("Method not implemented.")}isInProgress(){throw new Error("Method not implemented.")}isEnded(){throw new Error("Method not implemented.")}isReadyToReOffer(){throw new Error("Method not implemented.")}answer(e){throw new Error("Method not implemented.")}terminate(e){throw new Error("Method not implemented.")}async sendInfo(e,t,r){throw new Error("Method not implemented.")}hold(e,t){throw new Error("Method not implemented.")}unhold(e,t){throw new Error("Method not implemented.")}async renegotiate(e,t){throw new Error("Method not implemented.")}isOnHold(){throw new Error("Method not implemented.")}mute(e){throw new Error("Method not implemented.")}unmute(e){throw new Error("Method not implemented.")}isMuted(){throw new Error("Method not implemented.")}refer(e,t){throw new Error("Method not implemented.")}resetLocalMedia(){throw new Error("Method not implemented.")}async replaceMediaStream(e,t){throw new Error("Method not implemented.")}addListener(e,t){throw new Error("Method not implemented.")}once(e,t){throw new Error("Method not implemented.")}removeListener(e,t){throw new Error("Method not implemented.")}off(e,t){return this.events.off(e,t),this}removeAllListeners(e){return console.warn("Method not implemented. Event:",e),this}setMaxListeners(e){throw new Error("Method not implemented.")}getMaxListeners(){throw new Error("Method not implemented.")}listeners(e){throw new Error("Method not implemented.")}rawListeners(e){throw new Error("Method not implemented.")}emit(e,...t){throw new Error("Method not implemented.")}listenerCount(e){throw new Error("Method not implemented.")}prependListener(e,t){throw new Error("Method not implemented.")}prependOnceListener(e,t){throw new Error("Method not implemented.")}eventNames(){throw new Error("Method not implemented.")}initEvents(e){e&&Object.entries(e).forEach(([t,r])=>{this.on(t,r)})}on(e,t){return _.includes(e)&&this.events.on(e,t),this}trigger(e,t){this.events.trigger(e,t)}sendDTMF(){this.trigger("newDTMF",{originator:this.originator})}async startPresentation(e){return this.trigger("presentation:start",e),this.trigger("presentation:started",e),e}async stopPresentation(e){return this.trigger("presentation:end",e),this.trigger("presentation:ended",e),e}isEstablished(){return!0}}class A{stats=new Map().set("codec",{mimeType:"video/h264"});dtmf=null;track=null;transport=null;transform=null;parameters={encodings:[{}],transactionId:"0",codecs:[],headerExtensions:[],rtcp:{}};parametersGets;constructor({track:e}={}){this.track=e??null}async getStats(){return this.stats}async replaceTrack(e){this.track=e??null}async setParameters(e){if(e!==this.parametersGets)throw new Error("Failed to execute 'setParameters' on 'RTCRtpSender': Read-only field modified in setParameters().");const{transactionId:t}=this.parameters;this.parameters={...this.parameters,...e,transactionId:`${Number(t)+1}`}}getParameters(){return this.parametersGets={...this.parameters},this.parametersGets}setStreams(){throw new Error("Method not implemented.")}}class M{currentDirection="sendrecv";direction="sendrecv";mid=null;receiver;sender;stopped=!1;constructor(e){this.sender=e}setCodecPreferences(e){}stop(){}}const at=["track"];class ct{senders=[];receivers=[];canTrickleIceCandidates;connectionState;currentLocalDescription;currentRemoteDescription;iceConnectionState;iceGatheringState;idpErrorInfo;idpLoginUrl;localDescription;onconnectionstatechange;ondatachannel;onicecandidate;onicecandidateerror=null;oniceconnectionstatechange;onicegatheringstatechange;onnegotiationneeded;onsignalingstatechange;ontrack;peerIdentity=void 0;pendingLocalDescription;pendingRemoteDescription;remoteDescription;sctp=null;signalingState;events;constructor(e,t){this.events=new S.Events(at),this.receivers=t.map(r=>({track:r}))}getRemoteStreams(){throw new Error("Method not implemented.")}async addIceCandidate(e){throw new Error("Method not implemented.")}addTransceiver(e,t){throw new Error("Method not implemented.")}close(){throw new Error("Method not implemented.")}restartIce(){throw new Error("Method not implemented.")}async createAnswer(e,t){throw new Error("Method not implemented.")}createDataChannel(e,t){throw new Error("Method not implemented.")}async createOffer(e,t,r){throw new Error("Method not implemented.")}getConfiguration(){throw new Error("Method not implemented.")}async getIdentityAssertion(){throw new Error("Method not implemented.")}async getStats(e){throw new Error("Method not implemented.")}getTransceivers(){throw new Error("Method not implemented.")}removeTrack(e){throw new Error("Method not implemented.")}setConfiguration(e){throw new Error("Method not implemented.")}async setLocalDescription(e){throw new Error("Method not implemented.")}async setRemoteDescription(e){throw new Error("Method not implemented.")}addEventListener(e,t,r){this.events.on(e,t)}removeEventListener(e,t,r){this.events.off(e,t)}dispatchEvent(e){throw new Error("Method not implemented.")}getReceivers=()=>this.receivers;getSenders=()=>this.senders;addTrack=(e,...t)=>{const r=new A({track:e}),n=new M(r);return n.mid=e.kind==="audio"?"0":"1",this.senders.push(r),this.events.trigger("track",{track:e,transceiver:n}),r};addTrackWithMid=(e,t)=>{const r=new A({track:e}),n=new M(r);return t===void 0?n.mid=e.kind==="audio"?"0":"1":n.mid=t,this.senders.push(r),this.events.trigger("track",{track:e,transceiver:n}),r}}function dt(o){const e=o.match(/(purgatory)|[\d.]+/g);if(!e)throw new Error("wrong sip url");return e[0]}const O=400,F="777",Et=o=>o.getVideoTracks().length>0;class s extends st{static presentationError;static startPresentationError;static countStartPresentationError=Number.POSITIVE_INFINITY;static countStartsPresentation=0;url;status_code;answer=jest.fn(({mediaStream:e})=>{if(this.originator!=="remote")throw new Error("answer available only for remote sessions");this.initPeerconnection(e),setTimeout(()=>{this.trigger("connecting"),setTimeout(()=>{this.trigger("accepted")},100),setTimeout(()=>{this.trigger("confirmed")},200)},O)});replaceMediaStream=jest.fn(async e=>{});_isReadyToReOffer=jest.fn(()=>!0);addTransceiver=jest.fn((e,t)=>({}));restartIce=jest.fn(async e=>!0);isEndedInner=!1;delayStartPresentation=0;timeoutStartPresentation;timeoutConnect;timeoutNewInfo;timeoutAccepted;timeoutConfirmed;constructor({eventHandlers:e,originator:t,remoteIdentity:r=new a.NameAddrHeader(new a.URI("sip","caller1","test1.com",5060),"Test Caller 1"),delayStartPresentation:n=0}){super({originator:t,eventHandlers:e,remoteIdentity:r}),this.delayStartPresentation=n}static get C(){return a.SessionStatus}static setPresentationError(e){this.presentationError=e}static resetPresentationError(){this.presentationError=void 0}static setStartPresentationError(e,{count:t=Number.POSITIVE_INFINITY}={}){this.startPresentationError=e,this.countStartPresentationError=t}static resetStartPresentationError(){this.startPresentationError=void 0,this.countStartPresentationError=Number.POSITIVE_INFINITY,this.countStartsPresentation=0}startPresentation=async e=>(s.countStartsPresentation+=1,new Promise((t,r)=>{this.timeoutStartPresentation=setTimeout(()=>{if(s.presentationError){this.trigger("presentation:start",e),this.trigger("presentation:failed",e),r(s.presentationError);return}if(s.startPresentationError&&s.countStartsPresentation<s.countStartPresentationError){this.trigger("presentation:start",e),this.trigger("presentation:failed",e),r(s.startPresentationError);return}t(super.startPresentation(e))},this.delayStartPresentation)}));stopPresentation=async e=>{if(s.presentationError)throw this.trigger("presentation:end",e),this.trigger("presentation:failed",e),s.presentationError;return super.stopPresentation(e)};initPeerconnection(e){return e?(this.createPeerconnection(e),!0):!1}createPeerconnection(e){const t=f.createAudioMediaStreamTrackMock();t.id="mainaudio1";const r=[t];if(Et(e)){const c=f.createVideoMediaStreamTrackMock();c.id="mainvideo1",r.push(c)}this.connection=new ct(void 0,r),this.addStream(e),this.trigger("peerconnection",{peerconnection:this.connection})}connect(e,{mediaStream:t}={}){const r=dt(e);return this.initPeerconnection(t),this.timeoutConnect=setTimeout(()=>{e.includes(F)?this.trigger("failed",{originator:"remote",message:"IncomingResponse",cause:"Rejected"}):(this.trigger("connecting"),this.timeoutNewInfo=setTimeout(()=>{this.newInfo({originator:D.Originator.REMOTE,request:{getHeader:n=>n==="content-type"?"application/vinteo.webrtc.roomname":n==="x-webrtc-enter-room"?r:n==="x-webrtc-participant-name"?"Test Caller 1":""}})},100),this.timeoutAccepted=setTimeout(()=>{this.trigger("accepted")},200),this.timeoutConfirmed=setTimeout(()=>{this.trigger("confirmed")},300))},O),this.connection}terminate({status_code:e,cause:t}={}){return this.status_code=e,this.trigger("ended",{status_code:e,cause:t,originator:"local"}),this.isEndedInner=!1,this}async terminateAsync({status_code:e,cause:t}={}){this.terminate({status_code:e,cause:t})}terminateRemote({status_code:e}={}){return this.status_code=e,this.trigger("ended",{status_code:e,originator:"remote"}),this}addStream(e,t="getTracks"){e[t]().forEach(r=>this.connection.addTrack(r))}forEachSenders(e){const t=this.connection.getSenders();for(const r of t)e(r);return t}toggleMuteAudio(e){this.forEachSenders(({track:t})=>{t?.kind==="audio"&&(t.enabled=!e)})}toggleMuteVideo(e){this.forEachSenders(({track:t})=>{t?.kind==="video"&&(t.enabled=!e)})}mute(e){e.audio&&(this.mutedOptions.audio=!0,this.toggleMuteAudio(this.mutedOptions.audio)),e.video&&(this.mutedOptions.video=!0,this.toggleMuteVideo(this.mutedOptions.video)),this.onmute(e)}unmute(e){e.audio&&(this.mutedOptions.audio=!1),e.video&&(this.mutedOptions.video=!1),this.trigger("unmuted",e)}isMuted(){return this.mutedOptions}onmute({audio:e,video:t}){this.trigger("muted",{audio:e,video:t})}async sendInfo(){}isEnded(){return this.isEndedInner}newInfo(e){this.trigger("newInfo",e)}clear(){clearTimeout(this.timeoutStartPresentation),clearTimeout(this.timeoutConnect),clearTimeout(this.timeoutNewInfo),clearTimeout(this.timeoutAccepted),clearTimeout(this.timeoutConfirmed)}}class ht{extraHeaders=[];setExtraHeaders(e){this.extraHeaders=e}setExtraContactParams(){}}const d="PASSWORD_CORRECT",T="PASSWORD_CORRECT_2",W="NAME_INCORRECT",h=400,g={url:"wss://sipServerUrl/webrtc/wss/",sip_uri:"sip:sipServerUrl;transport=ws",via_transport:"WSS"},P={status_code:200,reason_phrase:"OK"},v={status_code:401,reason_phrase:"Unauthorized"};class i{static isAvailableTelephony=!0;static startError;static countStartError=Number.POSITIVE_INFINITY;static countStarts=0;events;registratorInner;call=jest.fn((e,t)=>{const{mediaStream:r,eventHandlers:n}=t;return this.session=new s({eventHandlers:n,originator:"local"}),this.session.connect(e,{mediaStream:r}),this.session});sendOptions=jest.fn((e,t,r)=>{console.log("sendOptions",e,t,r)});start=jest.fn(()=>{if(i.countStarts+=1,i.startError&&i.countStarts<i.countStartError){this.trigger("disconnected",i.startError);return}this.register()});stop=jest.fn(()=>{this.startedTimeout&&clearTimeout(this.startedTimeout),this.stopedTimeout&&clearTimeout(this.stopedTimeout),this.unregister(),this.isStarted()?this.stopedTimeout=setTimeout(()=>{this.trigger("disconnected",{error:!0,socket:g})},h):this.trigger("disconnected",{error:!0,socket:g})});removeAllListeners=jest.fn(()=>(this.events.removeEventHandlers(),this));once=jest.fn((e,t)=>(this.events.once(e,t),this));startedTimeout;stopedTimeout;session;isRegisteredInner;isConnectedInner;configuration;constructor(e){this.events=new S.Events(L);const[t,r]=e.uri.split(":"),[n,c]=r.split("@"),p={...e,uri:new a.URI(t,n,c)};this.configuration=p,this.registratorInner=new ht}static setStartError(e,{count:t=Number.POSITIVE_INFINITY}={}){i.startError=e,i.countStartError=t}static resetStartError(){i.startError=void 0,i.countStartError=Number.POSITIVE_INFINITY,i.countStarts=0}static setAvailableTelephony(){i.isAvailableTelephony=!0}static setNotAvailableTelephony(){i.isAvailableTelephony=!1}static reset(){i.resetStartError(),i.setAvailableTelephony()}on(e,t){return this.events.on(e,t),this}off(e,t){return this.events.off(e,t),this}trigger(e,t){this.events.trigger(e,t)}terminateSessions(){this.session?.terminate()}set(e,t){return this.configuration[e]=t,!0}register(){this.startedTimeout&&clearTimeout(this.startedTimeout);const{password:e,register:t,uri:r}=this.configuration;t===!0&&r.user.includes(W)?(this.isRegisteredInner=!1,this.isConnectedInner=!1,this.startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:v,cause:a.C.causes.REJECTED})},h)):!this.isRegistered()&&t===!0&&(e===d||e===T)?(this.isRegisteredInner=!0,this.startedTimeout=setTimeout(()=>{this.trigger("registered",{response:P})},h)):t===!0&&e!==d&&e!==T&&(this.isRegisteredInner=!1,this.isConnectedInner=!1,this.startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:v,cause:a.C.causes.REJECTED})},h)),i.isAvailableTelephony?(this.trigger("connected",{socket:g}),this.isConnectedInner=!0):this.stop()}unregister(){this.isRegisteredInner=!1,this.isConnectedInner=!1,this.trigger("unregistered",{response:P})}isRegistered(){return this.isRegisteredInner===!0}isConnected(){return this.isConnectedInner===!0}isStarted(){return this.configuration.register===!0&&this.isRegisteredInner===!0||this.configuration.register!==!0&&this.isConnectedInner===!0}newSipEvent(e){this.trigger("sipEvent",e)}registrator(){return this.registratorInner}}class ut{url;constructor(e){this.url=e}}class mt extends V.EventEmitter{contentType;body;constructor(e,t){super(),this.contentType=e,this.body=t}}const I="remote",lt=(o,e)=>{const t=new N(e),r={originator:I,request:t,info:new mt("","")};o.newInfo(r)},pt=(o,e)=>{const r={event:"sipEvent",request:new N(e)};o.newSipEvent(r)},gt=(o,{incomingNumber:e="1234",displayName:t,host:r})=>{const n=new s({originator:I,eventHandlers:{}}),c=new H("sip",e,r);n.remote_identity=new U(c,t);const p=new N([]);o.trigger("newRTCSession",{originator:I,session:n,request:p})},_t=(o,e)=>{e?o.trigger("failed",e):o.trigger("failed",o)},w={triggerNewInfo:lt,triggerNewSipEvent:pt,triggerIncomingSession:gt,triggerFailIncomingSession:_t,WebSocketInterface:ut,UA:i,C:{INVITE:"INVITE"}},u="user",E="displayName",m="SIP_SERVER_URL",C="SIP_WEB_SOCKET_SERVER_URL",Tt=new w.WebSocketInterface(C),R={displayName:"DISPLAY_NAME",userAgent:"Chrome",sipServerUrl:m,sipWebSocketServerURL:C},It={...R,displayName:"DISPLAY_NAME",register:!1},b={...R,user:u,password:d,register:!0},St={...b,displayName:E},Nt={...R,displayName:E,register:!1},l={session_timers:!1,sockets:[Tt],user_agent:"Chrome",sdpSemantics:"unified-plan",register_expires:300,connection_recovery_max_interval:6,connection_recovery_min_interval:2},wt={...l,password:d,uri:new a.URI("sip",u,m),display_name:"DISPLAY_NAME",register:!0},Ct={...l,password:d,uri:new a.URI("sip",u,m),display_name:E,register:!0},Rt={...l,display_name:E,register:!1},ft={...l,display_name:"DISPLAY_NAME",register:!1},k="10.10.10.10",At=[`X-Vinteo-Remote: ${k}`],Mt=()=>new D.SipConnector({JsSIP:w});exports.FAILED_CONFERENCE_NUMBER=F;exports.JsSIP=w;exports.NAME_INCORRECT=W;exports.PASSWORD_CORRECT=d;exports.PASSWORD_CORRECT_2=T;exports.SIP_SERVER_URL=m;exports.SIP_WEB_SOCKET_SERVER_URL=C;exports.dataForConnectionWithAuthorization=b;exports.dataForConnectionWithAuthorizationWithDisplayName=St;exports.dataForConnectionWithoutAuthorization=Nt;exports.dataForConnectionWithoutAuthorizationWithoutDisplayName=It;exports.displayName=E;exports.doMockSipConnector=Mt;exports.extraHeadersRemoteAddress=At;exports.remoteAddress=k;exports.uaConfigurationWithAuthorization=wt;exports.uaConfigurationWithAuthorizationWithDisplayName=Ct;exports.uaConfigurationWithoutAuthorization=Rt;exports.uaConfigurationWithoutAuthorizationWithoutDisplayName=ft;exports.user=u;
package/dist/doMock.js CHANGED
@@ -4,9 +4,9 @@ import b from "@krivega/jssip/lib/URI";
4
4
  import { IncomingRequest as k } from "@krivega/jssip/lib/SIPMessage";
5
5
  import { NameAddrHeader as V, URI as E, SessionStatus as W, C as N } from "@krivega/jssip";
6
6
  import { createAudioMediaStreamTrackMock as U, createVideoMediaStreamTrackMock as G } from "webrtc-mock";
7
- import { Events as T } from "events-constructor";
8
- import { O as H, S as x } from "./@SipConnector-CM9pBA-c.js";
9
- class _ extends k {
7
+ import { Events as _ } from "events-constructor";
8
+ import { O as H, S as x } from "./@SipConnector-DXMX6l2G.js";
9
+ class T extends k {
10
10
  headers;
11
11
  constructor(e) {
12
12
  super(), this.headers = new Headers(e);
@@ -15,24 +15,24 @@ class _ extends k {
15
15
  return this.headers.get(e) ?? "";
16
16
  }
17
17
  }
18
- const j = "incomingCall", q = "declinedIncomingCall", Y = "failedIncomingCall", z = "terminatedIncomingCall", v = "connecting", B = "connected", K = "disconnected", $ = "newRTCSession", J = "registered", Q = "unregistered", X = "registrationFailed", Z = "newMessage", ee = "sipEvent", te = "availableSecondRemoteStream", re = "notAvailableSecondRemoteStream", ne = "mustStopPresentation", oe = "shareState", se = "enterRoom", ie = "useLicense", ae = "peerconnection:confirmed", ce = "peerconnection:ontrack", de = "channels", Ee = "channels:notify", he = "ended:fromserver", me = "main-cam-control", ue = "admin-stop-main-cam", le = "admin-start-main-cam", pe = "admin-stop-mic", ge = "admin-start-mic", Te = "admin-force-sync-media-state", _e = "participant:added-to-list-moderators", Ie = "participant:removed-from-list-moderators", Se = "participant:move-request-to-stream", we = "participant:move-request-to-spectators", Ne = "participant:move-request-to-participants", fe = "participation:accepting-word-request", Ce = "participation:cancelling-word-request", Re = "webcast:started", Me = "webcast:stopped", Ae = "account:changed", Oe = "account:deleted", ve = "conference:participant-token-issued", Pe = "ended", De = "sending", ye = "reinvite", Le = "replaces", Fe = "refer", be = "progress", ke = "accepted", Ve = "confirmed", We = "peerconnection", Ue = "failed", Ge = "muted", He = "unmuted", xe = "newDTMF", je = "newInfo", qe = "hold", Ye = "unhold", ze = "update", Be = "sdp", Ke = "icecandidate", $e = "getusermediafailed", Je = "peerconnection:createofferfailed", Qe = "peerconnection:createanswerfailed", Xe = "peerconnection:setlocaldescriptionfailed", Ze = "peerconnection:setremotedescriptionfailed", et = "presentation:start", tt = "presentation:started", rt = "presentation:end", nt = "presentation:ended", ot = "presentation:failed", st = [
18
+ const Y = "incomingCall", j = "declinedIncomingCall", q = "failedIncomingCall", z = "terminatedIncomingCall", P = "connecting", B = "connected", K = "disconnected", $ = "newRTCSession", J = "registered", Q = "unregistered", X = "registrationFailed", Z = "newMessage", ee = "sipEvent", te = "availableSecondRemoteStream", re = "notAvailableSecondRemoteStream", ne = "mustStopPresentation", oe = "shareState", se = "enterRoom", ie = "useLicense", ae = "peerconnection:confirmed", ce = "peerconnection:ontrack", de = "channels", Ee = "channels:notify", he = "ended:fromserver", me = "main-cam-control", ue = "admin-stop-main-cam", le = "admin-start-main-cam", pe = "admin-stop-mic", ge = "admin-start-mic", _e = "admin-force-sync-media-state", Te = "participant:added-to-list-moderators", Ie = "participant:removed-from-list-moderators", Se = "participant:move-request-to-stream", we = "participant:move-request-to-spectators", Ne = "participant:move-request-to-participants", fe = "participation:accepting-word-request", Ce = "participation:cancelling-word-request", Re = "webcast:started", Ae = "webcast:stopped", Me = "account:changed", Oe = "account:deleted", Pe = "conference:participant-token-issued", ve = "ended", De = "sending", ye = "reinvite", Le = "replaces", Fe = "refer", be = "progress", ke = "accepted", Ve = "confirmed", We = "peerconnection", Ue = "failed", Ge = "muted", He = "unmuted", xe = "newDTMF", Ye = "newInfo", je = "hold", qe = "unhold", ze = "update", Be = "sdp", Ke = "icecandidate", $e = "getusermediafailed", Je = "peerconnection:createofferfailed", Qe = "peerconnection:createanswerfailed", Xe = "peerconnection:setlocaldescriptionfailed", Ze = "peerconnection:setremotedescriptionfailed", et = "presentation:start", tt = "presentation:started", rt = "presentation:end", nt = "presentation:ended", ot = "presentation:failed", st = [
19
+ Y,
19
20
  j,
20
- q,
21
21
  z,
22
- Y,
22
+ q,
23
23
  fe,
24
24
  Ce,
25
25
  Se,
26
26
  Ee,
27
- ve,
28
- Ae,
27
+ Pe,
28
+ Me,
29
29
  Oe,
30
30
  Re,
31
- Me,
32
- _e,
31
+ Ae,
32
+ Te,
33
33
  Ie
34
- ], P = [
35
- v,
34
+ ], v = [
35
+ P,
36
36
  B,
37
37
  K,
38
38
  $,
@@ -57,12 +57,12 @@ const j = "incomingCall", q = "declinedIncomingCall", Y = "failedIncomingCall",
57
57
  ue,
58
58
  pe,
59
59
  ge,
60
- Te,
60
+ _e,
61
61
  we,
62
62
  Ne
63
63
  ], p = [
64
- Pe,
65
- v,
64
+ ve,
65
+ P,
66
66
  De,
67
67
  ye,
68
68
  Le,
@@ -75,9 +75,9 @@ const j = "incomingCall", q = "declinedIncomingCall", Y = "failedIncomingCall",
75
75
  Ge,
76
76
  He,
77
77
  xe,
78
+ Ye,
78
79
  je,
79
80
  qe,
80
- Ye,
81
81
  ze,
82
82
  Be,
83
83
  Ke,
@@ -92,7 +92,7 @@ const j = "incomingCall", q = "declinedIncomingCall", Y = "failedIncomingCall",
92
92
  nt,
93
93
  ot
94
94
  ];
95
- [...P, ...st];
95
+ [...v, ...st];
96
96
  [
97
97
  ...p,
98
98
  ...it
@@ -108,7 +108,7 @@ class at {
108
108
  eventHandlers: t,
109
109
  remoteIdentity: r
110
110
  }) {
111
- this.originator = e, this.events = new T(p), this.initEvents(t), this.remote_identity = r;
111
+ this.originator = e, this.events = new _(p), this.initEvents(t), this.remote_identity = r;
112
112
  }
113
113
  get contact() {
114
114
  throw new Error("Method not implemented.");
@@ -361,7 +361,7 @@ class dt {
361
361
  signalingState;
362
362
  events;
363
363
  constructor(e, t) {
364
- this.events = new T(ct), this.receivers = t.map((r) => ({ track: r }));
364
+ this.events = new _(ct), this.receivers = t.map((r) => ({ track: r }));
365
365
  }
366
366
  getRemoteStreams() {
367
367
  throw new Error("Method not implemented.");
@@ -629,11 +629,11 @@ class ut {
629
629
  setExtraContactParams() {
630
630
  }
631
631
  }
632
- const c = "PASSWORD_CORRECT", M = "PASSWORD_CORRECT_2", lt = "NAME_INCORRECT", d = 400, l = {
632
+ const c = "PASSWORD_CORRECT", A = "PASSWORD_CORRECT_2", lt = "NAME_INCORRECT", d = 400, l = {
633
633
  url: "wss://sipServerUrl/webrtc/wss/",
634
634
  sip_uri: "sip:sipServerUrl;transport=ws",
635
635
  via_transport: "WSS"
636
- }, A = {
636
+ }, M = {
637
637
  status_code: 200,
638
638
  reason_phrase: "OK"
639
639
  }, O = {
@@ -686,7 +686,7 @@ class s {
686
686
  isConnectedInner;
687
687
  configuration;
688
688
  constructor(e) {
689
- this.events = new T(P);
689
+ this.events = new _(v);
690
690
  const [t, r] = e.uri.split(":"), [n, a] = r.split("@"), u = {
691
691
  ...e,
692
692
  uri: new E(t, n, a)
@@ -738,9 +738,9 @@ class s {
738
738
  const { password: e, register: t, uri: r } = this.configuration;
739
739
  t === !0 && r.user.includes(lt) ? (this.isRegisteredInner = !1, this.isConnectedInner = !1, this.startedTimeout = setTimeout(() => {
740
740
  this.trigger("registrationFailed", { response: O, cause: N.causes.REJECTED });
741
- }, d)) : !this.isRegistered() && t === !0 && (e === c || e === M) ? (this.isRegisteredInner = !0, this.startedTimeout = setTimeout(() => {
742
- this.trigger("registered", { response: A });
743
- }, d)) : t === !0 && e !== c && e !== M && (this.isRegisteredInner = !1, this.isConnectedInner = !1, this.startedTimeout = setTimeout(() => {
741
+ }, d)) : !this.isRegistered() && t === !0 && (e === c || e === A) ? (this.isRegisteredInner = !0, this.startedTimeout = setTimeout(() => {
742
+ this.trigger("registered", { response: M });
743
+ }, d)) : t === !0 && e !== c && e !== A && (this.isRegisteredInner = !1, this.isConnectedInner = !1, this.startedTimeout = setTimeout(() => {
744
744
  this.trigger("registrationFailed", { response: O, cause: N.causes.REJECTED });
745
745
  }, d)), s.isAvailableTelephony ? (this.trigger("connected", { socket: l }), this.isConnectedInner = !0) : this.stop();
746
746
  }
@@ -750,7 +750,7 @@ class s {
750
750
  * @returns {undefined}
751
751
  */
752
752
  unregister() {
753
- this.isRegisteredInner = !1, this.isConnectedInner = !1, this.trigger("unregistered", { response: A });
753
+ this.isRegisteredInner = !1, this.isConnectedInner = !1, this.trigger("unregistered", { response: M });
754
754
  }
755
755
  isRegistered() {
756
756
  return this.isRegisteredInner === !0;
@@ -786,15 +786,15 @@ class gt extends L {
786
786
  super(), this.contentType = e, this.body = t;
787
787
  }
788
788
  }
789
- const g = "remote", Tt = (o, e) => {
790
- const t = new _(e), r = {
789
+ const g = "remote", _t = (o, e) => {
790
+ const t = new T(e), r = {
791
791
  originator: g,
792
792
  request: t,
793
793
  info: new gt("", "")
794
794
  };
795
795
  o.newInfo(r);
796
- }, _t = (o, e) => {
797
- const r = { event: "sipEvent", request: new _(e) };
796
+ }, Tt = (o, e) => {
797
+ const r = { event: "sipEvent", request: new T(e) };
798
798
  o.newSipEvent(r);
799
799
  }, It = (o, {
800
800
  incomingNumber: e = "1234",
@@ -803,7 +803,7 @@ const g = "remote", Tt = (o, e) => {
803
803
  }) => {
804
804
  const n = new i({ originator: g, eventHandlers: {} }), a = new b("sip", e, r);
805
805
  n.remote_identity = new F(a, t);
806
- const u = new _([]);
806
+ const u = new T([]);
807
807
  o.trigger("newRTCSession", {
808
808
  originator: g,
809
809
  session: n,
@@ -812,8 +812,8 @@ const g = "remote", Tt = (o, e) => {
812
812
  }, St = (o, e) => {
813
813
  e ? o.trigger("failed", e) : o.trigger("failed", o);
814
814
  }, D = {
815
- triggerNewInfo: Tt,
816
- triggerNewSipEvent: _t,
815
+ triggerNewInfo: _t,
816
+ triggerNewSipEvent: Tt,
817
817
  triggerIncomingSession: It,
818
818
  triggerFailIncomingSession: St,
819
819
  WebSocketInterface: pt,
@@ -822,11 +822,14 @@ const g = "remote", Tt = (o, e) => {
822
822
  INVITE: "INVITE"
823
823
  }
824
824
  }, I = "user", h = "displayName", S = "SIP_SERVER_URL", y = "SIP_WEB_SOCKET_SERVER_URL", wt = new D.WebSocketInterface(y), w = {
825
+ displayName: "DISPLAY_NAME",
825
826
  userAgent: "Chrome",
826
827
  sipServerUrl: S,
827
828
  sipWebSocketServerURL: y
828
829
  }, yt = {
829
- ...w
830
+ ...w,
831
+ displayName: "DISPLAY_NAME",
832
+ register: !1
830
833
  }, Nt = {
831
834
  ...w,
832
835
  user: I,
@@ -851,7 +854,7 @@ const g = "remote", Tt = (o, e) => {
851
854
  ...m,
852
855
  password: c,
853
856
  uri: new E("sip", I, S),
854
- display_name: "",
857
+ display_name: "DISPLAY_NAME",
855
858
  register: !0
856
859
  }, kt = {
857
860
  ...m,
@@ -865,7 +868,7 @@ const g = "remote", Tt = (o, e) => {
865
868
  register: !1
866
869
  }, Wt = {
867
870
  ...m,
868
- display_name: "",
871
+ display_name: "DISPLAY_NAME",
869
872
  register: !1
870
873
  }, ft = "10.10.10.10", Ut = [`X-Vinteo-Remote: ${ft}`], Gt = () => new x({
871
874
  JsSIP: D
@@ -875,7 +878,7 @@ export {
875
878
  D as JsSIP,
876
879
  lt as NAME_INCORRECT,
877
880
  c as PASSWORD_CORRECT,
878
- M as PASSWORD_CORRECT_2,
881
+ A as PASSWORD_CORRECT_2,
879
882
  S as SIP_SERVER_URL,
880
883
  y as SIP_WEB_SOCKET_SERVER_URL,
881
884
  Nt as dataForConnectionWithAuthorization,
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("events-constructor");const o=require("./@SipConnector-kXwCLeH0.cjs"),V=require("@krivega/cancelable-promise"),W=require("repeated-calls"),j=require("ts-debounce"),K=require("ua-parser-js"),X=require("sequent-promises"),Y=require("stack-promises"),G=n=>n instanceof Object&&("originator"in n||"cause"in n),J=n=>{if(V.isCanceledError(n))return!0;if(!G(n))return!1;const{originator:e,cause:t}=n;return typeof t=="string"?t===o.ECallCause.REQUEST_TIMEOUT||t===o.ECallCause.REJECTED||e==="local"&&(t===o.ECallCause.CANCELED||t===o.ECallCause.BYE):!1},z=()=>globalThis.process?.versions?.electron!==void 0,x=()=>{const n=new K.UAParser,{name:e}=n.getBrowser(),t=z();return{isChrome:e==="Chrome"||t}},A=n=>{const{url:e,cause:t}=n;let r=e;return(t===o.ECallCause.BAD_MEDIA_DESCRIPTION||t===o.ECallCause.NOT_FOUND)&&(r=`${n.message.to.uri.user}@${n.message.to.uri.host}`),r};var B=(n=>(n.CONNECT_SERVER_FAILED="CONNECT_SERVER_FAILED",n.WRONG_USER_OR_PASSWORD="WRONG_USER_OR_PASSWORD",n.BAD_MEDIA_ERROR="BAD_MEDIA_ERROR",n.NOT_FOUND_ERROR="NOT_FOUND_ERROR",n.WS_CONNECTION_FAILED="WS_CONNECTION_FAILED",n.CONNECT_SERVER_FAILED_BY_LINK="CONNECT_SERVER_FAILED_BY_LINK",n))(B||{});const Q=new Error("Unknown error"),Z=(n=Q)=>{const{cause:e,socket:t}=n;let r="CONNECT_SERVER_FAILED";switch(e){case"Forbidden":{r="WRONG_USER_OR_PASSWORD";break}case o.ECallCause.BAD_MEDIA_DESCRIPTION:{r="BAD_MEDIA_ERROR";break}case o.ECallCause.NOT_FOUND:{r="NOT_FOUND_ERROR";break}default:t!==void 0&&t._ws?.readyState===3?r="WS_CONNECTION_FAILED":A(n)!==void 0&&A(n)!==""&&(r="CONNECT_SERVER_FAILED_BY_LINK")}return r},ee=n=>{let e="";try{e=JSON.stringify(n)}catch(t){o.logger("failed to stringify message",t)}return e},ne=new Error("Unknown error"),te=(n=ne)=>{const{code:e,cause:t,message:r}=n,a=A(n),s={code:"",cause:"",message:""};return typeof r=="object"&&r!==null?s.message=ee(r):r&&(s.message=String(r)),a!==void 0&&a!==""&&(s.link=a),e!==void 0&&e!==""&&(s.code=e),t!==void 0&&t!==""&&(s.cause=t),s},oe=Object.freeze(Object.defineProperty({__proto__:null,EErrorTypes:B,getLinkError:A,getTypeFromError:Z,getValuesFromError:te},Symbol.toStringTag,{value:"Module"})),re=({sessionId:n,remoteAddress:e,isMutedAudio:t,isMutedVideo:r,isRegistered:a,isPresentationCall:s})=>{const c=[],l=t?"0":"1",d=r?"0":"1";return c.push(`X-Vinteo-Mic-State: ${l}`,`X-Vinteo-MainCam-State: ${d}`),(a===!1||a===void 0)&&c.push("X-Vinteo-Purgatory-Call: yes"),n!==void 0&&n!==""&&c.push(`X-Vinteo-Session: ${n}`),s===!0&&c.push("X-Vinteo-Presentation-Call: yes"),e!==void 0&&e!==""&&c.push(`X-Vinteo-Remote: ${e}`),c},se="[@*!|]",ae="_",ce=n=>{let e=n;return e=e.replaceAll(new RegExp(se,"g"),ae),e},ie=({appName:n,appVersion:e,browserName:t,browserVersion:r})=>{const s=`${ce(n)} ${e}`;return`ChromeNew - ${t===void 0?s:`${t} ${r}, ${s}`}`},le=({isUnifiedSdpSemantic:n,appVersion:e,browserName:t,browserVersion:r,appName:a})=>n?ie({appVersion:e,browserName:t,browserVersion:r,appName:a}):"Chrome",$="purgatory",D=n=>n===$,ue=n=>e=>[...e].map(r=>async()=>n(r)),de=async({accumulatedKeys:n,sendKey:e,canRunTask:t})=>{const a=ue(e)(n);return X.sequentPromises(a,t)},ge=n=>t=>(o.logger("onStartMainCam"),n.on("api:admin-start-main-cam",t)),Ce=n=>t=>(o.logger("onStartMic"),n.on("api:admin-start-mic",t)),Se=n=>t=>(o.logger("onStopMainCam"),n.on("api:admin-stop-main-cam",t)),me=n=>t=>(o.logger("onStopMic"),n.on("api:admin-stop-mic",t)),fe=({sipConnector:n})=>{const e=(u,C)=>({isSyncForced:g})=>{if(g===!0){u();return}C()},t=ge(n),r=Se(n),a=Ce(n),s=me(n);let c,l,d,h;const v=({onStartMainCamForced:u,onStartMainCamNotForced:C,onStopMainCamForced:g,onStopMainCamNotForced:m,onStartMicForced:p,onStartMicNotForced:R,onStopMicForced:y,onStopMicNotForced:E})=>{const b=e(u,C);c=t(b);const O=e(g,m);l=r(O);const _=e(p,R);d=a(_);const S=e(y,E);h=s(S)},P=()=>{c?.(),l?.(),d?.(),h?.()};return{start:u=>{v(u)},stop:()=>{P()}}},he=Object.freeze(Object.defineProperty({__proto__:null,PURGATORY_CONFERENCE_NUMBER:$,createSyncMediaState:fe,createUaParser:x,error:oe,getExtraHeaders:re,getUserAgent:le,hasPurgatory:D,prepareMediaStream:o.prepareMediaStream,sendDtmfAccumulated:de,setEncodingsToSender:o.setEncodingsToSender,setParametersToSender:o.setParametersToSender},Symbol.toStringTag,{value:"Module"})),pe=()=>x().isChrome,Re=n=>{if(!V.isCanceledError(n)&&!W.hasCanceledError(n)&&!o.hasNotReadyForConnectionError(n))throw n;return{configuration:void 0,isSuccessful:!1}},Ee=({kind:n,readyState:e})=>n==="video"&&e==="live",U=(n,e,{onEnterPurgatory:t,onEnterConference:r})=>{D(n)?t&&t():r&&r({isSuccessProgressCall:e})},k=(n,e)=>{n(),e&&e()},L=(n,e,t)=>{throw n&&n(),e(),t},be=new Set(["on","once","onceRace","wait","off","sendDTMF","hangUp","declineToIncomingCall","sendChannels","checkTelephony","waitChannels","ping","startAutoConnect","stopAutoConnect","connection","isConfigured","isRegistered"]);class ve{on;once;onceRace;wait;off;sendDTMF;hangUp;declineToIncomingCall;sendChannels;checkTelephony;waitChannels;ping;startAutoConnect;stopAutoConnect;connection;isConfigured;isRegistered;sipConnector;constructor(e){return this.sipConnector=e,new Proxy(this,{get:(t,r,a)=>{if(typeof r=="string"&&be.has(r)&&r in this.sipConnector){const c=Reflect.get(this.sipConnector,r,this.sipConnector);return typeof c=="function"?c.bind(this.sipConnector):c}const s=Reflect.get(t,r,a);return typeof s=="function"?s.bind(t):s}})}connectToServer=async(e,t)=>this.sipConnector.connect(e,t).then(r=>(o.logger("connectToServer then"),{configuration:r,isSuccessful:!0})).catch(async r=>(o.logger("connectToServer catch: error",r),Re(r)));callToServer=async e=>{const{conference:t,mediaStream:r,extraHeaders:a,iceServers:s,contentHint:c,degradationPreference:l,sendEncodings:d,offerToReceiveAudio:h,offerToReceiveVideo:v,directionVideo:P,directionAudio:N,setRemoteStreams:T,onBeforeProgressCall:u,onSuccessProgressCall:C,onEnterPurgatory:g,onEnterConference:m,onFailProgressCall:p,onFinishProgressCall:R,onEndedCall:y,onAddedTransceiver:E}=e,b=this.resolveHandleReadyRemoteStreamsDebounced({onReadyRemoteStreams:T}),O=this.resolveHandleReadyRemoteStreams({onReadyRemoteStreams:()=>{b().catch(o.logger)}});o.logger("callToServer",e);const _=async()=>(o.logger("startCall"),this.sipConnector.call({mediaStream:r,extraHeaders:a,iceServers:s,contentHint:c,offerToReceiveAudio:h,offerToReceiveVideo:v,directionVideo:P,directionAudio:N,degradationPreference:l,onAddedTransceiver:E,sendEncodings:d,number:t,ontrack:O}));let S=!1,f;const M=(o.logger("subscribeEnterConference: onEnterConference",m),this.sipConnector.on("api:enterRoom",({room:i})=>{o.logger("enterRoom",{_room:i,isSuccessProgressCall:S}),f=i,(g??m)&&U(f,S,{onEnterPurgatory:g,onEnterConference:m})})),F=i=>(o.logger("onSuccess"),S=!0,b().catch(o.logger),C&&C({isPurgatory:D(f)}),this.sipConnector.onceRace(["call:ended","call:failed"],()=>{k(M,y)}),i),w=i=>(o.logger("onFail"),L(p,M,i)),I=()=>{o.logger("onFinish"),R&&R()};return o.logger("onBeforeProgressCall"),u&&u(t),_().then(F).catch(i=>w(i)).finally(I)};disconnectFromServer=async()=>this.sipConnector.disconnect().then(()=>(o.logger("disconnectFromServer: then"),{isSuccessful:!0})).catch(e=>(o.logger("disconnectFromServer: catch",e),{isSuccessful:!1}));answerToIncomingCall=async e=>{const{mediaStream:t,extraHeaders:r,iceServers:a,contentHint:s,degradationPreference:c,sendEncodings:l,offerToReceiveAudio:d,offerToReceiveVideo:h,directionVideo:v,directionAudio:P,setRemoteStreams:N,onBeforeProgressCall:T,onSuccessProgressCall:u,onEnterPurgatory:C,onEnterConference:g,onFailProgressCall:m,onFinishProgressCall:p,onEndedCall:R,onAddedTransceiver:y}=e,E=this.resolveHandleReadyRemoteStreamsDebounced({onReadyRemoteStreams:N}),b=this.resolveHandleReadyRemoteStreams({onReadyRemoteStreams:()=>{E().catch(o.logger)}});o.logger("answerToIncomingCall",e);const O=async()=>this.sipConnector.answerToIncomingCall({mediaStream:t,extraHeaders:r,iceServers:a,contentHint:s,offerToReceiveAudio:d,offerToReceiveVideo:h,directionVideo:v,directionAudio:P,degradationPreference:c,onAddedTransceiver:y,sendEncodings:l,ontrack:b}),_=()=>{const{remoteCallerData:i}=this.sipConnector;return i.incomingNumber};let S=!1,f;const M=(o.logger("subscribeEnterConference: onEnterConference",g),this.sipConnector.on("api:enterRoom",i=>{o.logger("enterRoom",{_room:i,isSuccessProgressCall:S}),f=i,(C??g)&&U(f,S,{onEnterPurgatory:C,onEnterConference:g})})),F=i=>(o.logger("onSuccess"),S=!0,E().catch(o.logger),u&&u({isPurgatory:D(f)}),this.sipConnector.onceRace(["call:ended","call:failed"],()=>{k(M,R)}),i),w=i=>(o.logger("onFail"),L(m,M,i)),I=()=>{o.logger("onFinish"),p&&p()};if(o.logger("onBeforeProgressCall"),T){const i=_();T(i)}return O().then(F).catch(i=>w(i)).finally(I)};updatePresentation=async({mediaStream:e,isP2P:t,contentHint:r,degradationPreference:a,sendEncodings:s,onAddedTransceiver:c})=>(o.logger("updatePresentation"),this.sipConnector.updatePresentation(e,{isP2P:t,contentHint:r,degradationPreference:a,onAddedTransceiver:c,sendEncodings:s}));startPresentation=async({mediaStream:e,isP2P:t,contentHint:r,degradationPreference:a,sendEncodings:s,callLimit:c,onAddedTransceiver:l})=>(o.logger("startPresentation"),this.sipConnector.startPresentation(e,{isP2P:t,contentHint:r,callLimit:c,degradationPreference:a,onAddedTransceiver:l,sendEncodings:s}));stopShareSipConnector=async({isP2P:e=!1}={})=>(o.logger("stopShareSipConnector"),this.sipConnector.stopPresentation({isP2P:e}).catch(t=>{o.logger(t)}));sendRefusalToTurnOnMic=async()=>{o.logger("sendRefusalToTurnOnMic"),await this.sipConnector.sendRefusalToTurnOnMic().catch(e=>{o.logger("sendRefusalToTurnOnMic: error",e)})};sendRefusalToTurnOnCam=async()=>{o.logger("sendRefusalToTurnOnCam"),await this.sipConnector.sendRefusalToTurnOnCam().catch(e=>{o.logger("sendRefusalToTurnOnCam: error",e)})};sendMediaState=async({isEnabledCam:e,isEnabledMic:t})=>{o.logger("sendMediaState"),await this.sipConnector.sendMediaState({cam:e,mic:t})};replaceMediaStream=async(e,{deleteExisting:t,addMissing:r,forceRenegotiation:a,contentHint:s,degradationPreference:c,sendEncodings:l,onAddedTransceiver:d})=>(o.logger("replaceMediaStream"),this.sipConnector.replaceMediaStream(e,{deleteExisting:t,addMissing:r,forceRenegotiation:a,contentHint:s,degradationPreference:c,onAddedTransceiver:d,sendEncodings:l}));askPermissionToEnableCam=async()=>{o.logger("askPermissionToEnableCam"),await this.sipConnector.askPermissionToEnableCam()};resolveHandleReadyRemoteStreamsDebounced=({onReadyRemoteStreams:e})=>j.debounce(()=>{const t=this.sipConnector.getRemoteStreams();o.logger("remoteStreams",t),t&&e(t)},200);resolveHandleReadyRemoteStreams=({onReadyRemoteStreams:e})=>({track:t})=>{Ee(t)&&e()};getRemoteStreams=()=>(o.logger("getRemoteStreams"),this.sipConnector.getRemoteStreams());onUseLicense=e=>(o.logger("onUseLicense"),this.sipConnector.on("api:useLicense",e));onMustStopPresentation=e=>(o.logger("onMustStopPresentation"),this.sipConnector.on("api:mustStopPresentation",e));onMoveToSpectators=e=>(o.logger("onMoveToSpectators"),this.sipConnector.on("api:participant:move-request-to-spectators",e));onMoveToParticipants=e=>(o.logger("onMoveToParticipants"),this.sipConnector.on("api:participant:move-request-to-participants",e));onStats=e=>(o.logger("onStats"),this.sipConnector.on("stats:collected",e));offStats=e=>{o.logger("offStats"),this.sipConnector.off("stats:collected",e)}}var H=(n=>(n.VP8="video/VP8",n.VP9="video/VP9",n.H264="video/H264",n.AV1="video/AV1",n.rtx="video/rtx",n.red="video/red",n.flexfec03="video/flexfec-03",n))(H||{});exports.ECallCause=o.ECallCause;exports.EStatsTypes=o.EStatsTypes;exports.EUseLicense=o.EUseLicense;exports.SipConnector=o.SipConnector;exports.StatsPeerConnection=o.StatsPeerConnection;exports.disableDebug=o.disableDebug;exports.enableDebug=o.enableDebug;exports.getCodecFromSender=o.getCodecFromSender;exports.hasCanceledStartPresentationError=o.hasCanceledStartPresentationError;Object.defineProperty(exports,"hasConnectionPromiseIsNotActualError",{enumerable:!0,get:()=>Y.isPromiseIsNotActualError});exports.EMimeTypesVideoCodecs=H;exports.SipConnectorFacade=ve;exports.hasAvailableStats=pe;exports.hasCanceledCallError=J;exports.tools=he;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("events-constructor");const o=require("./@SipConnector-CMDm0Voo.cjs"),V=require("@krivega/cancelable-promise"),W=require("repeated-calls"),j=require("ts-debounce"),K=require("ua-parser-js"),X=require("sequent-promises"),Y=require("stack-promises"),G=n=>n instanceof Object&&("originator"in n||"cause"in n),J=n=>{if(V.isCanceledError(n))return!0;if(!G(n))return!1;const{originator:e,cause:t}=n;return typeof t=="string"?t===o.ECallCause.REQUEST_TIMEOUT||t===o.ECallCause.REJECTED||e==="local"&&(t===o.ECallCause.CANCELED||t===o.ECallCause.BYE):!1},z=()=>globalThis.process?.versions?.electron!==void 0,x=()=>{const n=new K.UAParser,{name:e}=n.getBrowser(),t=z();return{isChrome:e==="Chrome"||t}},A=n=>{const{url:e,cause:t}=n;let r=e;return(t===o.ECallCause.BAD_MEDIA_DESCRIPTION||t===o.ECallCause.NOT_FOUND)&&(r=`${n.message.to.uri.user}@${n.message.to.uri.host}`),r};var B=(n=>(n.CONNECT_SERVER_FAILED="CONNECT_SERVER_FAILED",n.WRONG_USER_OR_PASSWORD="WRONG_USER_OR_PASSWORD",n.BAD_MEDIA_ERROR="BAD_MEDIA_ERROR",n.NOT_FOUND_ERROR="NOT_FOUND_ERROR",n.WS_CONNECTION_FAILED="WS_CONNECTION_FAILED",n.CONNECT_SERVER_FAILED_BY_LINK="CONNECT_SERVER_FAILED_BY_LINK",n))(B||{});const Q=new Error("Unknown error"),Z=(n=Q)=>{const{cause:e,socket:t}=n;let r="CONNECT_SERVER_FAILED";switch(e){case"Forbidden":{r="WRONG_USER_OR_PASSWORD";break}case o.ECallCause.BAD_MEDIA_DESCRIPTION:{r="BAD_MEDIA_ERROR";break}case o.ECallCause.NOT_FOUND:{r="NOT_FOUND_ERROR";break}default:t!==void 0&&t._ws?.readyState===3?r="WS_CONNECTION_FAILED":A(n)!==void 0&&A(n)!==""&&(r="CONNECT_SERVER_FAILED_BY_LINK")}return r},ee=n=>{let e="";try{e=JSON.stringify(n)}catch(t){o.logger("failed to stringify message",t)}return e},ne=new Error("Unknown error"),te=(n=ne)=>{const{code:e,cause:t,message:r}=n,a=A(n),s={code:"",cause:"",message:""};return typeof r=="object"&&r!==null?s.message=ee(r):r&&(s.message=String(r)),a!==void 0&&a!==""&&(s.link=a),e!==void 0&&e!==""&&(s.code=e),t!==void 0&&t!==""&&(s.cause=t),s},oe=Object.freeze(Object.defineProperty({__proto__:null,EErrorTypes:B,getLinkError:A,getTypeFromError:Z,getValuesFromError:te},Symbol.toStringTag,{value:"Module"})),re=({sessionId:n,remoteAddress:e,isMutedAudio:t,isMutedVideo:r,isRegistered:a,isPresentationCall:s})=>{const c=[],l=t?"0":"1",d=r?"0":"1";return c.push(`X-Vinteo-Mic-State: ${l}`,`X-Vinteo-MainCam-State: ${d}`),(a===!1||a===void 0)&&c.push("X-Vinteo-Purgatory-Call: yes"),n!==void 0&&n!==""&&c.push(`X-Vinteo-Session: ${n}`),s===!0&&c.push("X-Vinteo-Presentation-Call: yes"),e!==void 0&&e!==""&&c.push(`X-Vinteo-Remote: ${e}`),c},se="[@*!|]",ae="_",ce=n=>{let e=n;return e=e.replaceAll(new RegExp(se,"g"),ae),e},ie=({appName:n,appVersion:e,browserName:t,browserVersion:r})=>{const s=`${ce(n)} ${e}`;return`ChromeNew - ${t===void 0?s:`${t} ${r}, ${s}`}`},le=({isUnifiedSdpSemantic:n,appVersion:e,browserName:t,browserVersion:r,appName:a})=>n?ie({appVersion:e,browserName:t,browserVersion:r,appName:a}):"Chrome",$="purgatory",D=n=>n===$,ue=n=>e=>[...e].map(r=>async()=>n(r)),de=async({accumulatedKeys:n,sendKey:e,canRunTask:t})=>{const a=ue(e)(n);return X.sequentPromises(a,t)},ge=n=>t=>(o.logger("onStartMainCam"),n.on("api:admin-start-main-cam",t)),Ce=n=>t=>(o.logger("onStartMic"),n.on("api:admin-start-mic",t)),Se=n=>t=>(o.logger("onStopMainCam"),n.on("api:admin-stop-main-cam",t)),me=n=>t=>(o.logger("onStopMic"),n.on("api:admin-stop-mic",t)),fe=({sipConnector:n})=>{const e=(u,C)=>({isSyncForced:g})=>{if(g===!0){u();return}C()},t=ge(n),r=Se(n),a=Ce(n),s=me(n);let c,l,d,h;const v=({onStartMainCamForced:u,onStartMainCamNotForced:C,onStopMainCamForced:g,onStopMainCamNotForced:m,onStartMicForced:p,onStartMicNotForced:R,onStopMicForced:y,onStopMicNotForced:E})=>{const b=e(u,C);c=t(b);const O=e(g,m);l=r(O);const _=e(p,R);d=a(_);const S=e(y,E);h=s(S)},P=()=>{c?.(),l?.(),d?.(),h?.()};return{start:u=>{v(u)},stop:()=>{P()}}},he=Object.freeze(Object.defineProperty({__proto__:null,PURGATORY_CONFERENCE_NUMBER:$,createSyncMediaState:fe,createUaParser:x,error:oe,getExtraHeaders:re,getUserAgent:le,hasPurgatory:D,prepareMediaStream:o.prepareMediaStream,sendDtmfAccumulated:de,setEncodingsToSender:o.setEncodingsToSender,setParametersToSender:o.setParametersToSender},Symbol.toStringTag,{value:"Module"})),pe=()=>x().isChrome,Re=n=>{if(!V.isCanceledError(n)&&!W.hasCanceledError(n)&&!o.hasNotReadyForConnectionError(n))throw n;return{configuration:void 0,isSuccessful:!1}},Ee=({kind:n,readyState:e})=>n==="video"&&e==="live",U=(n,e,{onEnterPurgatory:t,onEnterConference:r})=>{D(n)?t&&t():r&&r({isSuccessProgressCall:e})},k=(n,e)=>{n(),e&&e()},L=(n,e,t)=>{throw n&&n(),e(),t},be=new Set(["on","once","onceRace","wait","off","sendDTMF","hangUp","declineToIncomingCall","sendChannels","checkTelephony","waitChannels","ping","startAutoConnect","stopAutoConnect","connection","isConfigured","isRegistered"]);class ve{on;once;onceRace;wait;off;sendDTMF;hangUp;declineToIncomingCall;sendChannels;checkTelephony;waitChannels;ping;startAutoConnect;stopAutoConnect;connection;isConfigured;isRegistered;sipConnector;constructor(e){return this.sipConnector=e,new Proxy(this,{get:(t,r,a)=>{if(typeof r=="string"&&be.has(r)&&r in this.sipConnector){const c=Reflect.get(this.sipConnector,r,this.sipConnector);return typeof c=="function"?c.bind(this.sipConnector):c}const s=Reflect.get(t,r,a);return typeof s=="function"?s.bind(t):s}})}connectToServer=async(e,t)=>this.sipConnector.connect(e,t).then(r=>(o.logger("connectToServer then"),{configuration:r,isSuccessful:!0})).catch(async r=>(o.logger("connectToServer catch: error",r),Re(r)));callToServer=async e=>{const{conference:t,mediaStream:r,extraHeaders:a,iceServers:s,contentHint:c,degradationPreference:l,sendEncodings:d,offerToReceiveAudio:h,offerToReceiveVideo:v,directionVideo:P,directionAudio:N,setRemoteStreams:T,onBeforeProgressCall:u,onSuccessProgressCall:C,onEnterPurgatory:g,onEnterConference:m,onFailProgressCall:p,onFinishProgressCall:R,onEndedCall:y,onAddedTransceiver:E}=e,b=this.resolveHandleReadyRemoteStreamsDebounced({onReadyRemoteStreams:T}),O=this.resolveHandleReadyRemoteStreams({onReadyRemoteStreams:()=>{b().catch(o.logger)}});o.logger("callToServer",e);const _=async()=>(o.logger("startCall"),this.sipConnector.call({mediaStream:r,extraHeaders:a,iceServers:s,contentHint:c,offerToReceiveAudio:h,offerToReceiveVideo:v,directionVideo:P,directionAudio:N,degradationPreference:l,onAddedTransceiver:E,sendEncodings:d,number:t,ontrack:O}));let S=!1,f;const M=(o.logger("subscribeEnterConference: onEnterConference",m),this.sipConnector.on("api:enterRoom",({room:i})=>{o.logger("enterRoom",{_room:i,isSuccessProgressCall:S}),f=i,(g??m)&&U(f,S,{onEnterPurgatory:g,onEnterConference:m})})),F=i=>(o.logger("onSuccess"),S=!0,b().catch(o.logger),C&&C({isPurgatory:D(f)}),this.sipConnector.onceRace(["call:ended","call:failed"],()=>{k(M,y)}),i),w=i=>(o.logger("onFail"),L(p,M,i)),I=()=>{o.logger("onFinish"),R&&R()};return o.logger("onBeforeProgressCall"),u&&u(t),_().then(F).catch(i=>w(i)).finally(I)};disconnectFromServer=async()=>this.sipConnector.disconnect().then(()=>(o.logger("disconnectFromServer: then"),{isSuccessful:!0})).catch(e=>(o.logger("disconnectFromServer: catch",e),{isSuccessful:!1}));answerToIncomingCall=async e=>{const{mediaStream:t,extraHeaders:r,iceServers:a,contentHint:s,degradationPreference:c,sendEncodings:l,offerToReceiveAudio:d,offerToReceiveVideo:h,directionVideo:v,directionAudio:P,setRemoteStreams:N,onBeforeProgressCall:T,onSuccessProgressCall:u,onEnterPurgatory:C,onEnterConference:g,onFailProgressCall:m,onFinishProgressCall:p,onEndedCall:R,onAddedTransceiver:y}=e,E=this.resolveHandleReadyRemoteStreamsDebounced({onReadyRemoteStreams:N}),b=this.resolveHandleReadyRemoteStreams({onReadyRemoteStreams:()=>{E().catch(o.logger)}});o.logger("answerToIncomingCall",e);const O=async()=>this.sipConnector.answerToIncomingCall({mediaStream:t,extraHeaders:r,iceServers:a,contentHint:s,offerToReceiveAudio:d,offerToReceiveVideo:h,directionVideo:v,directionAudio:P,degradationPreference:c,onAddedTransceiver:y,sendEncodings:l,ontrack:b}),_=()=>{const{remoteCallerData:i}=this.sipConnector;return i.incomingNumber};let S=!1,f;const M=(o.logger("subscribeEnterConference: onEnterConference",g),this.sipConnector.on("api:enterRoom",i=>{o.logger("enterRoom",{_room:i,isSuccessProgressCall:S}),f=i,(C??g)&&U(f,S,{onEnterPurgatory:C,onEnterConference:g})})),F=i=>(o.logger("onSuccess"),S=!0,E().catch(o.logger),u&&u({isPurgatory:D(f)}),this.sipConnector.onceRace(["call:ended","call:failed"],()=>{k(M,R)}),i),w=i=>(o.logger("onFail"),L(m,M,i)),I=()=>{o.logger("onFinish"),p&&p()};if(o.logger("onBeforeProgressCall"),T){const i=_();T(i)}return O().then(F).catch(i=>w(i)).finally(I)};updatePresentation=async({mediaStream:e,isP2P:t,contentHint:r,degradationPreference:a,sendEncodings:s,onAddedTransceiver:c})=>(o.logger("updatePresentation"),this.sipConnector.updatePresentation(e,{isP2P:t,contentHint:r,degradationPreference:a,onAddedTransceiver:c,sendEncodings:s}));startPresentation=async({mediaStream:e,isP2P:t,contentHint:r,degradationPreference:a,sendEncodings:s,callLimit:c,onAddedTransceiver:l})=>(o.logger("startPresentation"),this.sipConnector.startPresentation(e,{isP2P:t,contentHint:r,callLimit:c,degradationPreference:a,onAddedTransceiver:l,sendEncodings:s}));stopShareSipConnector=async({isP2P:e=!1}={})=>(o.logger("stopShareSipConnector"),this.sipConnector.stopPresentation({isP2P:e}).catch(t=>{o.logger(t)}));sendRefusalToTurnOnMic=async()=>{o.logger("sendRefusalToTurnOnMic"),await this.sipConnector.sendRefusalToTurnOnMic().catch(e=>{o.logger("sendRefusalToTurnOnMic: error",e)})};sendRefusalToTurnOnCam=async()=>{o.logger("sendRefusalToTurnOnCam"),await this.sipConnector.sendRefusalToTurnOnCam().catch(e=>{o.logger("sendRefusalToTurnOnCam: error",e)})};sendMediaState=async({isEnabledCam:e,isEnabledMic:t})=>{o.logger("sendMediaState"),await this.sipConnector.sendMediaState({cam:e,mic:t})};replaceMediaStream=async(e,{deleteExisting:t,addMissing:r,forceRenegotiation:a,contentHint:s,degradationPreference:c,sendEncodings:l,onAddedTransceiver:d})=>(o.logger("replaceMediaStream"),this.sipConnector.replaceMediaStream(e,{deleteExisting:t,addMissing:r,forceRenegotiation:a,contentHint:s,degradationPreference:c,onAddedTransceiver:d,sendEncodings:l}));askPermissionToEnableCam=async()=>{o.logger("askPermissionToEnableCam"),await this.sipConnector.askPermissionToEnableCam()};resolveHandleReadyRemoteStreamsDebounced=({onReadyRemoteStreams:e})=>j.debounce(()=>{const t=this.sipConnector.getRemoteStreams();o.logger("remoteStreams",t),t&&e(t)},200);resolveHandleReadyRemoteStreams=({onReadyRemoteStreams:e})=>({track:t})=>{Ee(t)&&e()};getRemoteStreams=()=>(o.logger("getRemoteStreams"),this.sipConnector.getRemoteStreams());onUseLicense=e=>(o.logger("onUseLicense"),this.sipConnector.on("api:useLicense",e));onMustStopPresentation=e=>(o.logger("onMustStopPresentation"),this.sipConnector.on("api:mustStopPresentation",e));onMoveToSpectators=e=>(o.logger("onMoveToSpectators"),this.sipConnector.on("api:participant:move-request-to-spectators",e));onMoveToParticipants=e=>(o.logger("onMoveToParticipants"),this.sipConnector.on("api:participant:move-request-to-participants",e));onStats=e=>(o.logger("onStats"),this.sipConnector.on("stats:collected",e));offStats=e=>{o.logger("offStats"),this.sipConnector.off("stats:collected",e)}}var H=(n=>(n.VP8="video/VP8",n.VP9="video/VP9",n.H264="video/H264",n.AV1="video/AV1",n.rtx="video/rtx",n.red="video/red",n.flexfec03="video/flexfec-03",n))(H||{});exports.ECallCause=o.ECallCause;exports.EStatsTypes=o.EStatsTypes;exports.EUseLicense=o.EUseLicense;exports.SipConnector=o.SipConnector;exports.StatsPeerConnection=o.StatsPeerConnection;exports.disableDebug=o.disableDebug;exports.enableDebug=o.enableDebug;exports.getCodecFromSender=o.getCodecFromSender;exports.hasCanceledStartPresentationError=o.hasCanceledStartPresentationError;Object.defineProperty(exports,"hasConnectionPromiseIsNotActualError",{enumerable:!0,get:()=>Y.isPromiseIsNotActualError});exports.EMimeTypesVideoCodecs=H;exports.SipConnectorFacade=ve;exports.hasAvailableStats=pe;exports.hasCanceledCallError=J;exports.tools=he;