sip-connector 19.9.0 → 20.0.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.
Files changed (35) hide show
  1. package/README.md +131 -37
  2. package/dist/@SipConnector-CZiURTVf.cjs +1 -0
  3. package/dist/{@SipConnector-BpypVXj0.js → @SipConnector-D4DfiZRM.js} +860 -554
  4. package/dist/ApiManager/eventNames.d.ts +10 -3
  5. package/dist/CallManager/@CallManager.d.ts +18 -4
  6. package/dist/CallManager/MCUSession.d.ts +0 -1
  7. package/dist/CallManager/RecvSession.d.ts +1 -1
  8. package/dist/CallManager/RemoteStreamsManager.d.ts +20 -5
  9. package/dist/CallManager/RoleManager.d.ts +31 -0
  10. package/dist/CallManager/eventNames.d.ts +9 -2
  11. package/dist/CallManager/index.d.ts +1 -1
  12. package/dist/CallManager/types.d.ts +17 -5
  13. package/dist/ConnectionManager/@ConnectionManager.d.ts +2 -2
  14. package/dist/ConnectionManager/ConfigurationManager.d.ts +6 -1
  15. package/dist/ConnectionManager/ConnectionFlow.d.ts +5 -4
  16. package/dist/ConnectionManager/SipOperations.d.ts +2 -2
  17. package/dist/ConnectionManager/UAFactory.d.ts +4 -4
  18. package/dist/SipConnector/@SipConnector.d.ts +4 -2
  19. package/dist/SipConnector/eventNames.d.ts +1 -1
  20. package/dist/SipConnectorFacade/@SipConnectorFacade.d.ts +0 -2
  21. package/dist/VideoSendingBalancer/__fixtures__/createMockTrack.d.ts +1 -1
  22. package/dist/__fixtures__/RTCPeerConnectionMock.d.ts +1 -1
  23. package/dist/__fixtures__/index.d.ts +4 -4
  24. package/dist/doMock.cjs +1 -1
  25. package/dist/doMock.js +23 -21
  26. package/dist/index.cjs +1 -1
  27. package/dist/index.js +156 -171
  28. package/dist/tools/__fixtures__/connectToServer.d.ts +15 -15
  29. package/dist/tools/__fixtures__/permissions.d.ts +2 -2
  30. package/dist/tools/__fixtures__/processRequest.d.ts +2 -2
  31. package/dist/tools/index.d.ts +1 -0
  32. package/dist/tools/sendOffer.d.ts +39 -0
  33. package/dist/utils/utils.d.ts +1 -1
  34. package/package.json +4 -4
  35. package/dist/@SipConnector-CR3DyIpB.cjs +0 -1
