sip-connector 20.2.1 → 20.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +116 -1
- package/dist/@SipConnector-C-73R76v.cjs +1 -0
- package/dist/{@SipConnector-OO78fz6E.js → @SipConnector-D4SHRHKj.js} +1925 -767
- package/dist/CallManager/CallStateMachine.d.ts +83 -0
- package/dist/ConnectionManager/ConnectionStateMachine.d.ts +53 -4
- package/dist/IncomingCallManager/IncomingCallStateMachine.d.ts +114 -0
- package/dist/PresentationManager/PresentationStateMachine.d.ts +101 -0
- package/dist/SipConnector/@SipConnector.d.ts +4 -1
- package/dist/SipConnector/events.d.ts +2 -2
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +206 -188
- package/dist/session/createSession.d.ts +26 -0
- package/dist/session/index.d.ts +5 -0
- package/dist/session/selectors.d.ts +10 -0
- package/dist/session/types.d.ts +20 -0
- package/dist/tools/BaseStateMachine.d.ts +18 -0
- package/package.json +1 -1
- package/dist/@SipConnector-BTqBRDjY.cjs +0 -1
- package/dist/CallManager/@CallManager.d.ts +0 -60
- package/dist/ConnectionManager/@ConnectionManager.d.ts +0 -57
- package/dist/IncomingCallManager/@IncomingCallManager.d.ts +0 -29
- package/dist/PresentationManager/@PresentationManager.d.ts +0 -49
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { BaseStateMachine } from '../tools/BaseStateMachine';
|
|
2
|
+
import { ActorRefFrom, SnapshotFrom } from 'xstate';
|
|
3
|
+
import { TEvents } from './events';
|
|
4
|
+
export declare enum EState {
|
|
5
|
+
IDLE = "call:idle",
|
|
6
|
+
CONNECTING = "call:connecting",
|
|
7
|
+
RINGING = "call:ringing",
|
|
8
|
+
ACCEPTED = "call:accepted",
|
|
9
|
+
IN_CALL = "call:inCall",
|
|
10
|
+
ENDED = "call:ended",
|
|
11
|
+
FAILED = "call:failed"
|
|
12
|
+
}
|
|
13
|
+
type TCallEvent = {
|
|
14
|
+
type: 'CALL.CONNECTING';
|
|
15
|
+
} | {
|
|
16
|
+
type: 'CALL.RINGING';
|
|
17
|
+
} | {
|
|
18
|
+
type: 'CALL.ACCEPTED';
|
|
19
|
+
} | {
|
|
20
|
+
type: 'CALL.CONFIRMED';
|
|
21
|
+
} | {
|
|
22
|
+
type: 'CALL.ENDED';
|
|
23
|
+
} | {
|
|
24
|
+
type: 'CALL.FAILED';
|
|
25
|
+
error?: unknown;
|
|
26
|
+
} | {
|
|
27
|
+
type: 'CALL.RESET';
|
|
28
|
+
};
|
|
29
|
+
interface ICallContext {
|
|
30
|
+
lastError?: Error;
|
|
31
|
+
}
|
|
32
|
+
declare const callMachine: import('xstate').StateMachine<ICallContext, {
|
|
33
|
+
type: "CALL.CONNECTING";
|
|
34
|
+
} | {
|
|
35
|
+
type: "CALL.RINGING";
|
|
36
|
+
} | {
|
|
37
|
+
type: "CALL.ACCEPTED";
|
|
38
|
+
} | {
|
|
39
|
+
type: "CALL.CONFIRMED";
|
|
40
|
+
} | {
|
|
41
|
+
type: "CALL.ENDED";
|
|
42
|
+
} | {
|
|
43
|
+
type: "CALL.FAILED";
|
|
44
|
+
error?: unknown;
|
|
45
|
+
} | {
|
|
46
|
+
type: "CALL.RESET";
|
|
47
|
+
}, {}, never, {
|
|
48
|
+
type: "rememberError";
|
|
49
|
+
params: import('xstate').NonReducibleUnknown;
|
|
50
|
+
} | {
|
|
51
|
+
type: "resetError";
|
|
52
|
+
params: import('xstate').NonReducibleUnknown;
|
|
53
|
+
}, never, never, EState, string, import('xstate').NonReducibleUnknown, import('xstate').NonReducibleUnknown, import('xstate').EventObject, import('xstate').MetaObject, {
|
|
54
|
+
id: "call";
|
|
55
|
+
states: {
|
|
56
|
+
readonly "call:idle": {};
|
|
57
|
+
readonly "call:connecting": {};
|
|
58
|
+
readonly "call:ringing": {};
|
|
59
|
+
readonly "call:accepted": {};
|
|
60
|
+
readonly "call:inCall": {};
|
|
61
|
+
readonly "call:ended": {};
|
|
62
|
+
readonly "call:failed": {};
|
|
63
|
+
};
|
|
64
|
+
}>;
|
|
65
|
+
export type TCallSnapshot = SnapshotFrom<typeof callMachine>;
|
|
66
|
+
export type TCallActor = ActorRefFrom<typeof callMachine>;
|
|
67
|
+
export declare class CallStateMachine extends BaseStateMachine<typeof callMachine, EState> {
|
|
68
|
+
constructor(events: TEvents);
|
|
69
|
+
get isIdle(): boolean;
|
|
70
|
+
get isConnecting(): boolean;
|
|
71
|
+
get isRinging(): boolean;
|
|
72
|
+
get isAccepted(): boolean;
|
|
73
|
+
get isInCall(): boolean;
|
|
74
|
+
get isEnded(): boolean;
|
|
75
|
+
get isFailed(): boolean;
|
|
76
|
+
get isActive(): boolean;
|
|
77
|
+
get isPending(): boolean;
|
|
78
|
+
get lastError(): Error | undefined;
|
|
79
|
+
reset(): void;
|
|
80
|
+
send(event: TCallEvent): void;
|
|
81
|
+
private subscribeToEvents;
|
|
82
|
+
}
|
|
83
|
+
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { BaseStateMachine } from '../tools/BaseStateMachine';
|
|
2
|
+
import { ActorRefFrom, SnapshotFrom } from 'xstate';
|
|
1
3
|
import { TEvents } from './events';
|
|
2
4
|
export declare enum EEvents {
|
|
3
5
|
START_CONNECT = "START_CONNECT",
|
|
@@ -10,6 +12,13 @@ export declare enum EEvents {
|
|
|
10
12
|
RESET = "RESET"
|
|
11
13
|
}
|
|
12
14
|
type TConnectionMachineEvent = `${EEvents}`;
|
|
15
|
+
type TConnectionFailedEvent = {
|
|
16
|
+
type: typeof EEvents.CONNECTION_FAILED;
|
|
17
|
+
error?: Error;
|
|
18
|
+
};
|
|
19
|
+
interface IConnectionMachineContext {
|
|
20
|
+
error?: Error;
|
|
21
|
+
}
|
|
13
22
|
export declare enum EState {
|
|
14
23
|
IDLE = "connection:idle",
|
|
15
24
|
CONNECTING = "connection:connecting",
|
|
@@ -19,14 +28,51 @@ export declare enum EState {
|
|
|
19
28
|
DISCONNECTED = "connection:disconnected",
|
|
20
29
|
FAILED = "connection:failed"
|
|
21
30
|
}
|
|
22
|
-
|
|
23
|
-
|
|
31
|
+
declare enum EAction {
|
|
32
|
+
LOG_TRANSITION = "logTransition",
|
|
33
|
+
LOG_STATE_CHANGE = "logStateChange",
|
|
34
|
+
SET_ERROR = "setError",
|
|
35
|
+
CLEAR_ERROR = "clearError"
|
|
36
|
+
}
|
|
37
|
+
declare const connectionMachine: import('xstate').StateMachine<IConnectionMachineContext, TConnectionFailedEvent | {
|
|
38
|
+
type: TConnectionMachineEvent;
|
|
39
|
+
}, {}, never, {
|
|
40
|
+
type: EAction.LOG_TRANSITION;
|
|
41
|
+
params: {
|
|
42
|
+
from: string;
|
|
43
|
+
to: string;
|
|
44
|
+
event: string;
|
|
45
|
+
};
|
|
46
|
+
} | {
|
|
47
|
+
type: EAction.LOG_STATE_CHANGE;
|
|
48
|
+
params: {
|
|
49
|
+
state: string;
|
|
50
|
+
};
|
|
51
|
+
} | {
|
|
52
|
+
type: EAction.SET_ERROR;
|
|
53
|
+
params: import('xstate').NonReducibleUnknown;
|
|
54
|
+
} | {
|
|
55
|
+
type: EAction.CLEAR_ERROR;
|
|
56
|
+
params: import('xstate').NonReducibleUnknown;
|
|
57
|
+
}, never, never, EState, string, import('xstate').NonReducibleUnknown, import('xstate').NonReducibleUnknown, import('xstate').EventObject, import('xstate').MetaObject, {
|
|
58
|
+
id: "connection";
|
|
59
|
+
states: {
|
|
60
|
+
readonly "connection:idle": {};
|
|
61
|
+
readonly "connection:connecting": {};
|
|
62
|
+
readonly "connection:initializing": {};
|
|
63
|
+
readonly "connection:connected": {};
|
|
64
|
+
readonly "connection:registered": {};
|
|
65
|
+
readonly "connection:disconnected": {};
|
|
66
|
+
readonly "connection:failed": {};
|
|
67
|
+
};
|
|
68
|
+
}>;
|
|
69
|
+
export type TConnectionSnapshot = SnapshotFrom<typeof connectionMachine>;
|
|
70
|
+
export type TConnectionActor = ActorRefFrom<typeof connectionMachine>;
|
|
71
|
+
export default class ConnectionStateMachine extends BaseStateMachine<typeof connectionMachine, EState> {
|
|
24
72
|
private readonly stateChangeListeners;
|
|
25
73
|
private readonly events;
|
|
26
74
|
private unsubscribeFromEvents?;
|
|
27
|
-
private readonly actorSubscription?;
|
|
28
75
|
constructor(events: TEvents);
|
|
29
|
-
get state(): EState;
|
|
30
76
|
get isIdle(): boolean;
|
|
31
77
|
get isConnecting(): boolean;
|
|
32
78
|
get isInitializing(): boolean;
|
|
@@ -34,6 +80,7 @@ export default class ConnectionStateMachine {
|
|
|
34
80
|
get isRegistered(): boolean;
|
|
35
81
|
get isDisconnected(): boolean;
|
|
36
82
|
get isFailed(): boolean;
|
|
83
|
+
get error(): Error | undefined;
|
|
37
84
|
get isPending(): boolean;
|
|
38
85
|
get isPendingConnect(): boolean;
|
|
39
86
|
get isPendingInitUa(): boolean;
|
|
@@ -56,5 +103,7 @@ export default class ConnectionStateMachine {
|
|
|
56
103
|
private readonly toFailed;
|
|
57
104
|
private readonly toIdle;
|
|
58
105
|
private subscribeToEvents;
|
|
106
|
+
private readonly handleRegistrationFailed;
|
|
107
|
+
private readonly handleConnectFailed;
|
|
59
108
|
}
|
|
60
109
|
export {};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { BaseStateMachine } from '../tools/BaseStateMachine';
|
|
2
|
+
import { ActorRefFrom, SnapshotFrom } from 'xstate';
|
|
3
|
+
import { TEvents as TConnectionEvents } from '../ConnectionManager/events';
|
|
4
|
+
import { TEvents as TIncomingEvents, TRemoteCallerData } from './events';
|
|
5
|
+
export declare enum EState {
|
|
6
|
+
IDLE = "incoming:idle",
|
|
7
|
+
RINGING = "incoming:ringing",
|
|
8
|
+
CONSUMED = "incoming:consumed",
|
|
9
|
+
DECLINED = "incoming:declined",
|
|
10
|
+
TERMINATED = "incoming:terminated",
|
|
11
|
+
FAILED = "incoming:failed"
|
|
12
|
+
}
|
|
13
|
+
declare enum EAction {
|
|
14
|
+
LOG_TRANSITION = "logTransition",
|
|
15
|
+
LOG_STATE_CHANGE = "logStateChange",
|
|
16
|
+
REMEMBER_INCOMING = "rememberIncoming",
|
|
17
|
+
REMEMBER_REASON = "rememberReason",
|
|
18
|
+
CLEAR_INCOMING = "clearIncoming"
|
|
19
|
+
}
|
|
20
|
+
type TIncomingEvent = {
|
|
21
|
+
type: 'INCOMING.RINGING';
|
|
22
|
+
data: TRemoteCallerData;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'INCOMING.CONSUMED';
|
|
25
|
+
} | {
|
|
26
|
+
type: 'INCOMING.DECLINED';
|
|
27
|
+
data: TRemoteCallerData;
|
|
28
|
+
} | {
|
|
29
|
+
type: 'INCOMING.TERMINATED';
|
|
30
|
+
data: TRemoteCallerData;
|
|
31
|
+
} | {
|
|
32
|
+
type: 'INCOMING.FAILED';
|
|
33
|
+
data: TRemoteCallerData;
|
|
34
|
+
} | {
|
|
35
|
+
type: 'INCOMING.CLEAR';
|
|
36
|
+
};
|
|
37
|
+
interface IIncomingContext {
|
|
38
|
+
remoteCallerData?: TRemoteCallerData;
|
|
39
|
+
lastReason?: EState.CONSUMED | EState.DECLINED | EState.TERMINATED | EState.FAILED;
|
|
40
|
+
}
|
|
41
|
+
declare const incomingMachine: import('xstate').StateMachine<IIncomingContext, {
|
|
42
|
+
type: "INCOMING.RINGING";
|
|
43
|
+
data: TRemoteCallerData;
|
|
44
|
+
} | {
|
|
45
|
+
type: "INCOMING.CONSUMED";
|
|
46
|
+
} | {
|
|
47
|
+
type: "INCOMING.DECLINED";
|
|
48
|
+
data: TRemoteCallerData;
|
|
49
|
+
} | {
|
|
50
|
+
type: "INCOMING.TERMINATED";
|
|
51
|
+
data: TRemoteCallerData;
|
|
52
|
+
} | {
|
|
53
|
+
type: "INCOMING.FAILED";
|
|
54
|
+
data: TRemoteCallerData;
|
|
55
|
+
} | {
|
|
56
|
+
type: "INCOMING.CLEAR";
|
|
57
|
+
}, {}, never, {
|
|
58
|
+
type: EAction.LOG_TRANSITION;
|
|
59
|
+
params: {
|
|
60
|
+
from: string;
|
|
61
|
+
to: string;
|
|
62
|
+
event: string;
|
|
63
|
+
};
|
|
64
|
+
} | {
|
|
65
|
+
type: EAction.LOG_STATE_CHANGE;
|
|
66
|
+
params: {
|
|
67
|
+
state: string;
|
|
68
|
+
};
|
|
69
|
+
} | {
|
|
70
|
+
type: EAction.REMEMBER_INCOMING;
|
|
71
|
+
params: import('xstate').NonReducibleUnknown;
|
|
72
|
+
} | {
|
|
73
|
+
type: EAction.REMEMBER_REASON;
|
|
74
|
+
params: import('xstate').NonReducibleUnknown;
|
|
75
|
+
} | {
|
|
76
|
+
type: EAction.CLEAR_INCOMING;
|
|
77
|
+
params: import('xstate').NonReducibleUnknown;
|
|
78
|
+
}, never, never, EState, string, import('xstate').NonReducibleUnknown, import('xstate').NonReducibleUnknown, import('xstate').EventObject, import('xstate').MetaObject, {
|
|
79
|
+
id: "incoming";
|
|
80
|
+
states: {
|
|
81
|
+
readonly "incoming:idle": {};
|
|
82
|
+
readonly "incoming:ringing": {};
|
|
83
|
+
readonly "incoming:consumed": {};
|
|
84
|
+
readonly "incoming:declined": {};
|
|
85
|
+
readonly "incoming:terminated": {};
|
|
86
|
+
readonly "incoming:failed": {};
|
|
87
|
+
};
|
|
88
|
+
}>;
|
|
89
|
+
export type TIncomingSnapshot = SnapshotFrom<typeof incomingMachine>;
|
|
90
|
+
export type TIncomingActor = ActorRefFrom<typeof incomingMachine>;
|
|
91
|
+
type TDeps = {
|
|
92
|
+
incomingEvents: TIncomingEvents;
|
|
93
|
+
connectionEvents: TConnectionEvents;
|
|
94
|
+
};
|
|
95
|
+
export declare class IncomingCallStateMachine extends BaseStateMachine<typeof incomingMachine, EState> {
|
|
96
|
+
constructor({ incomingEvents, connectionEvents }: TDeps);
|
|
97
|
+
get isIdle(): boolean;
|
|
98
|
+
get isRinging(): boolean;
|
|
99
|
+
get isConsumed(): boolean;
|
|
100
|
+
get isDeclined(): boolean;
|
|
101
|
+
get isTerminated(): boolean;
|
|
102
|
+
get isFailed(): boolean;
|
|
103
|
+
get isActive(): boolean;
|
|
104
|
+
get isFinished(): boolean;
|
|
105
|
+
get remoteCallerData(): TRemoteCallerData | undefined;
|
|
106
|
+
get lastReason(): EState.CONSUMED | EState.DECLINED | EState.TERMINATED | EState.FAILED | undefined;
|
|
107
|
+
reset(): void;
|
|
108
|
+
send(event: TIncomingEvent): void;
|
|
109
|
+
toConsumed(): void;
|
|
110
|
+
private subscribeIncomingEvents;
|
|
111
|
+
private subscribeConnectionEvents;
|
|
112
|
+
private toClearIncoming;
|
|
113
|
+
}
|
|
114
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { BaseStateMachine } from '../tools/BaseStateMachine';
|
|
2
|
+
import { ActorRefFrom, SnapshotFrom } from 'xstate';
|
|
3
|
+
import { TCallEvents } from '../CallManager';
|
|
4
|
+
export declare enum EState {
|
|
5
|
+
IDLE = "presentation:idle",
|
|
6
|
+
STARTING = "presentation:starting",
|
|
7
|
+
ACTIVE = "presentation:active",
|
|
8
|
+
STOPPING = "presentation:stopping",
|
|
9
|
+
FAILED = "presentation:failed"
|
|
10
|
+
}
|
|
11
|
+
declare enum EAction {
|
|
12
|
+
LOG_TRANSITION = "logTransition",
|
|
13
|
+
LOG_STATE_CHANGE = "logStateChange",
|
|
14
|
+
SET_ERROR = "setError",
|
|
15
|
+
CLEAR_ERROR = "clearError"
|
|
16
|
+
}
|
|
17
|
+
type TPresentationEvent = {
|
|
18
|
+
type: 'SCREEN.STARTING';
|
|
19
|
+
} | {
|
|
20
|
+
type: 'SCREEN.STARTED';
|
|
21
|
+
} | {
|
|
22
|
+
type: 'SCREEN.ENDING';
|
|
23
|
+
} | {
|
|
24
|
+
type: 'SCREEN.ENDED';
|
|
25
|
+
} | {
|
|
26
|
+
type: 'SCREEN.FAILED';
|
|
27
|
+
error?: unknown;
|
|
28
|
+
} | {
|
|
29
|
+
type: 'CALL.ENDED';
|
|
30
|
+
} | {
|
|
31
|
+
type: 'CALL.FAILED';
|
|
32
|
+
error?: unknown;
|
|
33
|
+
} | {
|
|
34
|
+
type: 'PRESENTATION.RESET';
|
|
35
|
+
};
|
|
36
|
+
interface IPresentationContext {
|
|
37
|
+
lastError?: Error;
|
|
38
|
+
}
|
|
39
|
+
declare const presentationMachine: import('xstate').StateMachine<IPresentationContext, {
|
|
40
|
+
type: "SCREEN.STARTING";
|
|
41
|
+
} | {
|
|
42
|
+
type: "SCREEN.STARTED";
|
|
43
|
+
} | {
|
|
44
|
+
type: "SCREEN.ENDING";
|
|
45
|
+
} | {
|
|
46
|
+
type: "SCREEN.ENDED";
|
|
47
|
+
} | {
|
|
48
|
+
type: "SCREEN.FAILED";
|
|
49
|
+
error?: unknown;
|
|
50
|
+
} | {
|
|
51
|
+
type: "CALL.ENDED";
|
|
52
|
+
} | {
|
|
53
|
+
type: "CALL.FAILED";
|
|
54
|
+
error?: unknown;
|
|
55
|
+
} | {
|
|
56
|
+
type: "PRESENTATION.RESET";
|
|
57
|
+
}, {}, never, {
|
|
58
|
+
type: EAction.LOG_TRANSITION;
|
|
59
|
+
params: {
|
|
60
|
+
from: string;
|
|
61
|
+
to: string;
|
|
62
|
+
event: string;
|
|
63
|
+
};
|
|
64
|
+
} | {
|
|
65
|
+
type: EAction.LOG_STATE_CHANGE;
|
|
66
|
+
params: {
|
|
67
|
+
state: string;
|
|
68
|
+
};
|
|
69
|
+
} | {
|
|
70
|
+
type: EAction.SET_ERROR;
|
|
71
|
+
params: import('xstate').NonReducibleUnknown;
|
|
72
|
+
} | {
|
|
73
|
+
type: EAction.CLEAR_ERROR;
|
|
74
|
+
params: import('xstate').NonReducibleUnknown;
|
|
75
|
+
}, never, never, EState, string, import('xstate').NonReducibleUnknown, import('xstate').NonReducibleUnknown, import('xstate').EventObject, import('xstate').MetaObject, {
|
|
76
|
+
id: "presentation";
|
|
77
|
+
states: {
|
|
78
|
+
readonly "presentation:idle": {};
|
|
79
|
+
readonly "presentation:starting": {};
|
|
80
|
+
readonly "presentation:active": {};
|
|
81
|
+
readonly "presentation:stopping": {};
|
|
82
|
+
readonly "presentation:failed": {};
|
|
83
|
+
};
|
|
84
|
+
}>;
|
|
85
|
+
export type TPresentationSnapshot = SnapshotFrom<typeof presentationMachine>;
|
|
86
|
+
export type TPresentationActor = ActorRefFrom<typeof presentationMachine>;
|
|
87
|
+
export declare class PresentationStateMachine extends BaseStateMachine<typeof presentationMachine, EState> {
|
|
88
|
+
constructor(callEvents: TCallEvents);
|
|
89
|
+
get isIdle(): boolean;
|
|
90
|
+
get isStarting(): boolean;
|
|
91
|
+
get isActive(): boolean;
|
|
92
|
+
get isStopping(): boolean;
|
|
93
|
+
get isFailed(): boolean;
|
|
94
|
+
get isPending(): boolean;
|
|
95
|
+
get isActiveOrPending(): boolean;
|
|
96
|
+
get lastError(): Error | undefined;
|
|
97
|
+
reset(): void;
|
|
98
|
+
send(event: TPresentationEvent): void;
|
|
99
|
+
private subscribeCallEvents;
|
|
100
|
+
}
|
|
101
|
+
export {};
|
|
@@ -7,6 +7,7 @@ import { IncomingCallManager } from '../IncomingCallManager';
|
|
|
7
7
|
import { PresentationManager, TContentHint, TOnAddedTransceiver } from '../PresentationManager';
|
|
8
8
|
import { StatsManager } from '../StatsManager';
|
|
9
9
|
import { VideoSendingBalancerManager } from '../VideoSendingBalancerManager';
|
|
10
|
+
import { ISession } from '../session';
|
|
10
11
|
import { TJsSIP } from '../types';
|
|
11
12
|
import { IBalancerOptions } from '../VideoSendingBalancer';
|
|
12
13
|
import { TEventMap, TEvents } from './events';
|
|
@@ -21,6 +22,7 @@ declare class SipConnector {
|
|
|
21
22
|
readonly presentationManager: PresentationManager;
|
|
22
23
|
readonly statsManager: StatsManager;
|
|
23
24
|
readonly videoSendingBalancerManager: VideoSendingBalancerManager;
|
|
25
|
+
readonly session: ISession;
|
|
24
26
|
private readonly mainStreamHealthMonitor;
|
|
25
27
|
private readonly mainStreamRecovery;
|
|
26
28
|
private readonly preferredMimeTypesVideoCodecs?;
|
|
@@ -36,7 +38,7 @@ declare class SipConnector {
|
|
|
36
38
|
get requestedConnection(): boolean;
|
|
37
39
|
get isPendingConnect(): boolean;
|
|
38
40
|
get isPendingInitUa(): boolean;
|
|
39
|
-
get connectionState(): import('../
|
|
41
|
+
get connectionState(): import('../session').EConnectionStatus;
|
|
40
42
|
get isRegistered(): boolean;
|
|
41
43
|
get isRegisterConfig(): boolean;
|
|
42
44
|
get socket(): import('@krivega/jssip').WebSocketInterface | undefined;
|
|
@@ -110,6 +112,7 @@ declare class SipConnector {
|
|
|
110
112
|
askPermissionToEnableCam(...args: Parameters<ApiManager['askPermissionToEnableCam']>): Promise<void>;
|
|
111
113
|
private subscribeDisconnectedFromOutOfCall;
|
|
112
114
|
private subscribeConnectedWithConfigurationFromOutOfCall;
|
|
115
|
+
private mayBeStopPresentationAndNotify;
|
|
113
116
|
private subscribeToApiEvents;
|
|
114
117
|
private readonly sendOffer;
|
|
115
118
|
private setCodecPreferences;
|
|
@@ -8,7 +8,7 @@ import { TEventMap as TIncomingCallManagerEventMap } from '../IncomingCallManage
|
|
|
8
8
|
import { TEventMap as TPresentationManagerEventMap } from '../PresentationManager/events';
|
|
9
9
|
import { TEventMap as TStatsManagerEventMap } from '../StatsPeerConnection/events';
|
|
10
10
|
import { TEventMap as TVideoBalancerManagerEventMap } from '../VideoSendingBalancerManager/events';
|
|
11
|
-
export declare const EVENT_NAMES: readonly [...("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:
|
|
11
|
+
export declare const EVENT_NAMES: readonly [...("call:connecting" | "call:accepted" | "call:ended" | "call:failed" | "connection:connecting" | "connection:connected" | "connection:registered" | "connection:disconnected" | "auto-connect:before-attempt" | "auto-connect:success" | "auto-connect:failed-all-attempts" | "auto-connect:cancelled-attempts" | "auto-connect:changed-attempt-status" | "auto-connect:stop-attempts-by-error" | "auto-connect:limit-reached-attempts" | "connection:disconnecting" | "connection:newRTCSession" | "connection:unregistered" | "connection:registrationFailed" | "connection:newMessage" | "connection:sipEvent" | "connection:connect-started" | "connection:connect-succeeded" | "connection:connected-with-configuration" | "connection:connect-failed" | "connection:connect-parameters-resolve-success" | "connection:connect-parameters-resolve-failed" | "call:peerconnection" | "call:sending" | "call:progress" | "call:confirmed" | "call:newDTMF" | "call:newInfo" | "call:reinvite" | "call:update" | "call:refer" | "call:replaces" | "call:sdp" | "call:icecandidate" | "call:getusermediafailed" | "call:peerconnection:createofferfailed" | "call:peerconnection:createanswerfailed" | "call:peerconnection:setlocaldescriptionfailed" | "call:peerconnection:setremotedescriptionfailed" | "call:presentation:start" | "call:presentation:started" | "call:presentation:end" | "call:presentation:ended" | "call:presentation:failed" | "call:peerconnection:confirmed" | "call:peerconnection:ontrack" | "call:ended:fromserver" | "call:call-status-changed" | "call:remote-streams-changed" | "api:channels:notify" | "api:participant:added-to-list-moderators" | "api:participant:removed-from-list-moderators" | "api:participant:move-request-to-stream" | "api:participant:move-request-to-participants" | "api:participant:move-request-to-spectators" | "api:participant:move-request-to-spectators-synthetic" | "api:participant:move-request-to-spectators-with-audio-id" | "api:participation:accepting-word-request" | "api:participation:cancelling-word-request" | "api:webcast:started" | "api:webcast:stopped" | "api:account:changed" | "api:account:deleted" | "api:conference:participant-token-issued" | "api:channels" | "api:enterRoom" | "api:shareState" | "api:main-cam-control" | "api:useLicense" | "api:admin-start-main-cam" | "api:admin-stop-main-cam" | "api:admin-start-mic" | "api:admin-stop-mic" | "api:admin-force-sync-media-state" | "api:availableSecondRemoteStream" | "api:notAvailableSecondRemoteStream" | "api:mustStopPresentation" | "api:newDTMF" | "incoming-call:incomingCall" | "incoming-call:declinedIncomingCall" | "incoming-call:terminatedIncomingCall" | "incoming-call:failedIncomingCall" | "presentation:presentation:start" | "presentation:presentation:started" | "presentation:presentation:end" | "presentation:presentation:ended" | "presentation:presentation:failed" | "stats:collected" | "video-balancer:balancing-scheduled" | "video-balancer:balancing-started" | "video-balancer:balancing-stopped" | "video-balancer:parameters-updated")[], "disconnected-from-out-of-call", "connected-with-configuration-from-out-of-call", "stopped-presentation-by-server-command"];
|
|
12
12
|
export type TEvent = (typeof EVENT_NAMES)[number];
|
|
13
13
|
type PrefixedEventMap<T extends Record<string, unknown>, Prefix extends string> = {
|
|
14
14
|
[K in keyof T as `${Prefix}:${string & K}`]: T[K];
|
|
@@ -20,5 +20,5 @@ type TSipConnectorEventMap = {
|
|
|
20
20
|
};
|
|
21
21
|
export type TEventMap = PrefixedEventMap<TAutoConnectorManagerEventMap, 'auto-connect'> & PrefixedEventMap<TConnectionManagerEventMap, 'connection'> & PrefixedEventMap<TCallManagerEventMap, 'call'> & PrefixedEventMap<TApiManagerEventMap, 'api'> & PrefixedEventMap<TIncomingCallManagerEventMap, 'incoming-call'> & PrefixedEventMap<TPresentationManagerEventMap, 'presentation'> & PrefixedEventMap<TStatsManagerEventMap, 'stats'> & PrefixedEventMap<TVideoBalancerManagerEventMap, 'video-balancer'> & TSipConnectorEventMap;
|
|
22
22
|
export type TEvents = TypedEvents<TEventMap>;
|
|
23
|
-
export declare const createEvents: () => TypedEvents<TEventMap, readonly ("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:
|
|
23
|
+
export declare const createEvents: () => TypedEvents<TEventMap, readonly ("call:connecting" | "call:accepted" | "call:ended" | "call:failed" | "connection:connecting" | "connection:connected" | "connection:registered" | "connection:disconnected" | "auto-connect:before-attempt" | "auto-connect:success" | "auto-connect:failed-all-attempts" | "auto-connect:cancelled-attempts" | "auto-connect:changed-attempt-status" | "auto-connect:stop-attempts-by-error" | "auto-connect:limit-reached-attempts" | "connection:disconnecting" | "connection:newRTCSession" | "connection:unregistered" | "connection:registrationFailed" | "connection:newMessage" | "connection:sipEvent" | "connection:connect-started" | "connection:connect-succeeded" | "connection:connected-with-configuration" | "connection:connect-failed" | "connection:connect-parameters-resolve-success" | "connection:connect-parameters-resolve-failed" | "call:peerconnection" | "call:sending" | "call:progress" | "call:confirmed" | "call:newDTMF" | "call:newInfo" | "call:hold" | "call:unhold" | "call:muted" | "call:unmuted" | "call:reinvite" | "call:update" | "call:refer" | "call:replaces" | "call:sdp" | "call:icecandidate" | "call:getusermediafailed" | "call:peerconnection:createofferfailed" | "call:peerconnection:createanswerfailed" | "call:peerconnection:setlocaldescriptionfailed" | "call:peerconnection:setremotedescriptionfailed" | "call:presentation:start" | "call:presentation:started" | "call:presentation:end" | "call:presentation:ended" | "call:presentation:failed" | "call:peerconnection:confirmed" | "call:peerconnection:ontrack" | "call:ended:fromserver" | "call:call-status-changed" | "call:remote-streams-changed" | "api:channels:notify" | "api:participant:added-to-list-moderators" | "api:participant:removed-from-list-moderators" | "api:participant:move-request-to-stream" | "api:participant:move-request-to-participants" | "api:participant:move-request-to-spectators" | "api:participant:move-request-to-spectators-synthetic" | "api:participant:move-request-to-spectators-with-audio-id" | "api:participation:accepting-word-request" | "api:participation:cancelling-word-request" | "api:webcast:started" | "api:webcast:stopped" | "api:account:changed" | "api:account:deleted" | "api:conference:participant-token-issued" | "api:channels" | "api:enterRoom" | "api:shareState" | "api:main-cam-control" | "api:useLicense" | "api:admin-start-main-cam" | "api:admin-stop-main-cam" | "api:admin-start-mic" | "api:admin-stop-mic" | "api:admin-force-sync-media-state" | "api:availableSecondRemoteStream" | "api:notAvailableSecondRemoteStream" | "api:mustStopPresentation" | "api:newDTMF" | "incoming-call:incomingCall" | "incoming-call:declinedIncomingCall" | "incoming-call:terminatedIncomingCall" | "incoming-call:failedIncomingCall" | "presentation:presentation:start" | "presentation:presentation:started" | "presentation:presentation:end" | "presentation:presentation:ended" | "presentation:presentation:failed" | "stats:collected" | "video-balancer:balancing-scheduled" | "video-balancer:balancing-started" | "video-balancer:balancing-stopped" | "video-balancer:parameters-updated" | keyof TSipConnectorEventMap)[]>;
|
|
24
24
|
export {};
|
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-BTqBRDjY.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-C-73R76v.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-D4SHRHKj.js";
|
|
9
9
|
class T extends b {
|
|
10
10
|
headers;
|
|
11
11
|
constructor(e) {
|