sip-connector 20.4.0 → 20.5.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 (48) hide show
  1. package/README.md +18 -1264
  2. package/dist/{@SipConnector-FYEV5h4G.js → @SipConnector-DoyWexFp.js} +758 -719
  3. package/dist/@SipConnector-TNDGO7MW.cjs +1 -0
  4. package/dist/ApiManager/events.d.ts +0 -1
  5. package/dist/ApiManager/index.d.ts +2 -2
  6. package/dist/AutoConnectorManager/index.d.ts +2 -1
  7. package/dist/CallManager/@CallManager.d.ts +60 -0
  8. package/dist/CallManager/CallStateMachine.d.ts +0 -7
  9. package/dist/CallManager/events.d.ts +3 -3
  10. package/dist/CallManager/index.d.ts +2 -2
  11. package/dist/ConferenceStateManager/events.d.ts +0 -1
  12. package/dist/ConferenceStateManager/index.d.ts +2 -3
  13. package/dist/ConnectionManager/@ConnectionManager.d.ts +59 -0
  14. package/dist/ConnectionManager/ConnectionStateMachine.d.ts +20 -17
  15. package/dist/ConnectionManager/events.d.ts +0 -1
  16. package/dist/ConnectionManager/index.d.ts +1 -1
  17. package/dist/IncomingCallManager/@IncomingCallManager.d.ts +32 -0
  18. package/dist/IncomingCallManager/events.d.ts +3 -4
  19. package/dist/IncomingCallManager/index.d.ts +2 -2
  20. package/dist/MainStreamHealthMonitor/index.d.ts +2 -0
  21. package/dist/PresentationManager/@PresentationManager.d.ts +53 -0
  22. package/dist/PresentationManager/events.d.ts +0 -1
  23. package/dist/PresentationManager/index.d.ts +2 -1
  24. package/dist/SessionManager/@SessionManager.d.ts +30 -0
  25. package/dist/SessionManager/events.d.ts +14 -0
  26. package/dist/{session → SessionManager}/index.d.ts +3 -2
  27. package/dist/SipConnector/@SipConnector.d.ts +5 -4
  28. package/dist/SipConnector/events.d.ts +15 -13
  29. package/dist/SipConnector/index.d.ts +1 -1
  30. package/dist/SipConnectorFacade/@SipConnectorFacade.d.ts +3 -3
  31. package/dist/StatsManager/@StatsManager.d.ts +12 -8
  32. package/dist/StatsManager/constants.d.ts +1 -0
  33. package/dist/StatsManager/events.d.ts +2 -2
  34. package/dist/StatsManager/index.d.ts +2 -1
  35. package/dist/StatsPeerConnection/index.d.ts +2 -2
  36. package/dist/VideoSendingBalancerManager/events.d.ts +0 -1
  37. package/dist/VideoSendingBalancerManager/index.d.ts +2 -2
  38. package/dist/__fixtures__/eventNames.d.ts +1 -1
  39. package/dist/doMock.cjs +1 -1
  40. package/dist/doMock.js +1 -1
  41. package/dist/index.cjs +1 -1
  42. package/dist/index.d.ts +8 -8
  43. package/dist/index.js +2 -2
  44. package/package.json +1 -1
  45. package/dist/@SipConnector-DB4bLDI5.cjs +0 -1
  46. package/dist/session/createSession.d.ts +0 -26
  47. /package/dist/{session → SessionManager}/selectors.d.ts +0 -0
  48. /package/dist/{session → SessionManager}/types.d.ts +0 -0
@@ -2,4 +2,4 @@ export { default as ConnectionManager } from './@ConnectionManager';
2
2
  export { hasNotReadyForConnectionError, createNotReadyForConnectionError } from './utils';
3
3
  export { EVENT_NAMES as CONNECTION_MANAGER_EVENT_NAMES, EEvent as EConnectionManagerEvent, createEvents, } from './events';
4
4
  export type { TParametersConnection, TConnectionConfigurationWithUa } from './ConnectionFlow';