@@ -7,6 +7,7 @@ export declare enum EEvent {
7
7
  PARTICIPANT_REMOVED_FROM_LIST_MODERATORS = "participant:removed-from-list-moderators",
8
8
  PARTICIPANT_MOVE_REQUEST_TO_STREAM = "participant:move-request-to-stream",
9
9
  PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS = "participant:move-request-to-spectators",
10
+ PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_SYNTHETIC = "participant:move-request-to-spectators-synthetic",
10
11
  PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_WITH_AUDIO_ID = "participant:move-request-to-spectators-with-audio-id",
11
12
  PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS = "participant:move-request-to-participants",
12
13
  PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request",
@@ -31,18 +32,24 @@ export declare enum EEvent {
31
32
  MUST_STOP_PRESENTATION = "mustStopPresentation",
32
33
  NEW_DTMF = "newDTMF"
33
34
  }
34
- export declare const EVENT_NAMES: readonly ["participation:accepting-word-request", "participation:cancelling-word-request", "participant:move-request-to-stream", "channels:notify", "conference:participant-token-issued", "account:changed", "account:deleted", "webcast:started", "webcast:stopped", "participant:added-to-list-moderators", "participant:removed-from-list-moderators", "participant:move-request-to-spectators", "participant:move-request-to-spectators-with-audio-id", "participant:move-request-to-participants", "channels", "enterRoom", "shareState", "main-cam-control", "useLicense", "admin-start-main-cam", "admin-stop-main-cam", "admin-start-mic", "admin-stop-mic", "admin-force-sync-media-state", "availableSecondRemoteStream", "notAvailableSecondRemoteStream", "mustStopPresentation", "newDTMF"];
35
+ export declare const EVENT_NAMES: readonly ["participation:accepting-word-request", "participation:cancelling-word-request", "participant:move-request-to-stream", "channels:notify", "conference:participant-token-issued", "account:changed", "account:deleted", "webcast:started", "webcast:stopped", "participant:added-to-list-moderators", "participant:removed-from-list-moderators", "participant:move-request-to-spectators", "participant:move-request-to-spectators-synthetic", "participant:move-request-to-spectators-with-audio-id", "participant:move-request-to-participants", "channels", "enterRoom", "shareState", "main-cam-control", "useLicense", "admin-start-main-cam", "admin-stop-main-cam", "admin-start-mic", "admin-stop-mic", "admin-force-sync-media-state", "availableSecondRemoteStream", "notAvailableSecondRemoteStream", "mustStopPresentation", "newDTMF"];
35
36
  export type TEvent = (typeof EVENT_NAMES)[number];
36
37
  export type TEventMap = {
37
38
  'channels:notify': TChannels;
38
39
  'participant:added-to-list-moderators': TParametersModeratorsList;
39
40
  'participant:removed-from-list-moderators': TParametersModeratorsList;
40
41
  'participant:move-request-to-stream': TParametersModeratorsList;
41
- 'participant:move-request-to-spectators': Record<string, never>;
42
+ 'participant:move-request-to-participants': Record<string, never>;
43
+ 'participant:move-request-to-spectators': {
44
+ isSynthetic: true;
45
+ } | {
46
+ isSynthetic: false;
47
+ audioId: string;
48
+ };
49
+ 'participant:move-request-to-spectators-synthetic': Record<string, never>;
42
50
  'participant:move-request-to-spectators-with-audio-id': {
43
51
  audioId: string;
44
52
  };
45
- 'participant:move-request-to-participants': Record<string, never>;
46
53
  'participation:accepting-word-request': TParametersModeratorsList;
47
54
  'participation:cancelling-word-request': TParametersModeratorsList;
48
55
  'webcast:started': TParametersWebcast;
@@ -1,15 +1,18 @@
1
1
  import { RTCSession } from '@krivega/jssip';
2
2
  import { TEvents, TEventMap } from './eventNames';
3
- import { TStartCall, TCallConfiguration, TReplaceMediaStream, TAnswerToIncomingCall } from './types';
3
+ import { TStartCall, TCallConfiguration, TReplaceMediaStream, TAnswerToIncomingCall, TCallRoleSpectator } from './types';
4
4
  declare class CallManager {
5
5
  readonly events: TEvents;
6
6
  protected isPendingCall: boolean;
7
7
  protected isPendingAnswer: boolean;
8
8
  protected rtcSession?: RTCSession;
9
- protected remoteStreams: Record<string, MediaStream>;
10
9
  protected readonly callConfiguration: TCallConfiguration;
11
- private readonly remoteStreamsManager;
10
+ private readonly mainRemoteStreamsManager;
11
+ private readonly recvRemoteStreamsManager;
12
+ private readonly roleManager;
12
13
  private readonly mcuSession;
14
+ private recvSession?;
15
+ private disposeRecvSessionTrackListener?;
13
16
  constructor();
14
17
  get requested(): boolean;
15
18
  get connection(): RTCPeerConnection | undefined;
@@ -28,7 +31,10 @@ declare class CallManager {
28
31
  answer?: boolean;
29
32
  number?: string;
30
33
  };
31
- getRemoteStreams(): MediaStream[] | undefined;
34
+ getRemoteStreams(): MediaStream[];
35
+ setCallRoleParticipant(): void;
36
+ setCallRoleSpectatorSynthetic(): void;
37
+ setCallRoleSpectator(recvParams: TCallRoleSpectator['recvParams']): void;
32
38
  replaceMediaStream(mediaStream: Parameters<TReplaceMediaStream>[0], options?: Parameters<TReplaceMediaStream>[1]): Promise<void>;
33
39
  restartIce(options?: {
34
40
  useUpdate?: boolean;
@@ -40,5 +46,13 @@ declare class CallManager {
40
46
  private readonly reset;
41
47
  private subscribeCallStatusChange;
42
48
  private maybeTriggerCallStatus;
49
+ private subscribeMcuRemoteTrackEvents;
50
+ private addRemoteTrack;
51
+ private emitRemoteStreamsChanged;
52
+ private getActiveStreamsManager;
53
+ private attachRecvSessionTracks;
54
+ private startRecvSession;
55
+ private stopRecvSession;
56
+ private readonly onRoleChanged;
43
57
  }
44
58
  export default CallManager;
@@ -15,7 +15,6 @@ export declare class MCUSession implements IMCUSession {
15
15
  startCall: IMCUSession['startCall'];
16
16
  endCall(): Promise<void>;
17
17
  answerToIncomingCall: IMCUSession['answerToIncomingCall'];
18
- getRemoteTracks(): MediaStreamTrack[] | undefined;
19
18
  replaceMediaStream(mediaStream: Parameters<IMCUSession['replaceMediaStream']>[0], options?: Parameters<IMCUSession['replaceMediaStream']>[1]): Promise<void>;
20
19
  restartIce(options?: {
21
20
  useUpdate?: boolean;
@@ -6,7 +6,7 @@ type TSendOfferParams = {
6
6
  type TConfig = Pick<TSendOfferParams, 'quality' | 'audioChannel'> & {
7
7
  pcConfig?: RTCConfiguration;
8
8
  };
9
- type TTools = {
9
+ export type TTools = {
10
10
  sendOffer: (params: TSendOfferParams & {
11
11
  conferenceNumber: TConferenceNumber;
12
12
  }, offer: RTCSessionDescriptionInit) => Promise<RTCSessionDescription>;
@@ -1,8 +1,23 @@
1
1
  export declare class RemoteStreamsManager {
2
- private remoteStreams;
2
+ private readonly participantGroups;
3
+ private readonly trackToGroup;
4
+ private readonly trackDisposers;
3
5
  reset(): void;
4
- generateStream(videoTrack: MediaStreamTrack, audioTrack?: MediaStreamTrack): MediaStream;
5
- generateAudioStream(audioTrack: MediaStreamTrack): MediaStream;
6
- generateStreams(remoteTracks: MediaStreamTrack[]): MediaStream[];
7
- generateAudioStreams(remoteTracks: MediaStreamTrack[]): MediaStream[];
6
+ addTrack(track: MediaStreamTrack, { onRemoved, streamHint, }?: {
7
+ streamHint?: string;
8
+ onRemoved?: ({ trackId, participantId }: {
9
+ trackId: string;
10
+ participantId: string;
11
+ }) => void;
12
+ }): {
13
+ isAdded: true;
14
+ participantId: string;
15
+ } | {
16
+ isAdded: false;
17
+ };
18
+ removeTrack(trackId: string): boolean;
19
+ removeStaleTracks(participantId: string, keepTrackIds: string[]): boolean;
20
+ getStreams(participantId?: string): MediaStream[];
21
+ private disposeTrackListener;
22
+ private getParticipantGroups;
8
23
  }
@@ -0,0 +1,31 @@
1
+ import { RemoteStreamsManager } from './RemoteStreamsManager';
2
+ import { TCallRole, TCallRoleParticipant, TCallRoleSpectatorSynthetic, TCallRoleSpectator } from './types';
3
+ type TOnRoleChanged = (params: {
4
+ previous: TCallRole;
5
+ next: TCallRole;
6
+ }) => void;
7
+ export declare class RoleManager {
8
+ private role;
9
+ private readonly mainManager;
10
+ private readonly recvManager;
11
+ private readonly onRoleChanged?;
12
+ constructor({ mainManager, recvManager, }: {
13
+ mainManager: RemoteStreamsManager;
14
+ recvManager: RemoteStreamsManager;
15
+ }, onRoleChanged?: TOnRoleChanged);
16
+ static hasParticipant(role: TCallRole): role is TCallRoleParticipant;
17
+ static hasSpectatorSynthetic(role: TCallRole): role is TCallRoleSpectatorSynthetic;
18
+ static hasSpectator(role: TCallRole): role is TCallRoleSpectator;
19
+ getRole(): TCallRole;
20
+ setCallRoleParticipant(): void;
21
+ setCallRoleSpectatorSynthetic(): void;
22
+ setCallRoleSpectator(recvParams: TCallRoleSpectator['recvParams']): void;
23
+ changeRole(next: TCallRole): void;
24
+ reset(): void;
25
+ getActiveManager(): RemoteStreamsManager;
26
+ hasParticipant(): boolean;
27
+ hasSpectatorSynthetic(): boolean;
28
+ hasSpectator(): boolean;
29
+ private setRole;
30
+ }
31
+ export {};
@@ -34,7 +34,8 @@ export declare enum EEvent {
34
34
  PEER_CONNECTION_CONFIRMED = "peerconnection:confirmed",
35
35
  PEER_CONNECTION_ONTRACK = "peerconnection:ontrack",
36
36
  ENDED_FROM_SERVER = "ended:fromserver",
37
- CALL_STATUS_CHANGED = "call-status-changed"
37
+ CALL_STATUS_CHANGED = "call-status-changed",
38
+ REMOTE_STREAMS_CHANGED = "remote-streams-changed"
38
39
  }
39
40
  export declare enum Originator {
40
41
  LOCAL = "local",
@@ -42,7 +43,7 @@ export declare enum Originator {
42
43
  SYSTEM = "system"
43
44
  }
44
45
  export declare const SESSION_JSSIP_EVENT_NAMES: readonly ["peerconnection", "connecting", "sending", "progress", "accepted", "confirmed", "ended", "failed", "newInfo", "newDTMF", "presentation:start", "presentation:started", "presentation:end", "presentation:ended", "presentation:failed", "reinvite", "update", "refer", "replaces", "sdp", "icecandidate", "getusermediafailed", "peerconnection:createofferfailed", "peerconnection:createanswerfailed", "peerconnection:setlocaldescriptionfailed", "peerconnection:setremotedescriptionfailed"];
45
- export declare const EVENT_NAMES: readonly ["peerconnection", "connecting", "sending", "progress", "accepted", "confirmed", "ended", "failed", "newInfo", "newDTMF", "presentation:start", "presentation:started", "presentation:end", "presentation:ended", "presentation:failed", "reinvite", "update", "refer", "replaces", "sdp", "icecandidate", "getusermediafailed", "peerconnection:createofferfailed", "peerconnection:createanswerfailed", "peerconnection:setlocaldescriptionfailed", "peerconnection:setremotedescriptionfailed", "peerconnection:confirmed", "peerconnection:ontrack", "ended:fromserver", "call-status-changed"];
46
+ export declare const EVENT_NAMES: readonly ["peerconnection", "connecting", "sending", "progress", "accepted", "confirmed", "ended", "failed", "newInfo", "newDTMF", "presentation:start", "presentation:started", "presentation:end", "presentation:ended", "presentation:failed", "reinvite", "update", "refer", "replaces", "sdp", "icecandidate", "getusermediafailed", "peerconnection:createofferfailed", "peerconnection:createanswerfailed", "peerconnection:setlocaldescriptionfailed", "peerconnection:setremotedescriptionfailed", "peerconnection:confirmed", "peerconnection:ontrack", "ended:fromserver", "call-status-changed", "remote-streams-changed"];
46
47
  export type TEvent = (typeof EVENT_NAMES)[number];
47
48
  export type TEventMap = {
48
49
  peerconnection: {
@@ -85,5 +86,11 @@ export type TEventMap = {
85
86
  'call-status-changed': {
86
87
  isCallActive: boolean;
87
88
  };
89
+ 'remote-streams-changed': {
90
+ participantId: string;
91
+ changeType: 'added' | 'removed';
92
+ trackId: string;
93
+ streams: MediaStream[];
94
+ };
88
95
  };
89
96
  export type TEvents = TypedEvents<TEventMap>;
@@ -4,4 +4,4 @@ export type { TEventMap } from './eventNames';
4
4
  export { EEvent as ECallEvent } from './eventNames';
5
5
  export type { TEvent as TCallEvent, TEvents as TCallEvents } from './eventNames';
6
6
  export { default as hasCanceledCallError } from './hasCanceledCallError';
7
- export type { TCustomError, TGetServerUrl } from './types';
7
+ export type { TCustomError, TGetUri } from './types';
@@ -1,16 +1,15 @@
1
1
  import { RTCSession, UA } from '@krivega/jssip';
2
2
  import { TContentHint } from '../PresentationManager';
3
3
  import { Originator } from './eventNames';
4
- export type TOntrack = (event: RTCTrackEvent) => void;
4
+ import { TTools } from './RecvSession';
5
5
  export type TOnAddedTransceiver = (transceiver: RTCRtpTransceiver, track: MediaStreamTrack, streams: MediaStream[]) => Promise<void>;
6
- export type TGetServerUrl = (id: string) => string;
6
+ export type TGetUri = (id: string) => string;
7
7
  type TOptionsExtraHeaders = {
8
8
  extraHeaders?: string[];
9
9
  };
10
10
  type TParamsAnswerToIncomingCall = {
11
11
  mediaStream: MediaStream;
12
12
  extraHeaders?: TOptionsExtraHeaders['extraHeaders'];
13
- ontrack?: TOntrack;
14
13
  iceServers?: RTCIceServer[];
15
14
  directionVideo?: RTCRtpTransceiverDirection;
16
15
  directionAudio?: RTCRtpTransceiverDirection;
@@ -37,7 +36,21 @@ export type TCallConfiguration = {
37
36
  answer?: boolean;
38
37
  number?: string;
39
38
  };
40
- export type TStartCall = (ua: UA, getSipServerUrl: TGetServerUrl, params: TParamsCall) => Promise<RTCPeerConnection>;
39
+ export type TCallRoleParticipant = {
40
+ type: 'participant';
41
+ };
42
+ export type TCallRoleSpectatorSynthetic = {
43
+ type: 'spectator_synthetic';
44
+ };
45
+ export type TCallRoleSpectator = {
46
+ type: 'spectator';
47
+ recvParams: {
48
+ audioId: string;
49
+ sendOffer: TTools['sendOffer'];
50
+ };
51
+ };
52
+ export type TCallRole = TCallRoleParticipant | TCallRoleSpectatorSynthetic | TCallRoleSpectator;
53
+ export type TStartCall = (ua: UA, getUri: TGetUri, params: TParamsCall) => Promise<RTCPeerConnection>;
41
54
  export type TReplaceMediaStream = (mediaStream: MediaStream, options?: {
42
55
  deleteExisting?: boolean;
43
56
  addMissing?: boolean;
@@ -55,7 +68,6 @@ export interface IMCUSession {
55
68
  startCall: TStartCall;
56
69
  endCall: () => Promise<void>;
57
70
  answerToIncomingCall: (incomingRTCSession: RTCSession, params: TParamsAnswerToIncomingCall) => Promise<RTCPeerConnection>;
58
- getRemoteTracks: () => MediaStreamTrack[] | undefined;
59
71
  replaceMediaStream: TReplaceMediaStream;
60
72
  restartIce: (options?: {
61
73
  useUpdate?: boolean;
@@ -1,6 +1,6 @@
1
1
  import { default as SipOperations, TParametersCheckTelephony } from './SipOperations';
2
2
  import { RegisteredEvent, UA, UnRegisteredEvent, WebSocketInterface } from '@krivega/jssip';
3
- import { TGetServerUrl } from '../CallManager';
3
+ import { TGetUri } from '../CallManager';
4
4
  import { TJsSIP } from '../types';
5
5
  import { TConnect, TConnectionConfigurationWithUa, TParametersConnection, TSet } from './ConnectionFlow';
6
6
  import { TEventMap, TEvents } from './eventNames';
@@ -48,7 +48,7 @@ export default class ConnectionManager {
48
48
  isConfigured(): boolean;
49
49
  getConnectionConfiguration: () => import('./ConfigurationManager').IConnectionConfiguration | undefined;
50
50
  destroy(): void;
51
- getSipServerUrl: TGetServerUrl;
51
+ getUri: TGetUri;
52
52
  readonly getUaProtected: () => UA;
53
53
  private readonly getUa;
54
54
  private readonly connectWithProcessError;
@@ -1,5 +1,6 @@
1
1
  import { UA } from '@krivega/jssip';
2
2
  export interface IConnectionConfiguration {
3
+ sipServerIp: string;
3
4
  sipServerUrl: string;
4
5
  displayName: string;
5
6
  register?: boolean;
@@ -38,7 +39,11 @@ export default class ConfigurationManager {
38
39
  */
39
40
  isRegister(): boolean;
40
41
  /**
41
- * Получает SIP сервер URL из конфигурации
42
+ * Получает SIP сервер IP из конфигурации
43
+ */
44
+ getSipServerIp(): string | undefined;
45
+ /**
46
+ * Получает SIP сервер URL (WebSocket) из конфигурации
42
47
  */
43
48
  getSipServerUrl(): string | undefined;
44
49
  /**
@@ -1,5 +1,5 @@
1
1
  import { UA, WebSocketInterface } from '@krivega/jssip';
2
- import { TGetServerUrl } from '../CallManager';
2
+ import { TGetUri } from '../CallManager';
3
3
  import { TJsSIP } from '../types';
4
4
  import { default as ConnectionStateMachine } from './ConnectionStateMachine';
5
5
  import { TEvents } from './eventNames';
@@ -9,8 +9,8 @@ export type TOptionsExtraHeaders = {
9
9
  extraHeaders?: string[];
10
10
  };
11
11
  export type TParametersConnection = TOptionsExtraHeaders & {
12
+ sipServerIp: string;
12
13
  sipServerUrl: string;
13
- sipWebSocketServerURL: string;
14
14
  displayName: string;
15
15
  register?: boolean;
16
16
  user?: string;
@@ -23,6 +23,7 @@ export type TParametersConnection = TOptionsExtraHeaders & {
23
23
  connectionRecoveryMaxInterval?: number;
24
24
  };
25
25
  export type TConnectionConfiguration = {
26
+ sipServerIp: string;
26
27
  sipServerUrl: string;
27
28
  displayName: string;
28
29
  register?: boolean;
@@ -49,7 +50,7 @@ interface IDependencies {
49
50
  getConnectionConfiguration: () => TConnectionConfiguration | undefined;
50
51
  setConnectionConfiguration: (config: TConnectionConfiguration | undefined) => void;
51
52
  updateConnectionConfiguration: <K extends keyof TConnectionConfiguration>(key: K, value: TConnectionConfiguration[K]) => void;
52
- setSipServerUrl: (getSipServerUrl: TGetServerUrl) => void;
53
+ setGetUri: (getUri: TGetUri) => void;
53
54
  setSocket: (socket: WebSocketInterface) => void;
54
55
  }
55
56
  export default class ConnectionFlow {
@@ -64,7 +65,7 @@ export default class ConnectionFlow {
64
65
  private readonly getConnectionConfiguration;
65
66
  private readonly setConnectionConfiguration;
66
67
  private readonly updateConnectionConfiguration;
67
- private readonly setSipServerUrl;
68
+ private readonly setGetUri;
68
69
  private readonly setSocket;
69
70
  constructor(dependencies: IDependencies);
70
71
  connect: TConnect;
@@ -2,8 +2,8 @@ import { UA, URI } from '@krivega/jssip';
2
2
  import { default as UAFactory } from './UAFactory';
3
3
  export type TParametersCheckTelephony = {
4
4
  displayName: string;
5
+ sipServerIp: string;
5
6
  sipServerUrl: string;
6
- sipWebSocketServerURL: string;
7
7
  userAgent?: string;
8
8
  remoteAddress?: string;
9
9
  extraHeaders?: string[];
@@ -27,6 +27,6 @@ export default class SipOperations {
27
27
  /**
28
28
  * Проверяет доступность телефонии, создавая временное соединение
29
29
  */
30
- checkTelephony({ userAgent, displayName, sipServerUrl, sipWebSocketServerURL, remoteAddress, extraHeaders, }: TParametersCheckTelephony): Promise<void>;
30
+ checkTelephony({ userAgent, displayName, sipServerIp, sipServerUrl, remoteAddress, extraHeaders, }: TParametersCheckTelephony): Promise<void>;
31
31
  }
32
32
  export {};
@@ -4,7 +4,7 @@ export type TUAConfiguration = {
4
4
  configuration: UAConfigurationParams;
5
5
  helpers: {
6
6
  socket: WebSocketInterface;
7
- getSipServerUrl: (id: string) => string;
7
+ getUri: (id: string) => string;
8
8
  };
9
9
  };
10
10
  export type TCreateUAParameters = UAConfigurationParams & {
@@ -12,9 +12,9 @@ export type TCreateUAParameters = UAConfigurationParams & {
12
12
  extraHeaders?: string[];
13
13
  };
14
14
  type TParametersCreateUaConfiguration = {
15
- sipWebSocketServerURL: string;
16
- displayName: string;
17
15
  sipServerUrl: string;
16
+ displayName: string;
17
+ sipServerIp: string;
18
18
  user?: string;
19
19
  register?: boolean;
20
20
  password?: string;
@@ -31,7 +31,7 @@ export default class UAFactory {
31
31
  private static validateParametersConnection;
32
32
  private static resolveAuthorizationUser;
33
33
  private static buildExtraHeaders;
34
- createConfiguration({ user, password, sipWebSocketServerURL, displayName, sipServerUrl, register, sessionTimers, registerExpires, // 5 minutes in sec
34
+ createConfiguration({ user, password, sipServerUrl, displayName, sipServerIp, register, sessionTimers, registerExpires, // 5 minutes in sec
35
35
  connectionRecoveryMinInterval, connectionRecoveryMaxInterval, userAgent, }: TParametersCreateUaConfiguration): TUAConfiguration;
36
36
  createUA({ remoteAddress, extraHeaders, ...parameters }: TCreateUAParameters): UA;
37
37
  /**
@@ -1,6 +1,6 @@
1
1
  import { ApiManager } from '../ApiManager';
2
2
  import { AutoConnectorManager, IAutoConnectorOptions } from '../AutoConnectorManager';
3
- import { CallManager, TGetServerUrl } from '../CallManager';
3
+ import { CallManager, TGetUri } from '../CallManager';
4
4
  import { ConnectionManager } from '../ConnectionManager';
5
5
  import { ConnectionQueueManager } from '../ConnectionQueueManager';
6
6
  import { IncomingCallManager } from '../IncomingCallManager';
@@ -59,7 +59,7 @@ declare class SipConnector {
59
59
  checkTelephony: ConnectionManager['checkTelephony'];
60
60
  isConfigured: () => boolean;
61
61
  getConnectionConfiguration: () => import('../ConnectionManager/ConfigurationManager').IConnectionConfiguration | undefined;
62
- getSipServerUrl: TGetServerUrl;
62
+ getUri: TGetUri;
63
63
  startAutoConnect: AutoConnectorManager['start'];
64
64
  stopAutoConnect: AutoConnectorManager['stop'];
65
65
  call: (params: Parameters<CallManager["startCall"]>[2]) => Promise<RTCPeerConnection>;
@@ -106,6 +106,8 @@ declare class SipConnector {
106
106
  askPermissionToStartPresentationP2P(...args: Parameters<ApiManager['askPermissionToStartPresentationP2P']>): Promise<void>;
107
107
  askPermissionToStartPresentation(...args: Parameters<ApiManager['askPermissionToStartPresentation']>): Promise<void>;
108
108
  askPermissionToEnableCam(...args: Parameters<ApiManager['askPermissionToEnableCam']>): Promise<void>;
109
+ private subscribeChangeRole;
110
+ private readonly sendOffer;
109
111
  private setCodecPreferences;
110
112
  private subscribe;
111
113
  private readonly bridgeEvents;
@@ -7,7 +7,7 @@ import { TEventMap as TIncomingCallManagerEventMap } from '../IncomingCallManage
7
7
  import { TEventMap as TPresentationManagerEventMap } from '../PresentationManager/eventNames';
8
8
  import { TEventMap as TStatsManagerEventMap } from '../StatsPeerConnection/eventNames';
9
9
  import { TEventMap as TVideoBalancerManagerEventMap } from '../VideoSendingBalancerManager/eventNames';
10
- export declare const EVENT_NAMES: readonly ("auto-connect:before-attempt" | "auto-connect:success" | "auto-connect:failed-all-attempts" | "auto-connect:cancelled-attempts" | "auto-connect:changed-attempt-status" | "auto-connect:stop-attempts-by-error" | "auto-connect:limit-reached-attempts" | "connection:connecting" | "connection:connected" | "connection:disconnected" | "connection:disconnecting" | "connection:newRTCSession" | "connection:registered" | "connection:unregistered" | "connection:registrationFailed" | "connection:newMessage" | "connection:sipEvent" | "connection:connect-started" | "connection:connect-succeeded" | "connection:connected-with-configuration" | "connection:connect-failed" | "connection:connect-parameters-resolve-success" | "connection:connect-parameters-resolve-failed" | "call:peerconnection" | "call:connecting" | "call:sending" | "call:progress" | "call:accepted" | "call:confirmed" | "call:ended" | "call:failed" | "call:newDTMF" | "call:newInfo" | "call:reinvite" | "call:update" | "call:refer" | "call:replaces" | "call:sdp" | "call:icecandidate" | "call:getusermediafailed" | "call:peerconnection:createofferfailed" | "call:peerconnection:createanswerfailed" | "call:peerconnection:setlocaldescriptionfailed" | "call:peerconnection:setremotedescriptionfailed" | "call:presentation:start" | "call:presentation:started" | "call:presentation:end" | "call:presentation:ended" | "call:presentation:failed" | "call:peerconnection:confirmed" | "call:peerconnection:ontrack" | "call:ended:fromserver" | "call:call-status-changed" | "api:channels:notify" | "api:participant:added-to-list-moderators" | "api:participant:removed-from-list-moderators" | "api:participant:move-request-to-stream" | "api:participant:move-request-to-spectators" | "api:participant:move-request-to-spectators-with-audio-id" | "api:participant:move-request-to-participants" | "api:participation:accepting-word-request" | "api:participation:cancelling-word-request" | "api:webcast:started" | "api:webcast:stopped" | "api:account:changed" | "api:account:deleted" | "api:conference:participant-token-issued" | "api:channels" | "api:enterRoom" | "api:shareState" | "api:main-cam-control" | "api:useLicense" | "api:admin-start-main-cam" | "api:admin-stop-main-cam" | "api:admin-start-mic" | "api:admin-stop-mic" | "api:admin-force-sync-media-state" | "api:availableSecondRemoteStream" | "api:notAvailableSecondRemoteStream" | "api:mustStopPresentation" | "api:newDTMF" | "incoming-call:incomingCall" | "incoming-call:declinedIncomingCall" | "incoming-call:terminatedIncomingCall" | "incoming-call:failedIncomingCall" | "presentation:presentation:start" | "presentation:presentation:started" | "presentation:presentation:end" | "presentation:presentation:ended" | "presentation:presentation:failed" | "stats:collected" | "video-balancer:balancing-scheduled" | "video-balancer:balancing-started" | "video-balancer:balancing-stopped" | "video-balancer:parameters-updated")[];
10
+ export declare const EVENT_NAMES: readonly ("auto-connect:before-attempt" | "auto-connect:success" | "auto-connect:failed-all-attempts" | "auto-connect:cancelled-attempts" | "auto-connect:changed-attempt-status" | "auto-connect:stop-attempts-by-error" | "auto-connect:limit-reached-attempts" | "connection:connecting" | "connection:connected" | "connection:disconnected" | "connection:disconnecting" | "connection:newRTCSession" | "connection:registered" | "connection:unregistered" | "connection:registrationFailed" | "connection:newMessage" | "connection:sipEvent" | "connection:connect-started" | "connection:connect-succeeded" | "connection:connected-with-configuration" | "connection:connect-failed" | "connection:connect-parameters-resolve-success" | "connection:connect-parameters-resolve-failed" | "call:peerconnection" | "call:connecting" | "call:sending" | "call:progress" | "call:accepted" | "call:confirmed" | "call:ended" | "call:failed" | "call:newDTMF" | "call:newInfo" | "call:reinvite" | "call:update" | "call:refer" | "call:replaces" | "call:sdp" | "call:icecandidate" | "call:getusermediafailed" | "call:peerconnection:createofferfailed" | "call:peerconnection:createanswerfailed" | "call:peerconnection:setlocaldescriptionfailed" | "call:peerconnection:setremotedescriptionfailed" | "call:presentation:start" | "call:presentation:started" | "call:presentation:end" | "call:presentation:ended" | "call:presentation:failed" | "call:peerconnection:confirmed" | "call:peerconnection:ontrack" | "call:ended:fromserver" | "call:call-status-changed" | "call:remote-streams-changed" | "api:channels:notify" | "api:participant:added-to-list-moderators" | "api:participant:removed-from-list-moderators" | "api:participant:move-request-to-stream" | "api:participant:move-request-to-participants" | "api:participant:move-request-to-spectators" | "api:participant:move-request-to-spectators-synthetic" | "api:participant:move-request-to-spectators-with-audio-id" | "api:participation:accepting-word-request" | "api:participation:cancelling-word-request" | "api:webcast:started" | "api:webcast:stopped" | "api:account:changed" | "api:account:deleted" | "api:conference:participant-token-issued" | "api:channels" | "api:enterRoom" | "api:shareState" | "api:main-cam-control" | "api:useLicense" | "api:admin-start-main-cam" | "api:admin-stop-main-cam" | "api:admin-start-mic" | "api:admin-stop-mic" | "api:admin-force-sync-media-state" | "api:availableSecondRemoteStream" | "api:notAvailableSecondRemoteStream" | "api:mustStopPresentation" | "api:newDTMF" | "incoming-call:incomingCall" | "incoming-call:declinedIncomingCall" | "incoming-call:terminatedIncomingCall" | "incoming-call:failedIncomingCall" | "presentation:presentation:start" | "presentation:presentation:started" | "presentation:presentation:end" | "presentation:presentation:ended" | "presentation:presentation:failed" | "stats:collected" | "video-balancer:balancing-scheduled" | "video-balancer:balancing-started" | "video-balancer:balancing-stopped" | "video-balancer:parameters-updated")[];
11
11
  export type TEvent = (typeof EVENT_NAMES)[number];
12
12
  type PrefixedEventMap<T extends Record<string, unknown>, Prefix extends string> = {
13
13
  [K in keyof T as `${Prefix}:${string & K}`]: T[K];
@@ -75,7 +75,6 @@ declare class SipConnectorFacade implements IProxyMethods {
75
75
  offerToReceiveVideo?: boolean;
76
76
  directionVideo?: RTCRtpTransceiverDirection;
77
77
  directionAudio?: RTCRtpTransceiverDirection;
78
- setRemoteStreams: (streams: MediaStream[]) => void;
79
78
  onBeforeProgressCall?: (conference: string) => void;
80
79
  onSuccessProgressCall?: (parameters_: {
81
80
  isPurgatory: boolean;
@@ -103,7 +102,6 @@ declare class SipConnectorFacade implements IProxyMethods {
103
102
  offerToReceiveVideo?: boolean;
104
103
  directionVideo?: RTCRtpTransceiverDirection;
105
104
  directionAudio?: RTCRtpTransceiverDirection;
106
- setRemoteStreams: (streams: MediaStream[]) => void;
107
105
  onBeforeProgressCall?: (conference: string) => void;
108
106
  onSuccessProgressCall?: (parameters_: {
109
107
  isPurgatory: boolean;
@@ -1,5 +1,5 @@
1
1
  declare const createMockTrack: (initialWidth: number) => {
2
- track: import('webrtc-mock').MediaStreamTrackMock<"video" | "audio">;
2
+ track: import('webrtc-mock').MediaStreamTrackMock<"audio" | "video">;
3
3
  setWidth: (newWidth: number) => void;
4
4
  };
5
5
  export default createMockTrack;
@@ -54,7 +54,7 @@ declare class RTCPeerConnectionMock extends EventTarget implements RTCPeerConnec
54
54
  setConfiguration(_configuration: RTCConfiguration): void;
55
55
  getReceivers: () => RTCRtpReceiver[];
56
56
  getSenders: () => RTCRtpSender[];
57
- addTrack: (track: MediaStreamTrack, ..._streams: MediaStream[]) => RTCRtpSenderMock;
57
+ addTrack: (track: MediaStreamTrack, ...streams: MediaStream[]) => RTCRtpSenderMock;
58
58
  addTrackWithMid: (track: MediaStreamTrack, mid?: string) => RTCRtpSenderMock;
59
59
  dispatchTrack(kind: 'audio' | 'video'): void;
60
60
  private dispatchTrackInternal;
@@ -7,8 +7,8 @@ export declare const dataForConnectionWithoutAuthorizationWithoutDisplayName: {
7
7
  displayName: string;
8
8
  register: boolean;
9
9
  userAgent: string;
10
+ sipServerIp: string;
10
11
  sipServerUrl: string;
11
- sipWebSocketServerURL: string;
12
12
  };
13
13
  export declare const dataForConnectionWithAuthorization: {
14
14
  user: string;
@@ -16,8 +16,8 @@ export declare const dataForConnectionWithAuthorization: {
16
16
  register: boolean;
17
17
  displayName: string;
18
18
  userAgent: string;
19
+ sipServerIp: string;
19
20
  sipServerUrl: string;
20
- sipWebSocketServerURL: string;
21
21
  };
22
22
  export declare const dataForConnectionWithAuthorizationWithDisplayName: {
23
23
  displayName: string;
@@ -25,15 +25,15 @@ export declare const dataForConnectionWithAuthorizationWithDisplayName: {
25
25
  password: string;
26
26
  register: boolean;
27
27
  userAgent: string;
28
+ sipServerIp: string;
28
29
  sipServerUrl: string;
29
- sipWebSocketServerURL: string;
30
30
  };
31
31
  export declare const dataForConnectionWithoutAuthorization: {
32
32
  displayName: string;
33
33
  register: boolean;
34
34
  userAgent: string;
35
+ sipServerIp: string;
35
36
  sipServerUrl: string;
36
- sipWebSocketServerURL: string;
37
37
  };
38
38
  export declare const uaConfigurationWithAuthorization: {
39
39
  password: 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"),j=require("@krivega/jssip/lib/URI"),H=require("@krivega/jssip/lib/SIPMessage"),a=require("@krivega/jssip"),_=require("webrtc-mock"),v=require("events-constructor"),D=require("./@SipConnector-CR3DyIpB.cjs");class N extends H.IncomingRequest{headers;constructor(e){super(),this.headers=new Headers(e)}getHeader(e){return this.headers.get(e)??""}}const q="incomingCall",G="declinedIncomingCall",x="failedIncomingCall",z="terminatedIncomingCall",y="connecting",Y="connected",B="disconnected",K="newRTCSession",J="registered",Q="unregistered",$="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",fe="webcast:started",Re="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",ke="accepted",We="confirmed",be="peerconnection",Ve="failed",Ue="muted",je="unmuted",He="newDTMF",qe="newInfo",Ge="hold",xe="unhold",ze="update",Ye="sdp",Be="icecandidate",Ke="getusermediafailed",Je="peerconnection:createofferfailed",Qe="peerconnection:createanswerfailed",$e="peerconnection:setlocaldescriptionfailed",Xe="peerconnection:setremotedescriptionfailed",Ze="presentation:start",et="presentation:started",tt="presentation:end",rt="presentation:ended",nt="presentation:failed",ot=[q,G,z,x,we,Ce,Ie,de,Oe,Ae,Me,fe,Re,_e,Te],L=[y,Y,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],T=[Pe,y,ve,De,ye,Le,Fe,ke,We,be,Ve,Ue,je,He,qe,Ge,xe,ze,Ye,Be,Ke,Je,Qe,$e,Xe,Ze,et,tt,rt,nt];[...L,...ot];[...T,...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 v.Events(T),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 T.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 R{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 A{currentDirection="sendrecv";direction="sendrecv";mid=null;receiver;sender;stopped=!1;constructor(e){this.sender=e}setCodecPreferences(e){}stop(){}}class at extends EventTarget{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;close=jest.fn();setLocalDescription=jest.fn(async e=>{});setRemoteDescription=jest.fn(async e=>{});addTransceiver=jest.fn((e,t)=>({}));createOffer=jest.fn(async(e,t,r)=>({type:"offer",sdp:"offer-sdp"}));constructor(e,t){super(),this.receivers=t?.map(r=>({track:r}))??[]}getRemoteStreams(){throw new Error("Method not implemented.")}async addIceCandidate(e){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.")}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.")}getReceivers=()=>this.receivers;getSenders=()=>this.senders;addTrack=(e,...t)=>{const r=new R({track:e}),o=new A(r);return o.mid=e.kind==="audio"?"0":"1",this.senders.push(r),this.dispatchTrackInternal(e),r};addTrackWithMid=(e,t)=>{const r=new R({track:e}),o=new A(r);return t===void 0?o.mid=e.kind==="audio"?"0":"1":o.mid=t,this.senders.push(r),this.dispatchTrackInternal(e),r};dispatchTrack(e){this.dispatchTrackInternal(new _.MediaStreamTrackMock(e))}dispatchTrackInternal(e){const t=new Event("track");Object.defineProperty(t,"track",{value:e}),this.dispatchEvent(t)}}function ct(n){const e=n.match(/(purgatory)|[\d.]+/g);if(!e)throw new Error("wrong sip url");return e[0]}const M=400,F="777",dt=n=>n.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)},M)});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:o=0}){super({originator:t,eventHandlers:e,remoteIdentity:r}),this.delayStartPresentation=o}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=_.createAudioMediaStreamTrackMock();t.id="mainaudio1";const r=[t];if(dt(e)){const c=_.createVideoMediaStreamTrackMock();c.id="mainvideo1",r.push(c)}this.connection=new at(void 0,r),this.addStream(e),this.trigger("peerconnection",{peerconnection:this.connection})}connect(e,{mediaStream:t}={}){const r=ct(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:o=>o==="content-type"?"application/vinteo.webrtc.roomname":o==="x-webrtc-enter-room"?r:o==="x-webrtc-participant-name"?"Test Caller 1":""}})},100),this.timeoutAccepted=setTimeout(()=>{this.trigger("accepted")},200),this.timeoutConfirmed=setTimeout(()=>{this.trigger("confirmed")},300))},M),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",I="PASSWORD_CORRECT_2",k="NAME_INCORRECT",h=400,g={url:"wss://sipServerUrl/webrtc/wss/",sip_uri:"sip:sipServerUrl;transport=ws",via_transport:"WSS"},O={status_code:200,reason_phrase:"OK"},P={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:o}=t;return this.session=new s({eventHandlers:o,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 v.Events(L);const[t,r]=e.uri.split(":"),[o,c]=r.split("@"),p={...e,uri:new a.URI(t,o,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(k)?(this.isRegisteredInner=!1,this.isConnectedInner=!1,this.startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:P,cause:a.C.causes.REJECTED})},h)):!this.isRegistered()&&t===!0&&(e===d||e===I)?(this.isRegisteredInner=!0,this.startedTimeout=setTimeout(()=>{this.trigger("registered",{response:O})},h)):t===!0&&e!==d&&e!==I&&(this.isRegisteredInner=!1,this.isConnectedInner=!1,this.startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:P,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:O})}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 ht{url;constructor(e){this.url=e}}class ut extends V.EventEmitter{contentType;body;constructor(e,t){super(),this.contentType=e,this.body=t}}const S="remote",mt=(n,e)=>{const t=new N(e),r={originator:S,request:t,info:new ut("","")};n.newInfo(r)},lt=(n,e)=>{const r={event:"sipEvent",request:new N(e)};n.newSipEvent(r)},pt=(n,{incomingNumber:e="1234",displayName:t,host:r})=>{const o=new s({originator:S,eventHandlers:{}}),c=new j("sip",e,r);o.remote_identity=new U(c,t);const p=new N([]);n.trigger("newRTCSession",{originator:S,session:o,request:p})},gt=(n,e)=>{e?n.trigger("failed",e):n.trigger("failed",n)},w={triggerNewInfo:mt,triggerNewSipEvent:lt,triggerIncomingSession:pt,triggerFailIncomingSession:gt,WebSocketInterface:ht,UA:i,C:{INVITE:"INVITE"}},u="user",E="displayName",m="SIP_SERVER_URL",C="SIP_WEB_SOCKET_SERVER_URL",_t=new w.WebSocketInterface(C),f={displayName:"DISPLAY_NAME",userAgent:"Chrome",sipServerUrl:m,sipWebSocketServerURL:C},Tt={...f,displayName:"DISPLAY_NAME",register:!1},W={...f,user:u,password:d,register:!0},It={...W,displayName:E},St={...f,displayName:E,register:!1},l={session_timers:!1,sockets:[_t],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:"DISPLAY_NAME",register:!0},wt={...l,password:d,uri:new a.URI("sip",u,m),display_name:E,register:!0},Ct={...l,display_name:E,register:!1},ft={...l,display_name:"DISPLAY_NAME",register:!1},b="10.10.10.10",Rt=[`X-Vinteo-Remote: ${b}`],At=()=>new D.SipConnector({JsSIP:w});exports.FAILED_CONFERENCE_NUMBER=F;exports.JsSIP=w;exports.NAME_INCORRECT=k;exports.PASSWORD_CORRECT=d;exports.PASSWORD_CORRECT_2=I;exports.SIP_SERVER_URL=m;exports.SIP_WEB_SOCKET_SERVER_URL=C;exports.dataForConnectionWithAuthorization=W;exports.dataForConnectionWithAuthorizationWithDisplayName=It;exports.dataForConnectionWithoutAuthorization=St;exports.dataForConnectionWithoutAuthorizationWithoutDisplayName=Tt;exports.displayName=E;exports.doMockSipConnector=At;exports.extraHeadersRemoteAddress=Rt;exports.remoteAddress=b;exports.uaConfigurationWithAuthorization=Nt;exports.uaConfigurationWithAuthorizationWithDisplayName=wt;exports.uaConfigurationWithoutAuthorization=Ct;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"),j=require("@krivega/jssip/lib/URI"),H=require("@krivega/jssip/lib/SIPMessage"),a=require("@krivega/jssip"),_=require("webrtc-mock"),v=require("events-constructor"),D=require("./@SipConnector-CZiURTVf.cjs");class N extends H.IncomingRequest{headers;constructor(e){super(),this.headers=new Headers(e)}getHeader(e){return this.headers.get(e)??""}}const q="incomingCall",G="declinedIncomingCall",x="failedIncomingCall",z="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",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",fe="webcast:started",Re="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",je="unmuted",He="newDTMF",qe="newInfo",Ge="hold",xe="unhold",ze="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=[q,G,z,x,we,Ce,Ie,de,Oe,Ae,Me,fe,Re,_e,Te],L=[y,Y,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],T=[Pe,y,ve,De,ye,Le,Fe,We,be,ke,Ve,Ue,je,He,qe,Ge,xe,ze,Ye,Be,Ke,Je,$e,Qe,Xe,Ze,et,tt,rt,nt];[...L,...ot];[...T,...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 v.Events(T),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 T.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 R{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 A{currentDirection="sendrecv";direction="sendrecv";mid=null;receiver;sender;stopped=!1;constructor(e){this.sender=e}setCodecPreferences(e){}stop(){}}class at extends EventTarget{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;close=jest.fn();setLocalDescription=jest.fn(async e=>{});setRemoteDescription=jest.fn(async e=>{});addTransceiver=jest.fn((e,t)=>({}));createOffer=jest.fn(async(e,t,r)=>({type:"offer",sdp:"offer-sdp"}));constructor(e,t){super(),this.receivers=t?.map(r=>({track:r}))??[]}getRemoteStreams(){throw new Error("Method not implemented.")}async addIceCandidate(e){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.")}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.")}getReceivers=()=>this.receivers;getSenders=()=>this.senders;addTrack=(e,...t)=>{const r=new R({track:e}),o=new A(r);return o.mid=e.kind==="audio"?"0":"1",this.senders.push(r),this.dispatchTrackInternal(e,...t),r};addTrackWithMid=(e,t)=>{const r=new R({track:e}),o=new A(r);return t===void 0?o.mid=e.kind==="audio"?"0":"1":o.mid=t,this.senders.push(r),this.dispatchTrackInternal(e),r};dispatchTrack(e){this.dispatchTrackInternal(new _.MediaStreamTrackMock(e))}dispatchTrackInternal(e,...t){const r=new Event("track");Object.defineProperty(r,"track",{value:e}),Object.defineProperty(r,"streams",{value:t.length===0?[new MediaStream([e])]:t}),this.dispatchEvent(r)}}function ct(n){const e=n.match(/(purgatory)|[\d.]+/g);if(!e)throw new Error("wrong sip url");return e[0]}const M=400,F="777",dt=n=>n.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)},M)});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:o=0}){super({originator:t,eventHandlers:e,remoteIdentity:r}),this.delayStartPresentation=o}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=_.createAudioMediaStreamTrackMock();t.id="mainaudio1";const r=[t];if(dt(e)){const c=_.createVideoMediaStreamTrackMock();c.id="mainvideo1",r.push(c)}this.connection=new at(void 0,r),this.trigger("peerconnection",{peerconnection:this.connection}),this.addStream(e)}connect(e,{mediaStream:t}={}){const r=ct(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:o=>o==="content-type"?"application/vinteo.webrtc.roomname":o==="x-webrtc-enter-room"?r:o==="x-webrtc-participant-name"?"Test Caller 1":""}})},100),this.timeoutAccepted=setTimeout(()=>{this.trigger("accepted")},200),this.timeoutConfirmed=setTimeout(()=>{this.trigger("confirmed")},300))},M),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,e))}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",I="PASSWORD_CORRECT_2",W="NAME_INCORRECT",h=400,g={url:"wss://sipServerUrl/webrtc/wss/",sip_uri:"sip:sipServerUrl;transport=ws",via_transport:"WSS"},O={status_code:200,reason_phrase:"OK"},P={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:o}=t;return this.session=new s({eventHandlers:o,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 v.Events(L);const[t,r]=e.uri.split(":"),[o,c]=r.split("@"),p={...e,uri:new a.URI(t,o,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:P,cause:a.C.causes.REJECTED})},h)):!this.isRegistered()&&t===!0&&(e===d||e===I)?(this.isRegisteredInner=!0,this.startedTimeout=setTimeout(()=>{this.trigger("registered",{response:O})},h)):t===!0&&e!==d&&e!==I&&(this.isRegisteredInner=!1,this.isConnectedInner=!1,this.startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:P,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:O})}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 ht{url;constructor(e){this.url=e}}class ut extends V.EventEmitter{contentType;body;constructor(e,t){super(),this.contentType=e,this.body=t}}const S="remote",mt=(n,e)=>{const t=new N(e),r={originator:S,request:t,info:new ut("","")};n.newInfo(r)},lt=(n,e)=>{const r={event:"sipEvent",request:new N(e)};n.newSipEvent(r)},pt=(n,{incomingNumber:e="1234",displayName:t,host:r})=>{const o=new s({originator:S,eventHandlers:{}}),c=new j("sip",e,r);o.remote_identity=new U(c,t);const p=new N([]);n.trigger("newRTCSession",{originator:S,session:o,request:p})},gt=(n,e)=>{e?n.trigger("failed",e):n.trigger("failed",n)},w={triggerNewInfo:mt,triggerNewSipEvent:lt,triggerIncomingSession:pt,triggerFailIncomingSession:gt,WebSocketInterface:ht,UA:i,C:{INVITE:"INVITE"}},u="user",E="displayName",m="SIP_SERVER_URL",C="SIP_WEB_SOCKET_SERVER_URL",_t=new w.WebSocketInterface(`wss://${C}/webrtc/wss/`),f={displayName:"DISPLAY_NAME",userAgent:"Chrome",sipServerIp:m,sipServerUrl:C},Tt={...f,displayName:"DISPLAY_NAME",register:!1},b={...f,user:u,password:d,register:!0},It={...b,displayName:E},St={...f,displayName:E,register:!1},l={session_timers:!1,sockets:[_t],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:"DISPLAY_NAME",register:!0},wt={...l,password:d,uri:new a.URI("sip",u,m),display_name:E,register:!0},Ct={...l,display_name:E,register:!1},ft={...l,display_name:"DISPLAY_NAME",register:!1},k="10.10.10.10",Rt=[`X-Vinteo-Remote: ${k}`],At=()=>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=I;exports.SIP_SERVER_URL=m;exports.SIP_WEB_SOCKET_SERVER_URL=C;exports.dataForConnectionWithAuthorization=b;exports.dataForConnectionWithAuthorizationWithDisplayName=It;exports.dataForConnectionWithoutAuthorization=St;exports.dataForConnectionWithoutAuthorizationWithoutDisplayName=Tt;exports.displayName=E;exports.doMockSipConnector=At;exports.extraHeadersRemoteAddress=Rt;exports.remoteAddress=k;exports.uaConfigurationWithAuthorization=Nt;exports.uaConfigurationWithAuthorizationWithDisplayName=wt;exports.uaConfigurationWithoutAuthorization=Ct;exports.uaConfigurationWithoutAuthorizationWithoutDisplayName=ft;exports.user=u;