sip-connector 20.6.1 → 21.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.
- package/dist/@SipConnector-B7rwpjv6.cjs +1 -0
- package/dist/{@SipConnector-B4noAdXF.js → @SipConnector-CQ2xR48Y.js} +642 -595
- package/dist/CallManager/@CallManager.d.ts +10 -5
- package/dist/CallManager/RemoteStreamsManager.d.ts +10 -4
- package/dist/CallManager/RoleManager.d.ts +1 -8
- package/dist/CallManager/StreamsManagerProvider.d.ts +10 -0
- package/dist/CallManager/events.d.ts +9 -4
- package/dist/CallManager/index.d.ts +1 -1
- package/dist/CallManager/types.d.ts +11 -0
- package/dist/SipConnector/events.d.ts +2 -2
- package/dist/SipConnectorFacade/@SipConnectorFacade.d.ts +3 -3
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/@SipConnector-C09GtMW6.cjs +0 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { CallStateMachine, TCallActor } from './CallStateMachine';
|
|
2
|
+
import { StreamsManagerProvider } from './StreamsManagerProvider';
|
|
2
3
|
import { RTCSession } from '@krivega/jssip';
|
|
3
4
|
import { ConferenceStateManager } from '../ConferenceStateManager';
|
|
4
5
|
import { TEventMap, TEvents } from './events';
|
|
5
|
-
import { TAnswerToIncomingCall, TCallRoleSpectator, TReplaceMediaStream, TStartCall } from './types';
|
|
6
|
+
import { TAnswerToIncomingCall, TCallRoleSpectator, TReplaceMediaStream, TStartCall, TRemoteStreams } from './types';
|
|
6
7
|
declare class CallManager {
|
|
7
8
|
readonly events: TEvents;
|
|
8
9
|
readonly callStateMachine: CallStateMachine;
|
|
@@ -12,6 +13,7 @@ declare class CallManager {
|
|
|
12
13
|
private readonly conferenceStateManager;
|
|
13
14
|
private readonly mainRemoteStreamsManager;
|
|
14
15
|
private readonly recvRemoteStreamsManager;
|
|
16
|
+
private readonly streamsManagerProvider;
|
|
15
17
|
private readonly roleManager;
|
|
16
18
|
private readonly mcuSession;
|
|
17
19
|
private recvSession?;
|
|
@@ -21,6 +23,7 @@ declare class CallManager {
|
|
|
21
23
|
get requested(): boolean;
|
|
22
24
|
get connection(): RTCPeerConnection | undefined;
|
|
23
25
|
get isCallActive(): boolean;
|
|
26
|
+
getStreamsManagerProvider(): StreamsManagerProvider;
|
|
24
27
|
getEstablishedRTCSession: () => RTCSession | undefined;
|
|
25
28
|
on<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): () => void;
|
|
26
29
|
onRace<T extends keyof TEventMap>(eventNames: T[], handler: (data: TEventMap[T], eventName: string) => void): () => void;
|
|
@@ -32,8 +35,8 @@ declare class CallManager {
|
|
|
32
35
|
endCall(): Promise<void>;
|
|
33
36
|
renegotiate(): Promise<boolean>;
|
|
34
37
|
answerToIncomingCall: TAnswerToIncomingCall;
|
|
35
|
-
|
|
36
|
-
getRemoteStreams():
|
|
38
|
+
getMainRemoteStream(): MediaStream | undefined;
|
|
39
|
+
getRemoteStreams(): TRemoteStreams;
|
|
37
40
|
setCallRoleParticipant(): void;
|
|
38
41
|
setCallRoleSpectatorSynthetic(): void;
|
|
39
42
|
setCallRoleSpectator(recvParams: TCallRoleSpectator['recvParams']): void;
|
|
@@ -50,8 +53,10 @@ declare class CallManager {
|
|
|
50
53
|
private maybeTriggerCallStatus;
|
|
51
54
|
private subscribeMcuRemoteTrackEvents;
|
|
52
55
|
private addRemoteTrack;
|
|
53
|
-
private
|
|
54
|
-
private
|
|
56
|
+
private handleChangedRemoteTracks;
|
|
57
|
+
private emitEventChangedRemoteTracks;
|
|
58
|
+
private emitEventChangedRemoteStreams;
|
|
59
|
+
private getActiveStreamsManagerTools;
|
|
55
60
|
private attachRecvSessionTracks;
|
|
56
61
|
private startRecvSession;
|
|
57
62
|
private stopRecvSession;
|
|
@@ -6,17 +6,23 @@ export declare class RemoteStreamsManager {
|
|
|
6
6
|
reset(): void;
|
|
7
7
|
addTrack(track: MediaStreamTrack, { onRemoved, streamHint, }?: {
|
|
8
8
|
streamHint?: string;
|
|
9
|
-
onRemoved?: ({ trackId, participantId }: {
|
|
9
|
+
onRemoved?: ({ trackId, participantId, }: {
|
|
10
10
|
trackId: string;
|
|
11
|
+
isRemovedStream: boolean;
|
|
11
12
|
participantId: string;
|
|
12
13
|
}) => void;
|
|
13
14
|
}): {
|
|
14
|
-
|
|
15
|
+
isAddedTrack: true;
|
|
16
|
+
isAddedStream: boolean;
|
|
15
17
|
participantId: string;
|
|
16
18
|
} | {
|
|
17
|
-
|
|
19
|
+
isAddedTrack: false;
|
|
20
|
+
isAddedStream: false;
|
|
21
|
+
};
|
|
22
|
+
removeTrack(trackId: string): {
|
|
23
|
+
isRemovedTrack: boolean;
|
|
24
|
+
isRemovedStream: boolean;
|
|
18
25
|
};
|
|
19
|
-
removeTrack(trackId: string): boolean;
|
|
20
26
|
removeStaleTracks(participantId: string, keepTrackIds: string[]): boolean;
|
|
21
27
|
getStreams(participantId?: string): MediaStream[];
|
|
22
28
|
private disposeTrackListener;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { RemoteStreamsManager } from './RemoteStreamsManager';
|
|
2
1
|
import { TCallRole, TCallRoleParticipant, TCallRoleSpectatorSynthetic, TCallRoleSpectator } from './types';
|
|
3
2
|
type TOnRoleChanged = (params: {
|
|
4
3
|
previous: TCallRole;
|
|
@@ -6,13 +5,8 @@ type TOnRoleChanged = (params: {
|
|
|
6
5
|
}) => void;
|
|
7
6
|
export declare class RoleManager {
|
|
8
7
|
private role;
|
|
9
|
-
private readonly mainManager;
|
|
10
|
-
private readonly recvManager;
|
|
11
8
|
private readonly onRoleChanged?;
|
|
12
|
-
constructor(
|
|
13
|
-
mainManager: RemoteStreamsManager;
|
|
14
|
-
recvManager: RemoteStreamsManager;
|
|
15
|
-
}, onRoleChanged?: TOnRoleChanged);
|
|
9
|
+
constructor(onRoleChanged?: TOnRoleChanged);
|
|
16
10
|
static hasParticipant(role: TCallRole): role is TCallRoleParticipant;
|
|
17
11
|
static hasSpectatorSynthetic(role: TCallRole): role is TCallRoleSpectatorSynthetic;
|
|
18
12
|
static hasSpectator(role: TCallRole): role is TCallRoleSpectator;
|
|
@@ -22,7 +16,6 @@ export declare class RoleManager {
|
|
|
22
16
|
setCallRoleSpectator(recvParams: TCallRoleSpectator['recvParams']): void;
|
|
23
17
|
changeRole(next: TCallRole): void;
|
|
24
18
|
reset(): void;
|
|
25
|
-
getActiveManager(): RemoteStreamsManager;
|
|
26
19
|
hasParticipant(): boolean;
|
|
27
20
|
hasSpectatorSynthetic(): boolean;
|
|
28
21
|
hasSpectator(): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RemoteStreamsManager } from './RemoteStreamsManager';
|
|
2
|
+
import { TStreamsManagerTools } from './types';
|
|
3
|
+
export declare class StreamsManagerProvider {
|
|
4
|
+
private readonly mainRemoteStreamsManager;
|
|
5
|
+
private readonly recvRemoteStreamsManager;
|
|
6
|
+
constructor(mainRemoteStreamsManager: RemoteStreamsManager, recvRemoteStreamsManager: RemoteStreamsManager);
|
|
7
|
+
getActiveStreamsManagerTools(isSpectator: boolean): TStreamsManagerTools;
|
|
8
|
+
getMainRemoteStreamsManagerTools(): TStreamsManagerTools;
|
|
9
|
+
getRecvRemoteStreamsManagerTools(): TStreamsManagerTools;
|
|
10
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TypedEvents } from 'events-constructor';
|
|
2
2
|
import { IncomingInfoEvent, OutgoingInfoEvent, EndEvent } from '@krivega/jssip';
|
|
3
|
+
import { TRemoteStreams, TRemoteTracksChangeType } from './types';
|
|
3
4
|
export declare enum EEvent {
|
|
4
5
|
PEER_CONNECTION = "peerconnection",
|
|
5
6
|
CONNECTING = "connecting",
|
|
@@ -35,6 +36,7 @@ export declare enum EEvent {
|
|
|
35
36
|
PEER_CONNECTION_ONTRACK = "peerconnection:ontrack",
|
|
36
37
|
ENDED_FROM_SERVER = "ended:fromserver",
|
|
37
38
|
CALL_STATUS_CHANGED = "call-status-changed",
|
|
39
|
+
REMOTE_TRACKS_CHANGED = "remote-tracks-changed",
|
|
38
40
|
REMOTE_STREAMS_CHANGED = "remote-streams-changed"
|
|
39
41
|
}
|
|
40
42
|
export declare enum Originator {
|
|
@@ -43,7 +45,7 @@ export declare enum Originator {
|
|
|
43
45
|
SYSTEM = "system"
|
|
44
46
|
}
|
|
45
47
|
export declare const SESSION_JSSIP_EVENT_NAMES: readonly ["peerconnection", "connecting", "sending", "progress", "accepted", "confirmed", "ended", "failed", "hold", "unhold", "muted", "unmuted", "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"];
|
|
46
|
-
export declare const EVENT_NAMES: readonly ["peerconnection", "connecting", "sending", "progress", "accepted", "confirmed", "ended", "failed", "hold", "unhold", "muted", "unmuted", "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"];
|
|
48
|
+
export declare const EVENT_NAMES: readonly ["peerconnection", "connecting", "sending", "progress", "accepted", "confirmed", "ended", "failed", "hold", "unhold", "muted", "unmuted", "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-tracks-changed", "remote-streams-changed"];
|
|
47
49
|
export type TEventName = (typeof EVENT_NAMES)[number];
|
|
48
50
|
export type TEventMap = {
|
|
49
51
|
peerconnection: {
|
|
@@ -86,11 +88,14 @@ export type TEventMap = {
|
|
|
86
88
|
'call-status-changed': {
|
|
87
89
|
isCallActive: boolean;
|
|
88
90
|
};
|
|
89
|
-
'remote-
|
|
91
|
+
'remote-tracks-changed': {
|
|
92
|
+
streams: TRemoteStreams;
|
|
93
|
+
changeType: TRemoteTracksChangeType;
|
|
90
94
|
participantId: string;
|
|
91
|
-
changeType: 'added' | 'removed';
|
|
92
95
|
trackId: string;
|
|
93
|
-
|
|
96
|
+
};
|
|
97
|
+
'remote-streams-changed': {
|
|
98
|
+
streams: TRemoteStreams;
|
|
94
99
|
};
|
|
95
100
|
};
|
|
96
101
|
export type TEvents = TypedEvents<TEventMap>;
|
|
@@ -2,5 +2,5 @@ export { default as CallManager } from './@CallManager';
|
|
|
2
2
|
export { ECallCause } from './causes';
|
|
3
3
|
export { EEvent as ECallEvent, createEvents, EVENT_NAMES as CALL_MANAGER_EVENT_NAMES, } from './events';
|
|
4
4
|
export { default as hasCanceledCallError } from './hasCanceledCallError';
|
|
5
|
-
export type { TCustomError, TGetUri } from './types';
|
|
5
|
+
export type { TCustomError, TGetUri, TOnAddedTransceiver, TRemoteStreams } from './types';
|
|
6
6
|
export type { TEventMap as TCallManagerEventMap, TEvents as TCallEvents } from './events';
|
|
@@ -2,6 +2,7 @@ import { RTCSession, UA } from '@krivega/jssip';
|
|
|
2
2
|
import { TContentHint } from '../PresentationManager';
|
|
3
3
|
import { Originator } from './events';
|
|
4
4
|
import { TTools } from './RecvSession';
|
|
5
|
+
import { RemoteStreamsManager } from './RemoteStreamsManager';
|
|
5
6
|
export type TOnAddedTransceiver = (transceiver: RTCRtpTransceiver, track: MediaStreamTrack, streams: MediaStream[]) => Promise<void>;
|
|
6
7
|
export type TGetUri = (id: string) => string;
|
|
7
8
|
type TOptionsExtraHeaders = {
|
|
@@ -78,4 +79,14 @@ export interface IMCUSession {
|
|
|
78
79
|
degradationPreference?: RTCDegradationPreference;
|
|
79
80
|
}) => Promise<boolean>;
|
|
80
81
|
}
|
|
82
|
+
export type TRemoteStreams = {
|
|
83
|
+
mainStream?: MediaStream;
|
|
84
|
+
contentedStream?: MediaStream;
|
|
85
|
+
};
|
|
86
|
+
export type TGetRemoteStreams = () => TRemoteStreams;
|
|
87
|
+
export type TStreamsManagerTools = {
|
|
88
|
+
manager: RemoteStreamsManager;
|
|
89
|
+
getRemoteStreams: TGetRemoteStreams;
|
|
90
|
+
};
|
|
91
|
+
export type TRemoteTracksChangeType = 'added' | 'removed' | 'updated';
|
|
81
92
|
export {};
|
|
@@ -10,7 +10,7 @@ import { TPresentationManagerEventMap } from '../PresentationManager';
|
|
|
10
10
|
import { TSessionManagerEventMap } from '../SessionManager';
|
|
11
11
|
import { TStatsManagerEventMap } from '../StatsManager';
|
|
12
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"];
|
|
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-tracks-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
14
|
export type TEventName = (typeof EVENT_NAMES)[number];
|
|
15
15
|
type PrefixedEventMap<T extends Record<string, unknown>, Prefix extends string> = {
|
|
16
16
|
[K in keyof T as `${Prefix}:${string & K}`]: T[K];
|
|
@@ -22,5 +22,5 @@ type TSipConnectorEventMap = {
|
|
|
22
22
|
};
|
|
23
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;
|
|
24
24
|
export type TEvents = TypedEvents<TEventMap>;
|
|
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)[]>;
|
|
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-tracks-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)[]>;
|
|
26
26
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EUseLicense } from '../ApiManager';
|
|
2
|
-
import { TOnAddedTransceiver } from '../CallManager
|
|
2
|
+
import { TOnAddedTransceiver, TRemoteStreams } from '../CallManager';
|
|
3
3
|
import { TParametersConnection, TConnectionConfigurationWithUa } from '../ConnectionManager';
|
|
4
4
|
import { TContentHint } from '../PresentationManager';
|
|
5
5
|
import { SipConnector } from '../SipConnector';
|
|
@@ -152,7 +152,7 @@ declare class SipConnectorFacade implements IProxyMethods {
|
|
|
152
152
|
}) => Promise<void>;
|
|
153
153
|
askPermissionToEnableCam: () => Promise<void>;
|
|
154
154
|
resolveHandleReadyRemoteStreamsDebounced: ({ onReadyRemoteStreams, }: {
|
|
155
|
-
onReadyRemoteStreams: (streams:
|
|
155
|
+
onReadyRemoteStreams: (streams: TRemoteStreams) => void;
|
|
156
156
|
}) => {
|
|
157
157
|
(this: unknown, ...args: [] & any[]): Promise<void>;
|
|
158
158
|
cancel: (reason?: any) => void;
|
|
@@ -162,7 +162,7 @@ declare class SipConnectorFacade implements IProxyMethods {
|
|
|
162
162
|
}) => ({ track }: {
|
|
163
163
|
track: MediaStreamTrack;
|
|
164
164
|
}) => void;
|
|
165
|
-
getRemoteStreams: () =>
|
|
165
|
+
getRemoteStreams: () => TRemoteStreams;
|
|
166
166
|
onUseLicense: (handler: (license: EUseLicense) => void) => (() => void);
|
|
167
167
|
onMustStopPresentation: (handler: () => void) => (() => void);
|
|
168
168
|
onMoveToSpectators: (handler: () => void) => (() => void);
|
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-C09GtMW6.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-B7rwpjv6.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-
|
|
8
|
+
import { O as H, S as x } from "./@SipConnector-CQ2xR48Y.js";
|
|
9
9
|
class T extends b {
|
|
10
10
|
headers;
|
|
11
11
|
constructor(e) {
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./@SipConnector-C09GtMW6.cjs");require("events-constructor");const k=require("@krivega/cancelable-promise"),W=require("repeated-calls"),H=require("ts-debounce"),Y=require("ua-parser-js"),j=require("sequent-promises"),K=require("stack-promises"),X=e=>e instanceof Object&&("originator"in e||"cause"in e),J=e=>{if(k.isCanceledError(e))return!0;if(!X(e))return!1;const{originator:n,cause:r}=e;return typeof r=="string"?r===t.ECallCause.REQUEST_TIMEOUT||r===t.ECallCause.REJECTED||n==="local"&&(r===t.ECallCause.CANCELED||r===t.ECallCause.BYE):!1};var C=(e=>(e.DISCONNECTED="system:disconnected",e.CONNECTING="system:connecting",e.READY_TO_CALL="system:readyToCall",e.CALL_CONNECTING="system:callConnecting",e.CALL_ACTIVE="system:callActive",e.CONNECTION_FAILED="system:connectionFailed",e.CALL_FAILED="system:callFailed",e))(C||{});const V=e=>e.connection.value,F=e=>e.call.value,z=e=>e.incoming.value,Q=e=>{if(e.incoming.value!==t.EState$2.IDLE)return e.incoming.context.remoteCallerData},Z=e=>e.presentation.value,ee=e=>{const n=F(e);return n===t.EState$1.IN_CALL||n===t.EState$1.ACCEPTED},ne=e=>{const n=V(e),r=F(e);if(n===t.EState.IDLE||n===t.EState.DISCONNECTED)return C.DISCONNECTED;if(n===t.EState.FAILED)return C.CONNECTION_FAILED;if(n===t.EState.PREPARING||n===t.EState.CONNECTING||n===t.EState.CONNECTED||n===t.EState.REGISTERED)return C.CONNECTING;switch(r){case t.EState$1.IDLE:return C.READY_TO_CALL;case t.EState$1.CONNECTING:return C.CALL_CONNECTING;case t.EState$1.ACCEPTED:case t.EState$1.IN_CALL:return C.CALL_ACTIVE;case t.EState$1.ENDED:return C.READY_TO_CALL;case t.EState$1.FAILED:return C.CALL_FAILED;default:return C.READY_TO_CALL}},te={selectConnectionStatus:V,selectCallStatus:F,selectIncomingStatus:z,selectIncomingRemoteCaller:Q,selectPresentationStatus:Z,selectIsInCall:ee,selectSystemStatus:ne},re=()=>globalThis.process?.versions?.electron!==void 0,x=()=>{const e=new Y.UAParser,{name:n}=e.getBrowser(),r=re();return{isChrome:n==="Chrome"||r}},v=e=>{const{url:n,cause:r}=e;let o=n;return(r===t.ECallCause.BAD_MEDIA_DESCRIPTION||r===t.ECallCause.NOT_FOUND)&&(o=`${e.message.to.uri.user}@${e.message.to.uri.host}`),o};var B=(e=>(e.CONNECT_SERVER_FAILED="CONNECT_SERVER_FAILED",e.WRONG_USER_OR_PASSWORD="WRONG_USER_OR_PASSWORD",e.BAD_MEDIA_ERROR="BAD_MEDIA_ERROR",e.NOT_FOUND_ERROR="NOT_FOUND_ERROR",e.WS_CONNECTION_FAILED="WS_CONNECTION_FAILED",e.CONNECT_SERVER_FAILED_BY_LINK="CONNECT_SERVER_FAILED_BY_LINK",e))(B||{});const oe=new Error("Unknown error"),se=(e=oe)=>{const{cause:n,socket:r}=e;let o="CONNECT_SERVER_FAILED";switch(n){case"Forbidden":{o="WRONG_USER_OR_PASSWORD";break}case t.ECallCause.BAD_MEDIA_DESCRIPTION:{o="BAD_MEDIA_ERROR";break}case t.ECallCause.NOT_FOUND:{o="NOT_FOUND_ERROR";break}default:r!==void 0&&r._ws?.readyState===3?o="WS_CONNECTION_FAILED":v(e)!==void 0&&v(e)!==""&&(o="CONNECT_SERVER_FAILED_BY_LINK")}return o},ae=e=>{let n="";try{n=JSON.stringify(e)}catch(r){t.logger("failed to stringify message",r)}return n},ce=new Error("Unknown error"),ie=(e=ce)=>{const{code:n,cause:r,message:o}=e,a=v(e),s={code:"",cause:"",message:""};return typeof o=="object"&&o!==null?s.message=ae(o):o&&(s.message=String(o)),a!==void 0&&a!==""&&(s.link=a),n!==void 0&&n!==""&&(s.code=n),r!==void 0&&r!==""&&(s.cause=r),s},le=Object.freeze(Object.defineProperty({__proto__:null,EErrorTypes:B,getLinkError:v,getTypeFromError:se,getValuesFromError:ie},Symbol.toStringTag,{value:"Module"})),ue=({sessionId:e,remoteAddress:n,isMutedAudio:r,isMutedVideo:o,isRegistered:a,isPresentationCall:s})=>{const c=[],l=r?"0":"1",g=o?"0":"1";return c.push(`X-Vinteo-Mic-State: ${l}`,`X-Vinteo-MainCam-State: ${g}`),(a===!1||a===void 0)&&c.push("X-Vinteo-Purgatory-Call: yes"),e!==void 0&&e!==""&&c.push(`X-Vinteo-Session: ${e}`),s===!0&&c.push("X-Vinteo-Presentation-Call: yes"),n!==void 0&&n!==""&&c.push(`X-Vinteo-Remote: ${n}`),c},Ce="[@*!|]",ge="_",de=e=>{let n=e;return n=n.replaceAll(new RegExp(Ce,"g"),ge),n},Se=({appName:e,appVersion:n,browserName:r,browserVersion:o})=>{const s=`${de(e)} ${n}`;return`ChromeNew - ${r===void 0?s:`${r} ${o}, ${s}`}`},Ee=({isUnifiedSdpSemantic:e,appVersion:n,browserName:r,browserVersion:o,appName:a})=>e?Se({appVersion:n,browserName:r,browserVersion:o,appName:a}):"Chrome",q="purgatory",D=e=>e===q,fe=e=>n=>[...n].map(o=>async()=>e(o)),me=async({accumulatedKeys:e,sendKey:n,canRunTask:r})=>{const a=fe(n)(e);return j.sequentPromises(a,r)},pe=e=>r=>(t.logger("onStartMainCam"),e.on("api:admin-start-main-cam",r)),he=e=>r=>(t.logger("onStartMic"),e.on("api:admin-start-mic",r)),Re=e=>r=>(t.logger("onStopMainCam"),e.on("api:admin-stop-main-cam",r)),Te=e=>r=>(t.logger("onStopMic"),e.on("api:admin-stop-mic",r)),Ne=({sipConnector:e})=>{const n=(u,d)=>({isSyncForced:S})=>{if(S===!0){u();return}d()},r=pe(e),o=Re(e),a=he(e),s=Te(e);let c,l,g,p;const N=({onStartMainCamForced:u,onStartMainCamNotForced:d,onStopMainCamForced:S,onStopMainCamNotForced:R,onStartMicForced:T,onStartMicNotForced:A,onStopMicForced:b,onStopMicNotForced:P})=>{const E=n(u,d);c=r(E);const f=n(S,R);l=o(f);const I=n(T,A);g=a(I);const m=n(b,P);p=s(m)},O=()=>{c?.(),l?.(),g?.(),p?.()};return{start:u=>{N(u)},stop:()=>{O()}}},Oe=Object.freeze(Object.defineProperty({__proto__:null,PURGATORY_CONFERENCE_NUMBER:q,createSyncMediaState:Ne,createUaParser:x,error:le,getExtraHeaders:ue,getUserAgent:Ee,hasPurgatory:D,prepareMediaStream:t.prepareMediaStream,sendDtmfAccumulated:me,sendOffer:t.sendOffer,setEncodingsToSender:t.setEncodingsToSender,setParametersToSender:t.setParametersToSender},Symbol.toStringTag,{value:"Module"})),_e=()=>x().isChrome,Ae=e=>{if(!k.isCanceledError(e)&&!W.hasCanceledError(e)&&!t.hasNotReadyForConnectionError(e))throw e;return{configuration:void 0,isSuccessful:!1}},be=({kind:e,readyState:n})=>e==="video"&&n==="live",w=(e,n,{onEnterPurgatory:r,onEnterConference:o})=>{D(e)?r&&r():o&&o({isSuccessProgressCall:n})},U=(e,n)=>{e(),n&&n()},$=(e,n,r)=>{throw e&&e(),n(),r},Pe=new Set(["on","once","onceRace","wait","off","sendDTMF","hangUp","declineToIncomingCall","sendChannels","checkTelephony","waitChannels","ping","startAutoConnect","stopAutoConnect","connection","isConfigured","isRegistered"]);class ve{on;once;onceRace;wait;off;sendDTMF;hangUp;declineToIncomingCall;sendChannels;checkTelephony;waitChannels;ping;startAutoConnect;stopAutoConnect;connection;isConfigured;isRegistered;sipConnector;constructor(n){return this.sipConnector=n,new Proxy(this,{get:(r,o,a)=>{if(typeof o=="string"&&Pe.has(o)&&o in this.sipConnector){const c=Reflect.get(this.sipConnector,o,this.sipConnector);return typeof c=="function"?c.bind(this.sipConnector):c}const s=Reflect.get(r,o,a);return typeof s=="function"?s.bind(r):s}})}connectToServer=async(n,r)=>this.sipConnector.connect(n,r).then(o=>(t.logger("connectToServer then"),{configuration:o,isSuccessful:!0})).catch(async o=>(t.logger("connectToServer catch: error",o),Ae(o)));callToServer=async n=>{const{conference:r,mediaStream:o,extraHeaders:a,iceServers:s,contentHint:c,degradationPreference:l,sendEncodings:g,offerToReceiveAudio:p,offerToReceiveVideo:N,directionVideo:O,directionAudio:_,onBeforeProgressCall:h,onSuccessProgressCall:u,onEnterPurgatory:d,onEnterConference:S,onFailProgressCall:R,onFinishProgressCall:T,onEndedCall:A,onAddedTransceiver:b}=n;t.logger("callToServer",n);const P=async()=>(t.logger("startCall"),this.sipConnector.call({mediaStream:o,extraHeaders:a,iceServers:s,contentHint:c,offerToReceiveAudio:p,offerToReceiveVideo:N,directionVideo:O,directionAudio:_,degradationPreference:l,onAddedTransceiver:b,sendEncodings:g,number:r}));let E=!1,f;const m=(t.logger("subscribeEnterConference: onEnterConference",S),this.sipConnector.on("api:enterRoom",({room:i})=>{t.logger("enterRoom",{_room:i,isSuccessProgressCall:E}),f=i,(d??S)&&w(f,E,{onEnterPurgatory:d,onEnterConference:S})})),M=i=>(t.logger("onSuccess"),E=!0,u&&u({isPurgatory:D(f)}),this.sipConnector.onceRace(["call:ended","call:failed"],()=>{U(m,A)}),i),y=i=>(t.logger("onFail"),$(R,m,i)),L=()=>{t.logger("onFinish"),T&&T()};return t.logger("onBeforeProgressCall"),h&&h(r),P().then(M).catch(i=>y(i)).finally(L)};disconnectFromServer=async()=>this.sipConnector.disconnect().then(()=>(t.logger("disconnectFromServer: then"),{isSuccessful:!0})).catch(n=>(t.logger("disconnectFromServer: catch",n),{isSuccessful:!1}));answerToIncomingCall=async n=>{const{mediaStream:r,extraHeaders:o,iceServers:a,contentHint:s,degradationPreference:c,sendEncodings:l,offerToReceiveAudio:g,offerToReceiveVideo:p,directionVideo:N,directionAudio:O,onBeforeProgressCall:_,onSuccessProgressCall:h,onEnterPurgatory:u,onEnterConference:d,onFailProgressCall:S,onFinishProgressCall:R,onEndedCall:T,onAddedTransceiver:A}=n;t.logger("answerToIncomingCall",n);const b=async()=>this.sipConnector.answerToIncomingCall({mediaStream:r,extraHeaders:o,iceServers:a,contentHint:s,offerToReceiveAudio:g,offerToReceiveVideo:p,directionVideo:N,directionAudio:O,degradationPreference:c,onAddedTransceiver:A,sendEncodings:l}),P=()=>{const{remoteCallerData:i}=this.sipConnector;return i.incomingNumber};let E=!1,f;const m=(t.logger("subscribeEnterConference: onEnterConference",d),this.sipConnector.on("api:enterRoom",i=>{t.logger("enterRoom",{room:i.room,isSuccessProgressCall:E}),f=i.room,(u??d)&&w(f,E,{onEnterPurgatory:u,onEnterConference:d})})),M=i=>(t.logger("onSuccess"),E=!0,h&&h({isPurgatory:D(f)}),this.sipConnector.onceRace(["call:ended","call:failed"],()=>{U(m,T)}),i),y=i=>(t.logger("onFail"),$(S,m,i)),L=()=>{t.logger("onFinish"),R&&R()};if(t.logger("onBeforeProgressCall"),_){const i=P();_(i)}return b().then(M).catch(i=>y(i)).finally(L)};updatePresentation=async({mediaStream:n,isP2P:r,contentHint:o,degradationPreference:a,sendEncodings:s,onAddedTransceiver:c})=>(t.logger("updatePresentation"),this.sipConnector.updatePresentation(n,{isP2P:r,contentHint:o,degradationPreference:a,onAddedTransceiver:c,sendEncodings:s}));startPresentation=async({mediaStream:n,isP2P:r,contentHint:o,degradationPreference:a,sendEncodings:s,callLimit:c,onAddedTransceiver:l})=>(t.logger("startPresentation"),this.sipConnector.startPresentation(n,{isP2P:r,contentHint:o,callLimit:c,degradationPreference:a,onAddedTransceiver:l,sendEncodings:s}));stopShareSipConnector=async({isP2P:n=!1}={})=>(t.logger("stopShareSipConnector"),this.sipConnector.stopPresentation({isP2P:n}).catch(r=>{t.logger(r)}));sendRefusalToTurnOnMic=async()=>{t.logger("sendRefusalToTurnOnMic"),await this.sipConnector.sendRefusalToTurnOnMic().catch(n=>{t.logger("sendRefusalToTurnOnMic: error",n)})};sendRefusalToTurnOnCam=async()=>{t.logger("sendRefusalToTurnOnCam"),await this.sipConnector.sendRefusalToTurnOnCam().catch(n=>{t.logger("sendRefusalToTurnOnCam: error",n)})};sendMediaState=async({isEnabledCam:n,isEnabledMic:r})=>{t.logger("sendMediaState"),await this.sipConnector.sendMediaState({cam:n,mic:r})};replaceMediaStream=async(n,{deleteExisting:r,addMissing:o,forceRenegotiation:a,contentHint:s,degradationPreference:c,sendEncodings:l,onAddedTransceiver:g})=>(t.logger("replaceMediaStream"),this.sipConnector.replaceMediaStream(n,{deleteExisting:r,addMissing:o,forceRenegotiation:a,contentHint:s,degradationPreference:c,onAddedTransceiver:g,sendEncodings:l}));askPermissionToEnableCam=async()=>{t.logger("askPermissionToEnableCam"),await this.sipConnector.askPermissionToEnableCam()};resolveHandleReadyRemoteStreamsDebounced=({onReadyRemoteStreams:n})=>H.debounce(()=>{const r=this.sipConnector.getRemoteStreams();t.logger("remoteStreams",r),n(r)},200);resolveHandleReadyRemoteStreams=({onReadyRemoteStreams:n})=>({track:r})=>{be(r)&&n()};getRemoteStreams=()=>(t.logger("getRemoteStreams"),this.sipConnector.getRemoteStreams());onUseLicense=n=>(t.logger("onUseLicense"),this.sipConnector.on("api:useLicense",n));onMustStopPresentation=n=>(t.logger("onMustStopPresentation"),this.sipConnector.on("api:mustStopPresentation",n));onMoveToSpectators=n=>(t.logger("onMoveToSpectators"),this.sipConnector.on("api:participant:move-request-to-spectators",n));onMoveToParticipants=n=>(t.logger("onMoveToParticipants"),this.sipConnector.on("api:participant:move-request-to-participants",n));onStats=n=>(t.logger("onStats"),this.sipConnector.on("stats:collected",n));offStats=n=>{t.logger("offStats"),this.sipConnector.off("stats:collected",n)}}var G=(e=>(e.VP8="video/VP8",e.VP9="video/VP9",e.H264="video/H264",e.AV1="video/AV1",e.rtx="video/rtx",e.red="video/red",e.flexfec03="video/flexfec-03",e))(G||{});exports.ECallCause=t.ECallCause;exports.ECallStatus=t.EState$1;exports.EConnectionStatus=t.EState;exports.EIncomingStatus=t.EState$2;exports.EPresentationStatus=t.EState$3;exports.EStatsTypes=t.EStatsTypes;exports.EUseLicense=t.EUseLicense;exports.SipConnector=t.SipConnector;exports.StatsPeerConnection=t.StatsPeerConnection;exports.disableDebug=t.disableDebug;exports.enableDebug=t.enableDebug;exports.getCodecFromSender=t.getCodecFromSender;exports.hasCanceledStartPresentationError=t.hasCanceledStartPresentationError;Object.defineProperty(exports,"hasConnectionPromiseIsNotActualError",{enumerable:!0,get:()=>K.isPromiseIsNotActualError});exports.EMimeTypesVideoCodecs=G;exports.ESystemStatus=C;exports.SipConnectorFacade=ve;exports.hasAvailableStats=_e;exports.hasCanceledCallError=J;exports.sessionSelectors=te;exports.tools=Oe;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./@SipConnector-B7rwpjv6.cjs");require("events-constructor");const k=require("@krivega/cancelable-promise"),W=require("repeated-calls"),H=require("ts-debounce"),Y=require("ua-parser-js"),j=require("sequent-promises"),K=require("stack-promises"),X=e=>e instanceof Object&&("originator"in e||"cause"in e),J=e=>{if(k.isCanceledError(e))return!0;if(!X(e))return!1;const{originator:n,cause:r}=e;return typeof r=="string"?r===t.ECallCause.REQUEST_TIMEOUT||r===t.ECallCause.REJECTED||n==="local"&&(r===t.ECallCause.CANCELED||r===t.ECallCause.BYE):!1};var C=(e=>(e.DISCONNECTED="system:disconnected",e.CONNECTING="system:connecting",e.READY_TO_CALL="system:readyToCall",e.CALL_CONNECTING="system:callConnecting",e.CALL_ACTIVE="system:callActive",e.CONNECTION_FAILED="system:connectionFailed",e.CALL_FAILED="system:callFailed",e))(C||{});const V=e=>e.connection.value,F=e=>e.call.value,z=e=>e.incoming.value,Q=e=>{if(e.incoming.value!==t.EState$2.IDLE)return e.incoming.context.remoteCallerData},Z=e=>e.presentation.value,ee=e=>{const n=F(e);return n===t.EState$1.IN_CALL||n===t.EState$1.ACCEPTED},ne=e=>{const n=V(e),r=F(e);if(n===t.EState.IDLE||n===t.EState.DISCONNECTED)return C.DISCONNECTED;if(n===t.EState.FAILED)return C.CONNECTION_FAILED;if(n===t.EState.PREPARING||n===t.EState.CONNECTING||n===t.EState.CONNECTED||n===t.EState.REGISTERED)return C.CONNECTING;switch(r){case t.EState$1.IDLE:return C.READY_TO_CALL;case t.EState$1.CONNECTING:return C.CALL_CONNECTING;case t.EState$1.ACCEPTED:case t.EState$1.IN_CALL:return C.CALL_ACTIVE;case t.EState$1.ENDED:return C.READY_TO_CALL;case t.EState$1.FAILED:return C.CALL_FAILED;default:return C.READY_TO_CALL}},te={selectConnectionStatus:V,selectCallStatus:F,selectIncomingStatus:z,selectIncomingRemoteCaller:Q,selectPresentationStatus:Z,selectIsInCall:ee,selectSystemStatus:ne},re=()=>globalThis.process?.versions?.electron!==void 0,x=()=>{const e=new Y.UAParser,{name:n}=e.getBrowser(),r=re();return{isChrome:n==="Chrome"||r}},v=e=>{const{url:n,cause:r}=e;let o=n;return(r===t.ECallCause.BAD_MEDIA_DESCRIPTION||r===t.ECallCause.NOT_FOUND)&&(o=`${e.message.to.uri.user}@${e.message.to.uri.host}`),o};var B=(e=>(e.CONNECT_SERVER_FAILED="CONNECT_SERVER_FAILED",e.WRONG_USER_OR_PASSWORD="WRONG_USER_OR_PASSWORD",e.BAD_MEDIA_ERROR="BAD_MEDIA_ERROR",e.NOT_FOUND_ERROR="NOT_FOUND_ERROR",e.WS_CONNECTION_FAILED="WS_CONNECTION_FAILED",e.CONNECT_SERVER_FAILED_BY_LINK="CONNECT_SERVER_FAILED_BY_LINK",e))(B||{});const oe=new Error("Unknown error"),se=(e=oe)=>{const{cause:n,socket:r}=e;let o="CONNECT_SERVER_FAILED";switch(n){case"Forbidden":{o="WRONG_USER_OR_PASSWORD";break}case t.ECallCause.BAD_MEDIA_DESCRIPTION:{o="BAD_MEDIA_ERROR";break}case t.ECallCause.NOT_FOUND:{o="NOT_FOUND_ERROR";break}default:r!==void 0&&r._ws?.readyState===3?o="WS_CONNECTION_FAILED":v(e)!==void 0&&v(e)!==""&&(o="CONNECT_SERVER_FAILED_BY_LINK")}return o},ae=e=>{let n="";try{n=JSON.stringify(e)}catch(r){t.logger("failed to stringify message",r)}return n},ce=new Error("Unknown error"),ie=(e=ce)=>{const{code:n,cause:r,message:o}=e,a=v(e),s={code:"",cause:"",message:""};return typeof o=="object"&&o!==null?s.message=ae(o):o&&(s.message=String(o)),a!==void 0&&a!==""&&(s.link=a),n!==void 0&&n!==""&&(s.code=n),r!==void 0&&r!==""&&(s.cause=r),s},le=Object.freeze(Object.defineProperty({__proto__:null,EErrorTypes:B,getLinkError:v,getTypeFromError:se,getValuesFromError:ie},Symbol.toStringTag,{value:"Module"})),ue=({sessionId:e,remoteAddress:n,isMutedAudio:r,isMutedVideo:o,isRegistered:a,isPresentationCall:s})=>{const c=[],l=r?"0":"1",g=o?"0":"1";return c.push(`X-Vinteo-Mic-State: ${l}`,`X-Vinteo-MainCam-State: ${g}`),(a===!1||a===void 0)&&c.push("X-Vinteo-Purgatory-Call: yes"),e!==void 0&&e!==""&&c.push(`X-Vinteo-Session: ${e}`),s===!0&&c.push("X-Vinteo-Presentation-Call: yes"),n!==void 0&&n!==""&&c.push(`X-Vinteo-Remote: ${n}`),c},Ce="[@*!|]",ge="_",de=e=>{let n=e;return n=n.replaceAll(new RegExp(Ce,"g"),ge),n},Se=({appName:e,appVersion:n,browserName:r,browserVersion:o})=>{const s=`${de(e)} ${n}`;return`ChromeNew - ${r===void 0?s:`${r} ${o}, ${s}`}`},Ee=({isUnifiedSdpSemantic:e,appVersion:n,browserName:r,browserVersion:o,appName:a})=>e?Se({appVersion:n,browserName:r,browserVersion:o,appName:a}):"Chrome",q="purgatory",D=e=>e===q,fe=e=>n=>[...n].map(o=>async()=>e(o)),me=async({accumulatedKeys:e,sendKey:n,canRunTask:r})=>{const a=fe(n)(e);return j.sequentPromises(a,r)},pe=e=>r=>(t.logger("onStartMainCam"),e.on("api:admin-start-main-cam",r)),he=e=>r=>(t.logger("onStartMic"),e.on("api:admin-start-mic",r)),Re=e=>r=>(t.logger("onStopMainCam"),e.on("api:admin-stop-main-cam",r)),Te=e=>r=>(t.logger("onStopMic"),e.on("api:admin-stop-mic",r)),Ne=({sipConnector:e})=>{const n=(u,d)=>({isSyncForced:S})=>{if(S===!0){u();return}d()},r=pe(e),o=Re(e),a=he(e),s=Te(e);let c,l,g,p;const N=({onStartMainCamForced:u,onStartMainCamNotForced:d,onStopMainCamForced:S,onStopMainCamNotForced:R,onStartMicForced:T,onStartMicNotForced:A,onStopMicForced:b,onStopMicNotForced:P})=>{const E=n(u,d);c=r(E);const f=n(S,R);l=o(f);const I=n(T,A);g=a(I);const m=n(b,P);p=s(m)},O=()=>{c?.(),l?.(),g?.(),p?.()};return{start:u=>{N(u)},stop:()=>{O()}}},Oe=Object.freeze(Object.defineProperty({__proto__:null,PURGATORY_CONFERENCE_NUMBER:q,createSyncMediaState:Ne,createUaParser:x,error:le,getExtraHeaders:ue,getUserAgent:Ee,hasPurgatory:D,prepareMediaStream:t.prepareMediaStream,sendDtmfAccumulated:me,sendOffer:t.sendOffer,setEncodingsToSender:t.setEncodingsToSender,setParametersToSender:t.setParametersToSender},Symbol.toStringTag,{value:"Module"})),_e=()=>x().isChrome,Ae=e=>{if(!k.isCanceledError(e)&&!W.hasCanceledError(e)&&!t.hasNotReadyForConnectionError(e))throw e;return{configuration:void 0,isSuccessful:!1}},be=({kind:e,readyState:n})=>e==="video"&&n==="live",w=(e,n,{onEnterPurgatory:r,onEnterConference:o})=>{D(e)?r&&r():o&&o({isSuccessProgressCall:n})},U=(e,n)=>{e(),n&&n()},$=(e,n,r)=>{throw e&&e(),n(),r},Pe=new Set(["on","once","onceRace","wait","off","sendDTMF","hangUp","declineToIncomingCall","sendChannels","checkTelephony","waitChannels","ping","startAutoConnect","stopAutoConnect","connection","isConfigured","isRegistered"]);class ve{on;once;onceRace;wait;off;sendDTMF;hangUp;declineToIncomingCall;sendChannels;checkTelephony;waitChannels;ping;startAutoConnect;stopAutoConnect;connection;isConfigured;isRegistered;sipConnector;constructor(n){return this.sipConnector=n,new Proxy(this,{get:(r,o,a)=>{if(typeof o=="string"&&Pe.has(o)&&o in this.sipConnector){const c=Reflect.get(this.sipConnector,o,this.sipConnector);return typeof c=="function"?c.bind(this.sipConnector):c}const s=Reflect.get(r,o,a);return typeof s=="function"?s.bind(r):s}})}connectToServer=async(n,r)=>this.sipConnector.connect(n,r).then(o=>(t.logger("connectToServer then"),{configuration:o,isSuccessful:!0})).catch(async o=>(t.logger("connectToServer catch: error",o),Ae(o)));callToServer=async n=>{const{conference:r,mediaStream:o,extraHeaders:a,iceServers:s,contentHint:c,degradationPreference:l,sendEncodings:g,offerToReceiveAudio:p,offerToReceiveVideo:N,directionVideo:O,directionAudio:_,onBeforeProgressCall:h,onSuccessProgressCall:u,onEnterPurgatory:d,onEnterConference:S,onFailProgressCall:R,onFinishProgressCall:T,onEndedCall:A,onAddedTransceiver:b}=n;t.logger("callToServer",n);const P=async()=>(t.logger("startCall"),this.sipConnector.call({mediaStream:o,extraHeaders:a,iceServers:s,contentHint:c,offerToReceiveAudio:p,offerToReceiveVideo:N,directionVideo:O,directionAudio:_,degradationPreference:l,onAddedTransceiver:b,sendEncodings:g,number:r}));let E=!1,f;const m=(t.logger("subscribeEnterConference: onEnterConference",S),this.sipConnector.on("api:enterRoom",({room:i})=>{t.logger("enterRoom",{_room:i,isSuccessProgressCall:E}),f=i,(d??S)&&w(f,E,{onEnterPurgatory:d,onEnterConference:S})})),M=i=>(t.logger("onSuccess"),E=!0,u&&u({isPurgatory:D(f)}),this.sipConnector.onceRace(["call:ended","call:failed"],()=>{U(m,A)}),i),y=i=>(t.logger("onFail"),$(R,m,i)),L=()=>{t.logger("onFinish"),T&&T()};return t.logger("onBeforeProgressCall"),h&&h(r),P().then(M).catch(i=>y(i)).finally(L)};disconnectFromServer=async()=>this.sipConnector.disconnect().then(()=>(t.logger("disconnectFromServer: then"),{isSuccessful:!0})).catch(n=>(t.logger("disconnectFromServer: catch",n),{isSuccessful:!1}));answerToIncomingCall=async n=>{const{mediaStream:r,extraHeaders:o,iceServers:a,contentHint:s,degradationPreference:c,sendEncodings:l,offerToReceiveAudio:g,offerToReceiveVideo:p,directionVideo:N,directionAudio:O,onBeforeProgressCall:_,onSuccessProgressCall:h,onEnterPurgatory:u,onEnterConference:d,onFailProgressCall:S,onFinishProgressCall:R,onEndedCall:T,onAddedTransceiver:A}=n;t.logger("answerToIncomingCall",n);const b=async()=>this.sipConnector.answerToIncomingCall({mediaStream:r,extraHeaders:o,iceServers:a,contentHint:s,offerToReceiveAudio:g,offerToReceiveVideo:p,directionVideo:N,directionAudio:O,degradationPreference:c,onAddedTransceiver:A,sendEncodings:l}),P=()=>{const{remoteCallerData:i}=this.sipConnector;return i.incomingNumber};let E=!1,f;const m=(t.logger("subscribeEnterConference: onEnterConference",d),this.sipConnector.on("api:enterRoom",i=>{t.logger("enterRoom",{room:i.room,isSuccessProgressCall:E}),f=i.room,(u??d)&&w(f,E,{onEnterPurgatory:u,onEnterConference:d})})),M=i=>(t.logger("onSuccess"),E=!0,h&&h({isPurgatory:D(f)}),this.sipConnector.onceRace(["call:ended","call:failed"],()=>{U(m,T)}),i),y=i=>(t.logger("onFail"),$(S,m,i)),L=()=>{t.logger("onFinish"),R&&R()};if(t.logger("onBeforeProgressCall"),_){const i=P();_(i)}return b().then(M).catch(i=>y(i)).finally(L)};updatePresentation=async({mediaStream:n,isP2P:r,contentHint:o,degradationPreference:a,sendEncodings:s,onAddedTransceiver:c})=>(t.logger("updatePresentation"),this.sipConnector.updatePresentation(n,{isP2P:r,contentHint:o,degradationPreference:a,onAddedTransceiver:c,sendEncodings:s}));startPresentation=async({mediaStream:n,isP2P:r,contentHint:o,degradationPreference:a,sendEncodings:s,callLimit:c,onAddedTransceiver:l})=>(t.logger("startPresentation"),this.sipConnector.startPresentation(n,{isP2P:r,contentHint:o,callLimit:c,degradationPreference:a,onAddedTransceiver:l,sendEncodings:s}));stopShareSipConnector=async({isP2P:n=!1}={})=>(t.logger("stopShareSipConnector"),this.sipConnector.stopPresentation({isP2P:n}).catch(r=>{t.logger(r)}));sendRefusalToTurnOnMic=async()=>{t.logger("sendRefusalToTurnOnMic"),await this.sipConnector.sendRefusalToTurnOnMic().catch(n=>{t.logger("sendRefusalToTurnOnMic: error",n)})};sendRefusalToTurnOnCam=async()=>{t.logger("sendRefusalToTurnOnCam"),await this.sipConnector.sendRefusalToTurnOnCam().catch(n=>{t.logger("sendRefusalToTurnOnCam: error",n)})};sendMediaState=async({isEnabledCam:n,isEnabledMic:r})=>{t.logger("sendMediaState"),await this.sipConnector.sendMediaState({cam:n,mic:r})};replaceMediaStream=async(n,{deleteExisting:r,addMissing:o,forceRenegotiation:a,contentHint:s,degradationPreference:c,sendEncodings:l,onAddedTransceiver:g})=>(t.logger("replaceMediaStream"),this.sipConnector.replaceMediaStream(n,{deleteExisting:r,addMissing:o,forceRenegotiation:a,contentHint:s,degradationPreference:c,onAddedTransceiver:g,sendEncodings:l}));askPermissionToEnableCam=async()=>{t.logger("askPermissionToEnableCam"),await this.sipConnector.askPermissionToEnableCam()};resolveHandleReadyRemoteStreamsDebounced=({onReadyRemoteStreams:n})=>H.debounce(()=>{const r=this.sipConnector.getRemoteStreams();t.logger("remoteStreams",r),n(r)},200);resolveHandleReadyRemoteStreams=({onReadyRemoteStreams:n})=>({track:r})=>{be(r)&&n()};getRemoteStreams=()=>(t.logger("getRemoteStreams"),this.sipConnector.getRemoteStreams());onUseLicense=n=>(t.logger("onUseLicense"),this.sipConnector.on("api:useLicense",n));onMustStopPresentation=n=>(t.logger("onMustStopPresentation"),this.sipConnector.on("api:mustStopPresentation",n));onMoveToSpectators=n=>(t.logger("onMoveToSpectators"),this.sipConnector.on("api:participant:move-request-to-spectators",n));onMoveToParticipants=n=>(t.logger("onMoveToParticipants"),this.sipConnector.on("api:participant:move-request-to-participants",n));onStats=n=>(t.logger("onStats"),this.sipConnector.on("stats:collected",n));offStats=n=>{t.logger("offStats"),this.sipConnector.off("stats:collected",n)}}var G=(e=>(e.VP8="video/VP8",e.VP9="video/VP9",e.H264="video/H264",e.AV1="video/AV1",e.rtx="video/rtx",e.red="video/red",e.flexfec03="video/flexfec-03",e))(G||{});exports.ECallCause=t.ECallCause;exports.ECallStatus=t.EState$1;exports.EConnectionStatus=t.EState;exports.EIncomingStatus=t.EState$2;exports.EPresentationStatus=t.EState$3;exports.EStatsTypes=t.EStatsTypes;exports.EUseLicense=t.EUseLicense;exports.SipConnector=t.SipConnector;exports.StatsPeerConnection=t.StatsPeerConnection;exports.disableDebug=t.disableDebug;exports.enableDebug=t.enableDebug;exports.getCodecFromSender=t.getCodecFromSender;exports.hasCanceledStartPresentationError=t.hasCanceledStartPresentationError;Object.defineProperty(exports,"hasConnectionPromiseIsNotActualError",{enumerable:!0,get:()=>K.isPromiseIsNotActualError});exports.EMimeTypesVideoCodecs=G;exports.ESystemStatus=C;exports.SipConnectorFacade=ve;exports.hasAvailableStats=_e;exports.hasCanceledCallError=J;exports.sessionSelectors=te;exports.tools=Oe;
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export { sessionSelectors, ECallStatus, EConnectionStatus, EIncomingStatus, EPre
|
|
|
11
11
|
export * as tools from './tools';
|
|
12
12
|
export { EMimeTypesVideoCodecs } from './types';
|
|
13
13
|
export type { TSessionSnapshot } from './SessionManager';
|
|
14
|
-
export type { TCustomError } from './CallManager';
|
|
14
|
+
export type { TCustomError, TRemoteStreams } from './CallManager';
|
|
15
15
|
export type { TParametersConnection, TConnectionConfigurationWithUa } from './ConnectionManager';
|
|
16
16
|
export type { TInboundStats, TOutboundStats } from './StatsPeerConnection';
|
|
17
17
|
export type { TContentHint } from './PresentationManager';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as h, a as R, b as p, c as j, l as r, p as K, s as X, d as q, e as z, h as J } from "./@SipConnector-
|
|
2
|
-
import { o as je, k as Ke, f as Xe, S as qe, m as ze, g as Je, i as Qe, n as Ze, j as en } from "./@SipConnector-
|
|
1
|
+
import { E as h, a as R, b as p, c as j, l as r, p as K, s as X, d as q, e as z, h as J } from "./@SipConnector-CQ2xR48Y.js";
|
|
2
|
+
import { o as je, k as Ke, f as Xe, S as qe, m as ze, g as Je, i as Qe, n as Ze, j as en } from "./@SipConnector-CQ2xR48Y.js";
|
|
3
3
|
import "events-constructor";
|
|
4
4
|
import { isCanceledError as B } from "@krivega/cancelable-promise";
|
|
5
5
|
import { hasCanceledError as Q } from "repeated-calls";
|