5
- export type { TEvent as TConnectionManagerEvent, TEvents as TConnectionManagerEvents, } from './events';
5
+ export type { TEvents as TConnectionManagerEvents, TEventMap as TConnectionManagerEventMap, } from './events';
@@ -0,0 +1,32 @@
1
+ import { IncomingCallStateMachine, TIncomingActor } from './IncomingCallStateMachine';
2
+ import { RTCSession } from '@krivega/jssip';
3
+ import { ConnectionManager } from '../ConnectionManager';
4
+ import { TEventMap, TEvents } from './events';
5
+ export default class IncomingCallManager {
6
+ readonly events: TEvents;
7
+ readonly incomingStateMachine: IncomingCallStateMachine;
8
+ private incomingRTCSession?;
9
+ private readonly connectionManager;
10
+ constructor(connectionManager: ConnectionManager);
11
+ get incomingActor(): TIncomingActor;
12
+ get remoteCallerData(): TEventMap['ringing'];
13
+ get isAvailableIncomingCall(): boolean;
14
+ start(): void;
15
+ stop(): void;
16
+ getIncomingRTCSession: () => RTCSession;
17
+ extractIncomingRTCSession: () => RTCSession;
18
+ declineToIncomingCall({ statusCode, }?: {
19
+ statusCode?: number;
20
+ }): Promise<void>;
21
+ busyIncomingCall(): Promise<void>;
22
+ on<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): () => void;
23
+ once<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): () => void;
24
+ onceRace<T extends keyof TEventMap>(eventNames: T[], handler: (data: TEventMap[T], eventName: string) => void): () => void;
25
+ wait<T extends keyof TEventMap>(eventName: T): Promise<TEventMap[T]>;
26
+ off<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): void;
27
+ private subscribe;
28
+ private unsubscribe;
29
+ private readonly handleNewRTCSession;
30
+ private setIncomingSession;
31
+ private removeIncomingSession;
32
+ }
@@ -1,7 +1,7 @@
1
1
  import { TypedEvents } from 'events-constructor';
2
2
  import { RTCSession } from '@krivega/jssip';
3
3
  export declare enum EEvent {
4
- INCOMING_CALL = "incomingCall",
4
+ RINGING = "ringing",
5
5
  DECLINED_INCOMING_CALL = "declinedIncomingCall",
6
6
  TERMINATED_INCOMING_CALL = "terminatedIncomingCall",
7
7
  FAILED_INCOMING_CALL = "failedIncomingCall"
@@ -11,8 +11,7 @@ export declare enum Originator {
11
11
  REMOTE = "remote",
12
12
  SYSTEM = "system"
13
13
  }
14
- export declare const EVENT_NAMES: readonly ["incomingCall", "declinedIncomingCall", "terminatedIncomingCall", "failedIncomingCall"];
15
- export type TEvent = (typeof EVENT_NAMES)[number];
14
+ export declare const EVENT_NAMES: readonly ["ringing", "declinedIncomingCall", "terminatedIncomingCall", "failedIncomingCall"];
16
15
  export type TRemoteCallerData = {
17
16
  displayName?: string;
18
17
  host?: string;
@@ -20,7 +19,7 @@ export type TRemoteCallerData = {
20
19
  rtcSession?: RTCSession;
21
20
  };
22
21
  export type TEventMap = {
23
- incomingCall: TRemoteCallerData;
22
+ ringing: TRemoteCallerData;
24
23
  declinedIncomingCall: TRemoteCallerData;
25
24
  terminatedIncomingCall: TRemoteCallerData;
26
25
  failedIncomingCall: TRemoteCallerData;
@@ -1,3 +1,3 @@
1
1
  export { default as IncomingCallManager } from './@IncomingCallManager';
2
- export { createEvents } from './events';
3
- export type { TEvent as TIncomingCallEvent, TRemoteCallerData } from './events';
2
+ export { createEvents, EVENT_NAMES as INCOMING_CALL_MANAGER_EVENT_NAMES } from './events';
3
+ export type { TRemoteCallerData, TEventMap as TIncomingCallManagerEventMap } from './events';
@@ -1 +1,3 @@
1
1
  export { default as MainStreamHealthMonitor } from './@MainStreamHealthMonitor';
2
+ export { EVENT_NAMES as MAIN_STREAM_HEALTH_MONITOR_EVENT_NAMES } from './events';
3
+ export type { TEventMap as TMainStreamHealthMonitorEventMap } from './events';
@@ -0,0 +1,53 @@
1
+ import { PresentationStateMachine, TPresentationActor } from './PresentationStateMachine';
2
+ import { CallManager } from '../CallManager';
3
+ import { TEventMap, TEvents } from './events';
4
+ import { TContentHint, TOnAddedTransceiver } from './types';
5
+ export declare const hasCanceledStartPresentationError: (error: unknown) => error is import('repeated-calls').TCanceledError<unknown>;
6
+ declare class PresentationManager {
7
+ readonly events: TEvents;
8
+ readonly presentationStateMachine: PresentationStateMachine;
9
+ promisePendingStartPresentation?: Promise<MediaStream>;
10
+ promisePendingStopPresentation?: Promise<MediaStream | undefined>;
11
+ streamPresentationCurrent?: MediaStream;
12
+ private readonly maxBitrate?;
13
+ private cancelableSendPresentationWithRepeatedCalls;
14
+ private readonly callManager;
15
+ constructor({ callManager, maxBitrate, }: {
16
+ callManager: CallManager;
17
+ maxBitrate?: number;
18
+ });
19
+ get presentationActor(): TPresentationActor;
20
+ get isPendingPresentation(): boolean;
21
+ get isPresentationInProcess(): boolean;
22
+ startPresentation(beforeStartPresentation: () => Promise<void>, stream: MediaStream, { isNeedReinvite, contentHint, sendEncodings, onAddedTransceiver, }?: {
23
+ isNeedReinvite?: boolean;
24
+ contentHint?: TContentHint;
25
+ sendEncodings?: RTCRtpEncodingParameters[];
26
+ onAddedTransceiver?: TOnAddedTransceiver;
27
+ }, options?: {
28
+ callLimit: number;
29
+ }): Promise<MediaStream>;
30
+ stopPresentation(beforeStopPresentation: () => Promise<void>): Promise<MediaStream | undefined>;
31
+ updatePresentation(beforeStartPresentation: () => Promise<void>, stream: MediaStream, { contentHint, sendEncodings, onAddedTransceiver, }?: {
32
+ isP2P?: boolean;
33
+ contentHint?: TContentHint;
34
+ sendEncodings?: RTCRtpEncodingParameters[];
35
+ onAddedTransceiver?: TOnAddedTransceiver;
36
+ }): Promise<MediaStream | undefined>;
37
+ cancelSendPresentationWithRepeatedCalls(): void;
38
+ on<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): () => void;
39
+ once<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): () => void;
40
+ onceRace<T extends keyof TEventMap>(eventNames: T[], handler: (data: TEventMap[T], eventName: string) => void): () => void;
41
+ wait<T extends keyof TEventMap>(eventName: T): Promise<TEventMap[T]>;
42
+ off<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): void;
43
+ private subscribe;
44
+ private sendPresentationWithDuplicatedCalls;
45
+ private sendPresentation;
46
+ private readonly setMaxBitrate;
47
+ private readonly getRtcSessionProtected;
48
+ private readonly handleEnded;
49
+ private reset;
50
+ private resetPresentation;
51
+ private removeStreamPresentationCurrent;
52
+ }
53
+ export default PresentationManager;
@@ -7,7 +7,6 @@ export declare enum EEvent {
7
7
  FAILED_PRESENTATION = "presentation:failed"
8
8
  }
9
9
  export declare const EVENT_NAMES: readonly ["presentation:start", "presentation:started", "presentation:end", "presentation:ended", "presentation:failed"];
10
- export type TEvent = (typeof EVENT_NAMES)[number];
11
10
  export type TEventMap = {
12
11
  'presentation:start': MediaStream;
13
12
  'presentation:started': MediaStream;
@@ -1,3 +1,4 @@
1
1
  export { hasCanceledStartPresentationError, default as PresentationManager, } from './@PresentationManager';
2
- export { createEvents } from './events';
2
+ export { EVENT_NAMES as PRESENTATION_MANAGER_EVENT_NAMES } from './events';
3
+ export type { TEventMap as TPresentationManagerEventMap } from './events';
3
4
  export type { TContentHint, TOnAddedTransceiver } from './types';
@@ -0,0 +1,30 @@
1
+ import { CallManager } from '../CallManager';
2
+ import { ConnectionManager } from '../ConnectionManager';
3
+ import { IncomingCallManager } from '../IncomingCallManager';
4
+ import { PresentationManager } from '../PresentationManager';
5
+ import { TEventMap, TEvents } from './events';
6
+ import { TSessionActors, TSessionSnapshot } from './types';
7
+ type TEqualityFunction<T> = (previous: T, next: T) => boolean;
8
+ type TSelector<T> = (snapshot: TSessionSnapshot) => T;
9
+ type TSessionManagerDeps = {
10
+ connectionManager: Pick<ConnectionManager, 'connectionActor'>;
11
+ callManager: Pick<CallManager, 'callActor'>;
12
+ incomingCallManager: Pick<IncomingCallManager, 'incomingActor'>;
13
+ presentationManager: Pick<PresentationManager, 'presentationActor'>;
14
+ };
15
+ declare class SessionManager {
16
+ readonly events: TEvents;
17
+ readonly actors: TSessionActors;
18
+ private currentSnapshot;
19
+ private readonly subscribers;
20
+ private readonly actorSubscriptions;
21
+ constructor(deps: TSessionManagerDeps);
22
+ getSnapshot(): TSessionSnapshot;
23
+ subscribe(listener: (snapshot: TSessionSnapshot) => void): () => void;
24
+ subscribe<T>(selector: TSelector<T>, listener: (value: T) => void, equals?: TEqualityFunction<T>): () => void;
25
+ stop(): void;
26
+ on<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): () => void;
27
+ off<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): void;
28
+ private readonly notifySubscribers;
29
+ }
30
+ export default SessionManager;
@@ -0,0 +1,14 @@
1
+ import { TypedEvents } from 'events-constructor';
2
+ import { TSessionSnapshot } from './types';
3
+ export declare enum EEvent {
4
+ SNAPSHOT_CHANGED = "snapshot-changed"
5
+ }
6
+ export declare const EVENT_NAMES: readonly ["snapshot-changed"];
7
+ export type TEventMap = {
8
+ 'snapshot-changed': {
9
+ previous: TSessionSnapshot;
10
+ current: TSessionSnapshot;
11
+ };
12
+ };
13
+ export type TEvents = TypedEvents<TEventMap>;
14
+ export declare const createEvents: () => TypedEvents<TEventMap, readonly "snapshot-changed"[]>;
@@ -1,5 +1,6 @@
1
- export { createSession } from './createSession';
1
+ export { default as SessionManager } from './@SessionManager';
2
+ export { EVENT_NAMES as SESSION_MANAGER_EVENT_NAMES } from './events';
2
3
  export { sessionSelectors } from './selectors';
3
4
  export { ECallStatus, EConnectionStatus, EIncomingStatus, EPresentationStatus } from './types';
4
- export type { ISession } from './createSession';
5
+ export type { TEventMap as TSessionManagerEventMap } from './events';
5
6
  export type { TSessionActors, TSessionSnapshot } from './types';
@@ -6,9 +6,10 @@ import { ConnectionManager } from '../ConnectionManager';
6
6
  import { ConnectionQueueManager } from '../ConnectionQueueManager';
7
7
  import { IncomingCallManager } from '../IncomingCallManager';
8
8
  import { PresentationManager, TContentHint, TOnAddedTransceiver } from '../PresentationManager';
9
+ import { SessionManager } from '../SessionManager';
9
10
  import { StatsManager } from '../StatsManager';
10
11
  import { VideoSendingBalancerManager } from '../VideoSendingBalancerManager';
11
- import { ISession } from '../session';
12
+ import { MainStreamHealthMonitor } from '../MainStreamHealthMonitor';
12
13
  import { TJsSIP } from '../types';
13
14
  import { IBalancerOptions } from '../VideoSendingBalancer';
14
15
  import { TEventMap, TEvents } from './events';
@@ -24,8 +25,8 @@ declare class SipConnector {
24
25
  readonly presentationManager: PresentationManager;
25
26
  readonly statsManager: StatsManager;
26
27
  readonly videoSendingBalancerManager: VideoSendingBalancerManager;
27
- readonly session: ISession;
28
- private readonly mainStreamHealthMonitor;
28
+ readonly sessionManager: SessionManager;
29
+ readonly mainStreamHealthMonitor: MainStreamHealthMonitor;
29
30
  private readonly mainStreamRecovery;
30
31
  private readonly preferredMimeTypesVideoCodecs?;
31
32
  private readonly excludeMimeTypesVideoCodecs?;
@@ -40,7 +41,7 @@ declare class SipConnector {
40
41
  get requestedConnection(): boolean;
41
42
  get isPendingConnect(): boolean;
42
43
  get isPendingInitUa(): boolean;
43
- get connectionState(): import('../session').EConnectionStatus;
44
+ get connectionState(): import('../SessionManager').EConnectionStatus;
44
45
  get isRegistered(): boolean;
45
46
  get isRegisterConfig(): boolean;
46
47
  get socket(): import('@krivega/jssip').WebSocketInterface | undefined;
@@ -1,15 +1,17 @@
1
1
  import { TypedEvents } from 'events-constructor';
2
- import { TEventMap as TApiManagerEventMap } from '../ApiManager/events';
3
- import { TEventMap as TAutoConnectorManagerEventMap } from '../AutoConnectorManager/events';
4
- import { TEventMap as TCallManagerEventMap } from '../CallManager/events';
5
- import { TConnectionConfigurationWithUa } from '../ConnectionManager';
6
- import { TEventMap as TConnectionManagerEventMap } from '../ConnectionManager/events';
7
- import { TEventMap as TIncomingCallManagerEventMap } from '../IncomingCallManager/events';
8
- import { TEventMap as TPresentationManagerEventMap } from '../PresentationManager/events';
9
- import { TEventMap as TStatsManagerEventMap } from '../StatsPeerConnection/events';
10
- import { TEventMap as TVideoBalancerManagerEventMap } from '../VideoSendingBalancerManager/events';
11
- export declare const EVENT_NAMES: readonly [...("call:connecting" | "call:accepted" | "call:ended" | "call:failed" | "connection:connecting" | "connection:connected" | "connection:registered" | "connection:disconnected" | "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:disconnecting" | "connection:newRTCSession" | "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:sending" | "call:progress" | "call:confirmed" | "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")[], "disconnected-from-out-of-call", "connected-with-configuration-from-out-of-call", "stopped-presentation-by-server-command"];
12
- export type TEvent = (typeof EVENT_NAMES)[number];
2
+ import { TApiManagerEventMap } from '../ApiManager';
3
+ import { TAutoConnectorManagerEventMap } from '../AutoConnectorManager';
4
+ import { TCallManagerEventMap } from '../CallManager';
5
+ import { TConferenceStateManagerEventMap } from '../ConferenceStateManager';
6
+ import { TConnectionConfigurationWithUa, TConnectionManagerEventMap } from '../ConnectionManager';
7
+ import { TIncomingCallManagerEventMap } from '../IncomingCallManager';
8
+ import { TMainStreamHealthMonitorEventMap } from '../MainStreamHealthMonitor';
9
+ import { TPresentationManagerEventMap } from '../PresentationManager';
10
+ import { TSessionManagerEventMap } from '../SessionManager';
11
+ import { TStatsManagerEventMap } from '../StatsManager';
12
+ import { TVideoSendingBalancerManagerEventMap } from '../VideoSendingBalancerManager';
13
+ export declare const EVENT_NAMES: readonly [...("call:connecting" | "call:accepted" | "call:ended" | "call:failed" | "connection:connecting" | "connection:connected" | "connection:registered" | "connection:disconnected" | "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:disconnecting" | "connection:newRTCSession" | "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:sending" | "call:progress" | "call:confirmed" | "call:newDTMF" | "call:newInfo" | "call:hold" | "call:unhold" | "call:muted" | "call:unmuted" | "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" | "conference-state:state-changed" | "conference-state:state-reset" | "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:ringing" | "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" | "main-stream-health:no-inbound-frames" | "session:snapshot-changed")[], "disconnected-from-out-of-call", "connected-with-configuration-from-out-of-call", "stopped-presentation-by-server-command"];
14
+ export type TEventName = (typeof EVENT_NAMES)[number];
13
15
  type PrefixedEventMap<T extends Record<string, unknown>, Prefix extends string> = {
14
16
  [K in keyof T as `${Prefix}:${string & K}`]: T[K];
15
17
  };
@@ -18,7 +20,7 @@ type TSipConnectorEventMap = {
18
20
  'connected-with-configuration-from-out-of-call': TConnectionConfigurationWithUa;
19
21
  'stopped-presentation-by-server-command': Record<string, never>;
20
22
  };
21
- export type TEventMap = PrefixedEventMap<TAutoConnectorManagerEventMap, 'auto-connect'> & PrefixedEventMap<TConnectionManagerEventMap, 'connection'> & PrefixedEventMap<TCallManagerEventMap, 'call'> & PrefixedEventMap<TApiManagerEventMap, 'api'> & PrefixedEventMap<TIncomingCallManagerEventMap, 'incoming-call'> & PrefixedEventMap<TPresentationManagerEventMap, 'presentation'> & PrefixedEventMap<TStatsManagerEventMap, 'stats'> & PrefixedEventMap<TVideoBalancerManagerEventMap, 'video-balancer'> & TSipConnectorEventMap;
23
+ export type TEventMap = PrefixedEventMap<TAutoConnectorManagerEventMap, 'auto-connect'> & PrefixedEventMap<TConnectionManagerEventMap, 'connection'> & PrefixedEventMap<TCallManagerEventMap, 'call'> & PrefixedEventMap<TConferenceStateManagerEventMap, 'conference-state'> & PrefixedEventMap<TApiManagerEventMap, 'api'> & PrefixedEventMap<TIncomingCallManagerEventMap, 'incoming-call'> & PrefixedEventMap<TPresentationManagerEventMap, 'presentation'> & PrefixedEventMap<TStatsManagerEventMap, 'stats'> & PrefixedEventMap<TVideoSendingBalancerManagerEventMap, 'video-balancer'> & PrefixedEventMap<TMainStreamHealthMonitorEventMap, 'main-stream-health'> & PrefixedEventMap<TSessionManagerEventMap, 'session'> & TSipConnectorEventMap;
22
24
  export type TEvents = TypedEvents<TEventMap>;
23
- export declare const createEvents: () => TypedEvents<TEventMap, readonly ("call:connecting" | "call:accepted" | "call:ended" | "call:failed" | "connection:connecting" | "connection:connected" | "connection:registered" | "connection:disconnected" | "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:disconnecting" | "connection:newRTCSession" | "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:sending" | "call:progress" | "call:confirmed" | "call:newDTMF" | "call:newInfo" | "call:hold" | "call:unhold" | "call:muted" | "call:unmuted" | "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" | keyof TSipConnectorEventMap)[]>;
25
+ export declare const createEvents: () => TypedEvents<TEventMap, readonly ("call:connecting" | "call:accepted" | "call:ended" | "call:failed" | "connection:connecting" | "connection:connected" | "connection:registered" | "connection:disconnected" | "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:disconnecting" | "connection:newRTCSession" | "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:sending" | "call:progress" | "call:confirmed" | "call:newDTMF" | "call:newInfo" | "call:hold" | "call:unhold" | "call:muted" | "call:unmuted" | "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" | "conference-state:state-changed" | "conference-state:state-reset" | "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:ringing" | "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" | "main-stream-health:no-inbound-frames" | "session:snapshot-changed" | keyof TSipConnectorEventMap)[]>;
24
26
  export {};
@@ -1,2 +1,2 @@
1
1
  export { default as SipConnector } from './@SipConnector';
2
- export type { TEvent, TEvents } from './events';
2
+ export type { TEvents } from './events';
@@ -3,7 +3,7 @@ import { TOnAddedTransceiver } from '../CallManager/types';
3
3
  import { TParametersConnection, TConnectionConfigurationWithUa } from '../ConnectionManager';
4
4
  import { TContentHint } from '../PresentationManager';
5
5
  import { SipConnector } from '../SipConnector';
6
- import { TEventMap as TStatsEventMap } from '../StatsManager';
6
+ import { TStatsManagerEventMap } from '../StatsManager';
7
7
  type TEnterRoomHandlers = {
8
8
  onEnterPurgatory?: () => void;
9
9
  onEnterConference?: (parameters_: {
@@ -167,7 +167,7 @@ declare class SipConnectorFacade implements IProxyMethods {
167
167
  onMustStopPresentation: (handler: () => void) => (() => void);
168
168
  onMoveToSpectators: (handler: () => void) => (() => void);
169
169
  onMoveToParticipants: (handler: () => void) => (() => void);
170
- onStats: (handler: (data: TStatsEventMap["collected"]) => void) => (() => void);
171
- offStats: (handler: (data: TStatsEventMap["collected"]) => void) => void;
170
+ onStats: (handler: (data: TStatsManagerEventMap["collected"]) => void) => (() => void);
171
+ offStats: (handler: (data: TStatsManagerEventMap["collected"]) => void) => void;
172
172
  }
173
173
  export default SipConnectorFacade;
@@ -1,4 +1,4 @@
1
- import { StatsPeerConnection, TEventMap } from '../StatsPeerConnection';
1
+ import { StatsPeerConnection, TStatsPeerConnectionEventMap } from '../StatsPeerConnection';
2
2
  import { ApiManager } from '../ApiManager';
3
3
  import { CallManager } from '../CallManager';
4
4
  declare class StatsManager {
@@ -11,9 +11,10 @@ declare class StatsManager {
11
11
  callManager: CallManager;
12
12
  apiManager: ApiManager;
13
13
  });
14
- get events(): import('../StatsPeerConnection').TEvents;
14
+ get events(): import('../StatsPeerConnection').TStatsPeerConnectionEvents;
15
15
  get availableIncomingBitrate(): number | undefined;
16
- get isNotValidFramesStats(): boolean;
16
+ get isInvalidInboundFrames(): boolean;
17
+ private get isEmptyInboundFrames();
17
18
  private get previousAvailableIncomingBitrate();
18
19
  private get previousInboundRtp();
19
20
  private get previousFramesReceived();
@@ -23,11 +24,14 @@ declare class StatsManager {
23
24
  private get framesDecoded();
24
25
  private get isFramesReceived();
25
26
  private get isFramesDecoded();
26
- on<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): () => void;
27
- once<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): () => void;
28
- onceRace<T extends keyof TEventMap>(eventNames: T[], handler: (data: TEventMap[T], eventName: string) => void): () => void;
29
- wait<T extends keyof TEventMap>(eventName: T): Promise<TEventMap[T]>;
30
- off<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): void;
27
+ private get packetsReceived();
28
+ private get previousPacketsReceived();
29
+ private get isReceivingPackets();
30
+ on<T extends keyof TStatsPeerConnectionEventMap>(eventName: T, handler: (data: TStatsPeerConnectionEventMap[T]) => void): () => void;
31
+ once<T extends keyof TStatsPeerConnectionEventMap>(eventName: T, handler: (data: TStatsPeerConnectionEventMap[T]) => void): () => void;
32
+ onceRace<T extends keyof TStatsPeerConnectionEventMap>(eventNames: T[], handler: (data: TStatsPeerConnectionEventMap[T], eventName: string) => void): () => void;
33
+ wait<T extends keyof TStatsPeerConnectionEventMap>(eventName: T): Promise<TStatsPeerConnectionEventMap[T]>;
34
+ off<T extends keyof TStatsPeerConnectionEventMap>(eventName: T, handler: (data: TStatsPeerConnectionEventMap[T]) => void): void;
31
35
  hasAvailableIncomingBitrateChangedQuarter(): boolean;
32
36
  private subscribe;
33
37
  private readonly handleStatsCollected;
@@ -0,0 +1 @@
1
+ export declare const MIN_RECEIVED_MAIN_STREAM_PACKETS = 500;
@@ -1,2 +1,2 @@
1
- export type { TEventMap } from '../StatsPeerConnection';
2
- export { EVENT_NAMES } from '../StatsPeerConnection/events';
1
+ export { STATS_PEER_CONNECTION_EVENT_NAMES as EVENT_NAMES } from '../StatsPeerConnection';
2
+ export type { TStatsPeerConnectionEventMap as TEventMap } from '../StatsPeerConnection';
@@ -1,2 +1,3 @@
1
1
  export { default as StatsManager } from './@StatsManager';
2
- export type { TEventMap } from './events';
2
+ export { EVENT_NAMES as STATS_MANAGER_EVENT_NAMES } from './events';
3
+ export type { TEventMap as TStatsManagerEventMap } from './events';
@@ -1,6 +1,6 @@
1
1
  export { default as StatsPeerConnection } from './@StatsPeerConnection';
2
2
  export { EStatsTypes } from './constants';
3
- export { createEvents } from './events';
3
+ export { createEvents, EVENT_NAMES as STATS_PEER_CONNECTION_EVENT_NAMES } from './events';
4
4
  export { default as hasAvailableStats } from './utils/hasAvailableStats';
5
- export type { TEventMap, TEvents } from './events';
5
+ export type { TEventMap as TStatsPeerConnectionEventMap, TEvents as TStatsPeerConnectionEvents, } from './events';
6
6
  export type { TInboundStats, TOutboundStats, TStats } from './types';
@@ -6,7 +6,6 @@ export declare enum EEvent {
6
6
  PARAMETERS_UPDATED = "parameters-updated"
7
7
  }
8
8
  export declare const EVENT_NAMES: readonly ["balancing-scheduled", "balancing-started", "balancing-stopped", "parameters-updated"];
9
- export type TEvent = (typeof EVENT_NAMES)[number];
10
9
  export type TEventMap = {
11
10
  'balancing-scheduled': {
12
11
  delay: number;
@@ -1,3 +1,3 @@
1
1
  export { default as VideoSendingBalancerManager } from './@VideoSendingBalancerManager';
2
- export { EEvent, EVENT_NAMES } from './events';
3
- export type { TEvent, TEventMap, TEvents } from './events';
2
+ export { EEvent, createEvents, EVENT_NAMES as VIDEO_SENDING_BALANCER_MANAGER_EVENT_NAMES, } from './events';
3
+ export type { TEventMap as TVideoSendingBalancerManagerEventMap, TEvents as TVideoSendingBalancerManagerEvents, } from './events';
@@ -2,7 +2,7 @@ export declare const UA_SYNTHETICS_EVENT_NAMES: readonly ["incomingCall", "decli
2
2
  export declare const UA_JSSIP_EVENT_NAMES: readonly ["connecting", "connected", "disconnected", "newRTCSession", "registered", "unregistered", "registrationFailed", "newMessage", "sipEvent"];
3
3
  export declare const SESSION_SYNTHETICS_EVENT_NAMES: readonly ["availableSecondRemoteStream", "notAvailableSecondRemoteStream", "mustStopPresentation", "shareState", "enterRoom", "useLicense", "peerconnection:confirmed", "peerconnection:ontrack", "channels", "ended:fromserver", "main-cam-control", "admin-start-main-cam", "admin-stop-main-cam", "admin-stop-mic", "admin-start-mic", "admin-force-sync-media-state", "participant:move-request-to-spectators", "participant:move-request-to-participants"];
4
4
  export declare const SESSION_JSSIP_EVENT_NAMES: readonly ["ended", "connecting", "sending", "reinvite", "replaces", "refer", "progress", "accepted", "confirmed", "peerconnection", "failed", "muted", "unmuted", "newDTMF", "newInfo", "hold", "unhold", "update", "sdp", "icecandidate", "getusermediafailed", "peerconnection:createofferfailed", "peerconnection:createanswerfailed", "peerconnection:setlocaldescriptionfailed", "peerconnection:setremotedescriptionfailed", "presentation:start", "presentation:started", "presentation:end", "presentation:ended", "presentation:failed"];
5
- export declare const UA_EVENT_NAMES: ("channels:notify" | "participant:added-to-list-moderators" | "participant:removed-from-list-moderators" | "participant:move-request-to-stream" | "participation:accepting-word-request" | "participation:cancelling-word-request" | "webcast:started" | "webcast:stopped" | "account:changed" | "account:deleted" | "conference:participant-token-issued" | "connecting" | "connected" | "disconnected" | "newRTCSession" | "registered" | "unregistered" | "registrationFailed" | "newMessage" | "sipEvent" | "incomingCall" | "declinedIncomingCall" | "terminatedIncomingCall" | "failedIncomingCall")[];
5
+ export declare const UA_EVENT_NAMES: ("channels:notify" | "participant:added-to-list-moderators" | "participant:removed-from-list-moderators" | "participant:move-request-to-stream" | "participation:accepting-word-request" | "participation:cancelling-word-request" | "webcast:started" | "webcast:stopped" | "account:changed" | "account:deleted" | "conference:participant-token-issued" | "connecting" | "connected" | "disconnected" | "newRTCSession" | "registered" | "unregistered" | "registrationFailed" | "newMessage" | "sipEvent" | "declinedIncomingCall" | "terminatedIncomingCall" | "failedIncomingCall" | "incomingCall")[];
6
6
  export declare const SESSION_EVENT_NAMES: readonly ["ended", "connecting", "sending", "reinvite", "replaces", "refer", "progress", "accepted", "confirmed", "peerconnection", "failed", "muted", "unmuted", "newDTMF", "newInfo", "hold", "unhold", "update", "sdp", "icecandidate", "getusermediafailed", "peerconnection:createofferfailed", "peerconnection:createanswerfailed", "peerconnection:setlocaldescriptionfailed", "peerconnection:setremotedescriptionfailed", "presentation:start", "presentation:started", "presentation:end", "presentation:ended", "presentation:failed", "availableSecondRemoteStream", "notAvailableSecondRemoteStream", "mustStopPresentation", "shareState", "enterRoom", "useLicense", "peerconnection:confirmed", "peerconnection:ontrack", "channels", "ended:fromserver", "main-cam-control", "admin-start-main-cam", "admin-stop-main-cam", "admin-stop-mic", "admin-start-mic", "admin-force-sync-media-state", "participant:move-request-to-spectators", "participant:move-request-to-participants"];
7
7
  export type TEventUA = (typeof UA_EVENT_NAMES)[number];
8
8
  export type TEventSession = (typeof SESSION_EVENT_NAMES)[number];
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-DB4bLDI5.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;renegotiate=jest.fn(async()=>!0);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;
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-TNDGO7MW.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;renegotiate=jest.fn(async()=>!0);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;
package/dist/doMock.js CHANGED
@@ -5,7 +5,7 @@ import { IncomingRequest as b } 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 { MediaStreamTrackMock as j, createAudioMediaStreamTrackMock as U, createVideoMediaStreamTrackMock as G } from "webrtc-mock";
7
7
  import { Events as O } from "events-constructor";
8
- import { O as H, S as x } from "./@SipConnector-FYEV5h4G.js";
8
+ import { O as H, S as x } from "./@SipConnector-DoyWexFp.js";
9
9
  class T extends b {
10
10
  headers;
11
11
  constructor(e) {