sip-connector 6.24.3 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/{SipConnector-BfKQCTIn.js → SipConnector-B87yL77o.js} +299 -288
  2. package/dist/SipConnector-BSuVfStn.cjs +1 -0
  3. package/dist/SipConnector.d.ts +6 -4
  4. package/dist/__fixtures__/BaseSession.mock.d.ts +4 -4
  5. package/dist/__fixtures__/RTCPeerConnectionMock.d.ts +3 -2
  6. package/dist/__fixtures__/Registrator.mock.d.ts +2 -1
  7. package/dist/__fixtures__/Request.mock.d.ts +1 -0
  8. package/dist/__fixtures__/Session.mock.d.ts +3 -3
  9. package/dist/__fixtures__/UA.mock.d.ts +6 -7
  10. package/dist/__fixtures__/enterRoom.d.ts +5 -0
  11. package/dist/__fixtures__/index.d.ts +5 -4
  12. package/dist/__fixtures__/jssip.mock.d.ts +5 -4
  13. package/dist/__fixtures__/participantMoveRequests.d.ts +1 -0
  14. package/dist/constants.d.ts +2 -0
  15. package/dist/doMock.cjs +1 -1
  16. package/dist/doMock.d.ts +2 -1
  17. package/dist/doMock.js +2 -2
  18. package/dist/eventNames.d.ts +2 -2
  19. package/dist/headers.d.ts +3 -0
  20. package/dist/index.cjs +1 -1
  21. package/dist/index.d.ts +2 -1
  22. package/dist/index.js +156 -155
  23. package/dist/logger.d.ts +2 -1
  24. package/dist/tools/__fixtures__/call.d.ts +3 -3
  25. package/dist/tools/__fixtures__/connectToServer.d.ts +3 -2
  26. package/dist/tools/__fixtures__/hasValidUri.d.ts +2 -1
  27. package/dist/tools/__fixtures__/processRequest.d.ts +2 -1
  28. package/dist/tools/answerIncomingCall.d.ts +13 -12
  29. package/dist/tools/callToServer.d.ts +13 -12
  30. package/dist/tools/connectToServer.d.ts +3 -2
  31. package/dist/tools/disconnectFromServer.d.ts +2 -1
  32. package/dist/tools/error/getLinkError.d.ts +2 -1
  33. package/dist/tools/error/getTypeFromError.d.ts +2 -1
  34. package/dist/tools/error/getValuesFromError.d.ts +2 -1
  35. package/dist/tools/getExtraHeaders.d.ts +4 -4
  36. package/dist/tools/getUserAgent.d.ts +2 -2
  37. package/dist/tools/index.d.ts +1 -0
  38. package/dist/tools/resolveAskPermissionToEnableCam.d.ts +2 -1
  39. package/dist/tools/resolveGetRemoteStreams.d.ts +2 -1
  40. package/dist/tools/resolveOnMoveToSpectators.d.ts +4 -0
  41. package/dist/tools/resolveOnMustStopPresentation.d.ts +2 -1
  42. package/dist/tools/resolveOnUseLicense.d.ts +3 -2
  43. package/dist/tools/resolveSendMediaState.d.ts +2 -1
  44. package/dist/tools/resolveSendRefusalToTurnOnCam.d.ts +2 -1
  45. package/dist/tools/resolveSendRefusalToTurnOnMic.d.ts +2 -1
  46. package/dist/tools/resolveStartPresentation.d.ts +3 -2
  47. package/dist/tools/resolveStopShareSipConnector.d.ts +3 -2
  48. package/dist/tools/resolveUpdatePresentation.d.ts +3 -2
  49. package/dist/tools/sendDTMFAccumulated.d.ts +1 -1
  50. package/dist/tools/syncMediaState/index.d.ts +2 -1
  51. package/dist/tools/syncMediaState/resolveOnStartMainCam.d.ts +2 -1
  52. package/dist/tools/syncMediaState/resolveOnStartMic.d.ts +2 -1
  53. package/dist/tools/syncMediaState/resolveOnStopMainCam.d.ts +2 -1
  54. package/dist/tools/syncMediaState/resolveOnStopMic.d.ts +2 -1
  55. package/dist/types.d.ts +2 -1
  56. package/dist/utils.d.ts +2 -2
  57. package/dist/videoSendingBalancer/balance.d.ts +7 -6
  58. package/dist/videoSendingBalancer/index.d.ts +7 -6
  59. package/dist/videoSendingBalancer/processSender.d.ts +5 -4
  60. package/dist/videoSendingBalancer/scaleBitrate.d.ts +1 -1
  61. package/package.json +11 -11
  62. package/dist/SipConnector-BWd7Anni.cjs +0 -1
@@ -1,4 +1,5 @@
1
1
  import { URI } from '@krivega/jssip';
2
+
2
3
  export declare const LOCKED_SIP_WEB_SOCKET_SERVER_URL = "LOCKED_SIP_WEB_SOCKET_SERVER_URL";
3
4
  export declare const dataForConnectionWithAuthorization: {
4
5
  password: string;
@@ -103,7 +104,7 @@ export declare const uaConfigurationWithAuthorization: {
103
104
  display_name: string;
104
105
  register: boolean;
105
106
  session_timers: boolean;
106
- sockets: import("src/__fixtures__/WebSocketInterface.mock").default[];
107
+ sockets: import('../../__fixtures__/WebSocketInterface.mock').default[];
107
108
  user_agent: string;
108
109
  sdp_semantics: string;
109
110
  register_expires: number;
@@ -116,7 +117,7 @@ export declare const uaConfigurationWithAuthorizationPasswordChanged: {
116
117
  display_name: string;
117
118
  register: boolean;
118
119
  session_timers: boolean;
119
- sockets: import("src/__fixtures__/WebSocketInterface.mock").default[];
120
+ sockets: import('../../__fixtures__/WebSocketInterface.mock').default[];
120
121
  user_agent: string;
121
122
  sdp_semantics: string;
122
123
  register_expires: number;
@@ -1,3 +1,4 @@
1
- import type { URI } from '@krivega/jssip';
1
+ import { URI } from '@krivega/jssip';
2
+
2
3
  declare const hasValidUri: ({ scheme, user, host }: URI, url?: string) => boolean;
3
4
  export default hasValidUri;
@@ -1,4 +1,5 @@
1
- import type SipConnector from '../../SipConnector';
1
+ import { default as SipConnector } from '../../SipConnector';
2
+
2
3
  declare const resolveInitUaPromised: (sipConnector: SipConnector) => (state: {
3
4
  remoteAddress: string | undefined;
4
5
  sipServerUrl: string;
@@ -1,21 +1,22 @@
1
- import type SipConnector from '../SipConnector';
1
+ import { default as SipConnector } from '../SipConnector';
2
+
2
3
  type TDegradationPreference = 'balanced' | 'maintain-framerate' | 'maintain-resolution';
3
4
  declare const resolveAnswerIncomingCall: (sipConnector: SipConnector) => (parameters: {
4
5
  mediaStream: MediaStream;
5
6
  extraHeaders?: string[] | undefined;
6
- iceServers?: RTCIceServer[] | undefined;
7
- degradationPreference?: TDegradationPreference | undefined;
7
+ iceServers?: RTCIceServer[];
8
+ degradationPreference?: TDegradationPreference;
8
9
  setRemoteStreams: (streams: MediaStream[]) => void;
9
- onBeforeProgressCall?: ((conference?: string) => void) | undefined;
10
- onSuccessProgressCall?: ((parameters_: {
10
+ onBeforeProgressCall?: (conference?: string) => void;
11
+ onSuccessProgressCall?: (parameters_: {
11
12
  isPurgatory: boolean;
12
- }) => void) | undefined;
13
- onFailProgressCall?: (() => void) | undefined;
14
- onFinishProgressCall?: (() => void) | undefined;
15
- onEnterPurgatory?: (() => void) | undefined;
16
- onEnterConference?: ((parameters_: {
13
+ }) => void;
14
+ onFailProgressCall?: () => void;
15
+ onFinishProgressCall?: () => void;
16
+ onEnterPurgatory?: () => void;
17
+ onEnterConference?: (parameters_: {
17
18
  isSuccessProgressCall: boolean;
18
- }) => void) | undefined;
19
- onEndedCall?: (() => void) | undefined;
19
+ }) => void;
20
+ onEndedCall?: () => void;
20
21
  }) => Promise<RTCPeerConnection | void>;
21
22
  export default resolveAnswerIncomingCall;
@@ -1,22 +1,23 @@
1
- import type SipConnector from '../SipConnector';
1
+ import { default as SipConnector } from '../SipConnector';
2
+
2
3
  type TDegradationPreference = 'balanced' | 'maintain-framerate' | 'maintain-resolution';
3
4
  declare const resolveCallToServer: (sipConnector: SipConnector) => (parameters: {
4
5
  conference: string;
5
6
  mediaStream: MediaStream;
6
7
  extraHeaders?: string[] | undefined;
7
- iceServers?: RTCIceServer[] | undefined;
8
- degradationPreference?: TDegradationPreference | undefined;
8
+ iceServers?: RTCIceServer[];
9
+ degradationPreference?: TDegradationPreference;
9
10
  setRemoteStreams: (streams: MediaStream[]) => void;
10
- onBeforeProgressCall?: ((conference: string) => void) | undefined;
11
- onSuccessProgressCall?: ((parameters_: {
11
+ onBeforeProgressCall?: (conference: string) => void;
12
+ onSuccessProgressCall?: (parameters_: {
12
13
  isPurgatory: boolean;
13
- }) => void) | undefined;
14
- onEnterPurgatory?: (() => void) | undefined;
15
- onEnterConference?: ((parameters_: {
14
+ }) => void;
15
+ onEnterPurgatory?: () => void;
16
+ onEnterConference?: (parameters_: {
16
17
  isSuccessProgressCall: boolean;
17
- }) => void) | undefined;
18
- onFailProgressCall?: (() => void) | undefined;
19
- onFinishProgressCall?: (() => void) | undefined;
20
- onEndedCall?: (() => void) | undefined;
18
+ }) => void;
19
+ onFailProgressCall?: () => void;
20
+ onFinishProgressCall?: () => void;
21
+ onEndedCall?: () => void;
21
22
  }) => Promise<RTCPeerConnection>;
22
23
  export default resolveCallToServer;
@@ -1,5 +1,6 @@
1
- import type { UA } from '@krivega/jssip';
2
- import type SipConnector from '../SipConnector';
1
+ import { default as SipConnector } from '../SipConnector';
2
+ import { UA } from '@krivega/jssip';
3
+
3
4
  declare const resolveConnectToServer: (sipConnector: SipConnector) => (parameters: {
4
5
  userAgent: string;
5
6
  sipWebSocketServerURL: string;
@@ -1,4 +1,5 @@
1
- import type SipConnector from '../SipConnector';
1
+ import { default as SipConnector } from '../SipConnector';
2
+
2
3
  declare const resolveDisconnectFromServer: (sipConnector: SipConnector) => () => Promise<{
3
4
  isSuccessful: boolean;
4
5
  } | {
@@ -1,3 +1,4 @@
1
- import type { TCustomError } from '../../types';
1
+ import { TCustomError } from '../../types';
2
+
2
3
  declare const getLinkError: (error: TCustomError) => string | undefined;
3
4
  export default getLinkError;
@@ -1,4 +1,5 @@
1
- import type { TCustomError } from '../../types';
1
+ import { TCustomError } from '../../types';
2
+
2
3
  export declare enum EErrorTypes {
3
4
  CONNECT_SERVER_FAILED = "CONNECT_SERVER_FAILED",
4
5
  WRONG_USER_OR_PASSWORD = "WRONG_USER_OR_PASSWORD",
@@ -1,4 +1,5 @@
1
- import type { TCustomError } from '../../types';
1
+ import { TCustomError } from '../../types';
2
+
2
3
  export type TValues = {
3
4
  message?: string;
4
5
  link?: string;
@@ -1,9 +1,9 @@
1
1
  declare const getExtraHeaders: ({ sessionId, remoteAddress, isMutedAudio, isMutedVideo, isRegistered, isPresentationCall, }: {
2
- sessionId?: string | undefined;
3
- remoteAddress?: string | undefined;
4
- isRegistered?: boolean | undefined;
2
+ sessionId?: string;
3
+ remoteAddress?: string;
4
+ isRegistered?: boolean;
5
5
  isMutedAudio: boolean;
6
6
  isMutedVideo: boolean;
7
- isPresentationCall?: boolean | undefined;
7
+ isPresentationCall?: boolean;
8
8
  }) => string[];
9
9
  export default getExtraHeaders;
@@ -2,7 +2,7 @@ declare const getUserAgent: ({ isUnifiedSdpSemantic, appVersion, browserName, br
2
2
  isUnifiedSdpSemantic: boolean;
3
3
  appName: string;
4
4
  appVersion: number;
5
- browserName?: string | undefined;
6
- browserVersion?: string | undefined;
5
+ browserName?: string;
6
+ browserVersion?: string;
7
7
  }) => string;
8
8
  export default getUserAgent;
@@ -9,6 +9,7 @@ export { PURGATORY_CONFERENCE_NUMBER, default as hasPurgatory } from './hasPurga
9
9
  export { default as resolveAskPermissionToEnableCam } from './resolveAskPermissionToEnableCam';
10
10
  export { default as resolveGetRemoteStreams } from './resolveGetRemoteStreams';
11
11
  export { default as resolveOnMustStopPresentation } from './resolveOnMustStopPresentation';
12
+ export { default as resolveOnMoveToSpectators } from './resolveOnMoveToSpectators';
12
13
  export { default as resolveOnUseLicense } from './resolveOnUseLicense';
13
14
  export { default as resolveSendMediaState } from './resolveSendMediaState';
14
15
  export { default as resolveSendRefusalToTurnOnCam } from './resolveSendRefusalToTurnOnCam';
@@ -1,3 +1,4 @@
1
- import type SipConnector from '../SipConnector';
1
+ import { default as SipConnector } from '../SipConnector';
2
+
2
3
  declare const resolveAskPermissionToEnableCam: (sipConnector: SipConnector) => (() => Promise<void>);
3
4
  export default resolveAskPermissionToEnableCam;
@@ -1,3 +1,4 @@
1
- import type SipConnector from '../SipConnector';
1
+ import { default as SipConnector } from '../SipConnector';
2
+
2
3
  declare const resolveGetRemoteStreams: (sipConnector: SipConnector) => () => MediaStream[] | undefined;
3
4
  export default resolveGetRemoteStreams;
@@ -0,0 +1,4 @@
1
+ import { default as SipConnector } from '../SipConnector';
2
+
3
+ declare const resolveOnMoveToSpectators: (sipConnector: SipConnector) => (handler: () => void) => (() => void);
4
+ export default resolveOnMoveToSpectators;
@@ -1,3 +1,4 @@
1
- import type SipConnector from '../SipConnector';
1
+ import { default as SipConnector } from '../SipConnector';
2
+
2
3
  declare const resolveOnMustStopPresentation: (sipConnector: SipConnector) => (handler: () => void) => (() => void);
3
4
  export default resolveOnMustStopPresentation;
@@ -1,4 +1,5 @@
1
- import type SipConnector from '../SipConnector';
2
- import type { EUseLicense } from '../types';
1
+ import { EUseLicense } from '../types';
2
+ import { default as SipConnector } from '../SipConnector';
3
+
3
4
  declare const resolveOnUseLicense: (sipConnector: SipConnector) => (handler: (license: EUseLicense) => void) => (() => void);
4
5
  export default resolveOnUseLicense;
@@ -1,4 +1,5 @@
1
- import type SipConnector from '../SipConnector';
1
+ import { default as SipConnector } from '../SipConnector';
2
+
2
3
  declare const resolveSendMediaState: (sipConnector: SipConnector) => ({ isEnabledCam, isEnabledMic, }: {
3
4
  isEnabledCam: boolean;
4
5
  isEnabledMic: boolean;
@@ -1,3 +1,4 @@
1
- import type SipConnector from '../SipConnector';
1
+ import { default as SipConnector } from '../SipConnector';
2
+
2
3
  declare const resolveSendRefusalToTurnOnCam: (sipConnector: SipConnector) => () => Promise<void>;
3
4
  export default resolveSendRefusalToTurnOnCam;
@@ -1,3 +1,4 @@
1
- import type SipConnector from '../SipConnector';
1
+ import { default as SipConnector } from '../SipConnector';
2
+
2
3
  declare const resolveSendRefusalToTurnOnMic: (sipConnector: SipConnector) => () => Promise<void>;
3
4
  export default resolveSendRefusalToTurnOnMic;
@@ -1,6 +1,7 @@
1
- import type SipConnector from '../SipConnector';
1
+ import { default as SipConnector } from '../SipConnector';
2
+
2
3
  declare const resolveStartPresentation: ({ maxBitrate, sipConnector, }: {
3
- maxBitrate?: number | undefined;
4
+ maxBitrate?: number;
4
5
  sipConnector: SipConnector;
5
6
  }) => ({ mediaStream, isP2P, }: {
6
7
  mediaStream: MediaStream;
@@ -1,7 +1,8 @@
1
- import type SipConnector from '../SipConnector';
1
+ import { default as SipConnector } from '../SipConnector';
2
+
2
3
  declare const resolveStopShareSipConnector: ({ sipConnector }: {
3
4
  sipConnector: SipConnector;
4
5
  }) => ({ isP2P }?: {
5
- isP2P?: boolean | undefined;
6
+ isP2P?: boolean;
6
7
  }) => Promise<void | MediaStream>;
7
8
  export default resolveStopShareSipConnector;
@@ -1,6 +1,7 @@
1
- import type SipConnector from '../SipConnector';
1
+ import { default as SipConnector } from '../SipConnector';
2
+
2
3
  declare const resolveUpdatePresentation: ({ sipConnector, maxBitrate, }: {
3
- maxBitrate?: number | undefined;
4
+ maxBitrate?: number;
4
5
  sipConnector: SipConnector;
5
6
  }) => ({ mediaStream, isP2P, }: {
6
7
  mediaStream: MediaStream;
@@ -2,7 +2,7 @@ type TSendKey = (values: string) => Promise<void>;
2
2
  declare const sendDTMFAccumulated: ({ accumulatedKeys, sendKey, canRunTask, }: {
3
3
  accumulatedKeys: string;
4
4
  sendKey: TSendKey;
5
- canRunTask?: (() => boolean) | undefined;
5
+ canRunTask?: () => boolean;
6
6
  }) => Promise<{
7
7
  isSuccessful: boolean;
8
8
  }>;
@@ -1,4 +1,5 @@
1
- import type SipConnector from '../../SipConnector';
1
+ import { default as SipConnector } from '../../SipConnector';
2
+
2
3
  type THandlers = {
3
4
  onStartMainCamForced: () => void;
4
5
  onStartMainCamNotForced: () => void;
@@ -1,4 +1,5 @@
1
- import type SipConnector from '../../SipConnector';
1
+ import { default as SipConnector } from '../../SipConnector';
2
+
2
3
  declare const resolveOnStartMainCam: (sipConnector: SipConnector) => (handler: ({ isSyncForced }: {
3
4
  isSyncForced: boolean;
4
5
  }) => void) => (() => void);
@@ -1,4 +1,5 @@
1
- import type SipConnector from '../../SipConnector';
1
+ import { default as SipConnector } from '../../SipConnector';
2
+
2
3
  declare const resolveOnStartMic: (sipConnector: SipConnector) => (handler: ({ isSyncForced }: {
3
4
  isSyncForced: boolean;
4
5
  }) => void) => (() => void);
@@ -1,4 +1,5 @@
1
- import type SipConnector from '../../SipConnector';
1
+ import { default as SipConnector } from '../../SipConnector';
2
+
2
3
  declare const resolveOnStopMainCam: (sipConnector: SipConnector) => (handler: ({ isSyncForced }: {
3
4
  isSyncForced: boolean;
4
5
  }) => void) => (() => void);
@@ -1,4 +1,5 @@
1
- import type SipConnector from '../../SipConnector';
1
+ import { default as SipConnector } from '../../SipConnector';
2
+
2
3
  declare const resolveOnStopMic: (sipConnector: SipConnector) => (handler: ({ isSyncForced }: {
3
4
  isSyncForced: boolean;
4
5
  }) => void) => (() => void);
package/dist/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import type { UA, WebSocketInterface } from '@krivega/jssip';
1
+ import { UA, WebSocketInterface } from '@krivega/jssip';
2
+
2
3
  export declare enum EEventsMainCAM {
3
4
  PAUSE_MAIN_CAM = "PAUSEMAINCAM",
4
5
  RESUME_MAIN_CAM = "RESUMEMAINCAM",
package/dist/utils.d.ts CHANGED
@@ -2,7 +2,7 @@ export declare function resolveSipUrl(serverUrl: string): (string: string) => st
2
2
  export declare const parseDisplayName: (displayName: string) => string;
3
3
  export declare const generateUserId: () => number;
4
4
  export declare const prepareMediaStream: (mediaStream?: MediaStream, { videoMode, audioMode, }?: {
5
- videoMode?: "recvonly" | "sendonly" | "sendrecv" | undefined;
6
- audioMode?: "recvonly" | "sendonly" | "sendrecv" | undefined;
5
+ videoMode?: 'recvonly' | 'sendonly' | 'sendrecv';
6
+ audioMode?: 'recvonly' | 'sendonly' | 'sendrecv';
7
7
  }) => MediaStream | undefined;
8
8
  export declare const hasVideoTracks: (remoteTracks: MediaStreamTrack[]) => boolean;
@@ -1,10 +1,11 @@
1
- import type { EEventsMainCAM } from '../types';
2
- import type { TOnSetParameters, TResult } from './setEncodingsToSender';
1
+ import { TOnSetParameters, TResult } from './setEncodingsToSender';
2
+ import { EEventsMainCAM } from '../types';
3
+
3
4
  declare const balance: ({ mainCam, resolutionMainCam, connection, onSetParameters, ignoreForCodec, }: {
4
- mainCam?: EEventsMainCAM | undefined;
5
- resolutionMainCam?: string | undefined;
5
+ mainCam?: EEventsMainCAM;
6
+ resolutionMainCam?: string;
6
7
  connection: RTCPeerConnection;
7
- onSetParameters?: TOnSetParameters | undefined;
8
- ignoreForCodec?: string | undefined;
8
+ onSetParameters?: TOnSetParameters;
9
+ ignoreForCodec?: string;
9
10
  }) => Promise<TResult>;
10
11
  export default balance;
@@ -1,13 +1,14 @@
1
- import type SipConnector from '../SipConnector';
2
- import type { TOnSetParameters } from './setEncodingsToSender';
1
+ import { TOnSetParameters } from './setEncodingsToSender';
2
+ import { default as SipConnector } from '../SipConnector';
3
+
3
4
  declare const resolveVideoSendingBalancer: (sipConnector: SipConnector, { ignoreForCodec, onSetParameters, }?: {
4
- ignoreForCodec?: string | undefined;
5
- onSetParameters?: TOnSetParameters | undefined;
5
+ ignoreForCodec?: string;
6
+ onSetParameters?: TOnSetParameters;
6
7
  }) => {
7
8
  subscribe: () => void;
8
9
  unsubscribe: () => void;
9
- balanceByTrack: () => Promise<import("./setEncodingsToSender").TResult>;
10
+ balanceByTrack: () => Promise<import('./setEncodingsToSender').TResult>;
10
11
  resetMainCamControl(): void;
11
- reBalance(): Promise<import("./setEncodingsToSender").TResult>;
12
+ reBalance(): Promise<import('./setEncodingsToSender').TResult>;
12
13
  };
13
14
  export default resolveVideoSendingBalancer;
@@ -1,10 +1,11 @@
1
+ import { TOnSetParameters, TResult } from './setEncodingsToSender';
1
2
  import { EEventsMainCAM } from '../types';
2
- import type { TOnSetParameters, TResult } from './setEncodingsToSender';
3
+
3
4
  declare const processSender: ({ mainCam, resolutionMainCam, sender, track, codec, }: {
4
- mainCam?: EEventsMainCAM | undefined;
5
- resolutionMainCam?: string | undefined;
5
+ mainCam?: EEventsMainCAM;
6
+ resolutionMainCam?: string;
6
7
  sender: RTCRtpSender;
7
8
  track: MediaStreamTrack;
8
- codec?: string | undefined;
9
+ codec?: string;
9
10
  }, onSetParameters?: TOnSetParameters) => Promise<TResult>;
10
11
  export default processSender;
@@ -1,2 +1,2 @@
1
- declare const scaleMaxBitrateBySender: (senders: RTCRtpSender[], mediaStream: MediaStream, maxBitrate: number) => Promise<import("./setEncodingsToSender").TResult | undefined>;
1
+ declare const scaleMaxBitrateBySender: (senders: RTCRtpSender[], mediaStream: MediaStream, maxBitrate: number) => Promise<import('./setEncodingsToSender').TResult | undefined>;
2
2
  export default scaleMaxBitrateBySender;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sip-connector",
3
- "version": "6.24.3",
3
+ "version": "7.0.0",
4
4
  "description": "Module for connect to Vinteo server",
5
5
  "keywords": [
6
6
  "webrtc",
@@ -73,13 +73,13 @@
73
73
  },
74
74
  "devDependencies": {
75
75
  "@babel/preset-typescript": "^7.24.1",
76
- "@commitlint/cli": "^19.2.1",
77
- "@commitlint/config-conventional": "^19.1.0",
78
- "@nabla/vite-plugin-eslint": "^2.0.2",
76
+ "@commitlint/cli": "^19.2.2",
77
+ "@commitlint/config-conventional": "^19.2.2",
78
+ "@nabla/vite-plugin-eslint": "^2.0.4",
79
79
  "@types/debug": "^4.1.12",
80
80
  "@types/jest": "^29.5.12",
81
- "@typescript-eslint/eslint-plugin": "^7.3.1",
82
- "@typescript-eslint/parser": "^7.3.1",
81
+ "@typescript-eslint/eslint-plugin": "^7.7.0",
82
+ "@typescript-eslint/parser": "^7.7.0",
83
83
  "cross-env": "^7.0.3",
84
84
  "eslint": "^8.57.0",
85
85
  "eslint-config-airbnb-base": "^15.0.0",
@@ -88,9 +88,9 @@
88
88
  "eslint-import-resolver-typescript": "^3.6.1",
89
89
  "eslint-plugin-flowtype": "^8.0.3",
90
90
  "eslint-plugin-import": "^2.29.1",
91
- "eslint-plugin-jest": "^27.9.0",
91
+ "eslint-plugin-jest": "^28.2.0",
92
92
  "eslint-plugin-prettier": "^5.1.3",
93
- "eslint-plugin-unicorn": "^51.0.1",
93
+ "eslint-plugin-unicorn": "^52.0.0",
94
94
  "husky": "^9.0.11",
95
95
  "jest": "^29.7.0",
96
96
  "jest-environment-jsdom": "^29.7.0",
@@ -102,9 +102,9 @@
102
102
  "ts-jest": "^29.1.2",
103
103
  "ts-node": "^10.9.2",
104
104
  "tsc-files": "^1.1.4",
105
- "typescript": "^5.4.3",
106
- "vite": "^5.2.2",
107
- "vite-plugin-dts": "^3.7.3",
105
+ "typescript": "^5.4.5",
106
+ "vite": "^5.2.9",
107
+ "vite-plugin-dts": "^3.8.3",
108
108
  "vite-tsconfig-paths": "^4.3.2"
109
109
  },
110
110
  "peerDependencies": {
@@ -1 +0,0 @@
1
- "use strict";var It=Object.defineProperty;var mt=(r,e,t)=>e in r?It(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var i=(r,e,t)=>(mt(r,typeof e!="symbol"?e+"":e,t),t);const N=require("@krivega/cancelable-promise"),Pe=require("events-constructor"),B=require("debug"),ft="Connection Error",He="Request Timeout",Ot="SIP Failure Code",Dt="Internal Error",Mt="Busy",V="Rejected",Pt="Redirected",pt="Unavailable",qe="Not Found",vt="Address Incomplete",bt="Incompatible SDP",wt="Missing SDP",yt="Authentication Error",ke="Terminated",Ut="WebRTC Error",We="Canceled",Lt="No Answer",Ht="Expires",qt="No ACK",kt="Dialog Error",Wt="User Denied Media Access",Fe="Bad Media Description",Ft="RTP Timeout",Bt=Object.freeze(Object.defineProperty({__proto__:null,ADDRESS_INCOMPLETE:vt,AUTHENTICATION_ERROR:yt,BAD_MEDIA_DESCRIPTION:Fe,BUSY:Mt,BYE:ke,CANCELED:We,CONNECTION_ERROR:ft,DIALOG_ERROR:kt,EXPIRES:Ht,INCOMPATIBLE_SDP:bt,INTERNAL_ERROR:Dt,MISSING_SDP:wt,NOT_FOUND:qe,NO_ACK:qt,NO_ANSWER:Lt,REDIRECTED:Pt,REJECTED:V,REQUEST_TIMEOUT:He,RTP_TIMEOUT:Ft,SIP_FAILURE_CODE:Ot,UNAVAILABLE:pt,USER_DENIED_MEDIA_ACCESS:Wt,WEBRTC_ERROR:Ut},Symbol.toStringTag,{value:"Module"})),Y="incomingCall",x="declinedIncomingCall",$="failedIncomingCall",G="terminatedIncomingCall",q="connecting",m="connected",T="disconnected",P="newRTCSession",f="registered",X="unregistered",O="registrationFailed",Be="newMessage",J="sipEvent",z="availableSecondRemoteStream",Q="notAvailableSecondRemoteStream",K="mustStopPresentation",p="shareState",j="enterRoom",Z="useLicense",ee="peerconnection:confirmed",te="peerconnection:ontrack",v="channels",ne="channels:notify",se="ended:fromserver",ie="main-cam-control",re="admin-stop-main-cam",oe="admin-start-main-cam",ae="admin-stop-mic",ce="admin-start-mic",b="admin-force-sync-media-state",Ee="participant:added-to-list-moderators",_e="participant:removed-from-list-moderators",he="participant:move-request-to-stream",de="participation:accepting-word-request",le="participation:cancelling-word-request",ue="webcast:started",Te="webcast:stopped",Se="account:changed",Ne="account:deleted",ge="conference:participant-token-issued",D="ended",Ve="sending",Ye="reinvite",xe="replaces",$e="refer",Ge="progress",Xe="accepted",w="confirmed",y="peerconnection",C="failed",Je="muted",ze="unmuted",Ce="newDTMF",Ae="newInfo",Qe="hold",Ke="unhold",je="update",Ze="sdp",et="icecandidate",tt="getusermediafailed",nt="peerconnection:createofferfailed",st="peerconnection:createanswerfailed",it="peerconnection:setlocaldescriptionfailed",rt="peerconnection:setremotedescriptionfailed",ot="presentation:start",at="presentation:started",ct="presentation:end",Re="presentation:ended",U="presentation:failed",Vt=Object.freeze(Object.defineProperty({__proto__:null,ACCEPTED:Xe,ACCOUNT_CHANGED:Se,ACCOUNT_DELETED:Ne,ADMIN_FORCE_SYNC_MEDIA_STATE:b,ADMIN_START_MAIN_CAM:oe,ADMIN_START_MIC:ce,ADMIN_STOP_MAIN_CAM:re,ADMIN_STOP_MIC:ae,AVAILABLE_SECOND_REMOTE_STREAM_EVENT:z,CHANNELS:v,CHANNELS_NOTIFY:ne,CONFERENCE_PARTICIPANT_TOKEN_ISSUED:ge,CONFIRMED:w,CONNECTED:m,CONNECTING:q,DECLINED_INCOMING_CALL:x,DISCONNECTED:T,ENDED:D,ENDED_FROM_SERVER:se,ENTER_ROOM:j,FAILED:C,FAILED_INCOMING_CALL:$,GET_USER_MEDIA_FAILED:tt,HOLD:Qe,ICE_CANDIDATE:et,INCOMING_CALL:Y,MAIN_CAM_CONTROL:ie,MUST_STOP_PRESENTATION_EVENT:K,MUTED:Je,NEW_DTMF:Ce,NEW_INFO:Ae,NEW_MESSAGE:Be,NEW_RTC_SESSION:P,NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT:Q,PARTICIPANT_ADDED_TO_LIST_MODERATORS:Ee,PARTICIPANT_MOVE_REQUEST_TO_STREAM:he,PARTICIPANT_REMOVED_FROM_LIST_MODERATORS:_e,PARTICIPATION_ACCEPTING_WORD_REQUEST:de,PARTICIPATION_CANCELLING_WORD_REQUEST:le,PEER_CONNECTION:y,PEER_CONNECTION_CONFIRMED:ee,PEER_CONNECTION_CREATE_ANSWER_FAILED:st,PEER_CONNECTION_CREATE_OFFER_FAILED:nt,PEER_CONNECTION_ONTRACK:te,PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED:it,PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED:rt,PRESENTATION_END:ct,PRESENTATION_ENDED:Re,PRESENTATION_FAILED:U,PRESENTATION_START:ot,PRESENTATION_STARTED:at,PROGRESS:Ge,REFER:$e,REGISTERED:f,REGISTRATION_FAILED:O,REINVITE:Ye,REPLACES:xe,SDP:Ze,SENDING:Ve,SHARE_STATE:p,SIP_EVENT:J,TERMINATED_INCOMING_CALL:G,UNHOLD:Ke,UNMUTED:ze,UNREGISTERED:X,UPDATE:je,USE_LICENSE:Z,WEBCAST_STARTED:ue,WEBCAST_STOPPED:Te},Symbol.toStringTag,{value:"Module"})),Et=[Y,x,G,$,de,le,he,ne,ge,Se,Ne,ue,Te,Ee,_e],Ie=[q,m,T,P,f,X,O,Be,J],_t=[z,Q,K,p,j,Z,ee,te,v,se,ie,oe,re,ae,ce,b],me=[D,q,Ve,Ye,xe,$e,Ge,Xe,w,y,C,Je,ze,Ce,Ae,Qe,Ke,je,Ze,et,tt,nt,st,it,rt,ot,at,ct,Re,U],fe=[...Ie,...Et],Oe=[...me,..._t],Yt=Object.freeze(Object.defineProperty({__proto__:null,SESSION_EVENT_NAMES:Oe,SESSION_JSSIP_EVENT_NAMES:me,SESSION_SYNTHETICS_EVENT_NAMES:_t,UA_EVENT_NAMES:fe,UA_JSSIP_EVENT_NAMES:Ie,UA_SYNTHETICS_EVENT_NAMES:Et},Symbol.toStringTag,{value:"Module"})),xt=r=>{const e=[];return r&&e.push(`X-Vinteo-Remote: ${r}`),e},$t="content-type",Gt="x-webrtc-enter-room",M="application/vinteo.webrtc.sharedesktop",Xt="application/vinteo.webrtc.roomname",Jt="application/vinteo.webrtc.channels",zt="application/vinteo.webrtc.mediastate",Qt="application/vinteo.webrtc.refusal",pe="application/vinteo.webrtc.maincam",Kt="application/vinteo.webrtc.mic",jt="application/vinteo.webrtc.uselic",Zt="X-WEBRTC-USE-LICENSE",ve="X-WEBRTC-INPUT-CHANNELS",be="X-WEBRTC-OUTPUT-CHANNELS",en="X-WEBRTC-MAINCAM",tn="X-WEBRTC-MIC",we="X-WEBRTC-SYNC",nn="X-WEBRTC-MAINCAM-RESOLUTION",sn="X-WEBRTC-MEDIA-STATE",rn="X-Vinteo-Media-Type",on="X-Vinteo-MainCam-State",an="X-Vinteo-Mic-State",cn="application/vinteo.webrtc.notify",En="X-VINTEO-NOTIFY",R="x-webrtc-share-state",_n=`${R}: LETMESTARTPRESENTATION`,hn=`${R}: STOPPRESENTATION`,ht="YOUCANRECEIVECONTENT",dt="CONTENTEND",lt="YOUMUSTSTOPSENDCONTENT",dn=`${R}: ${lt}`,ln=`${R}: ${ht}`,un=`${R}: ${dt}`,Tn="X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE",Sn=`${Tn}: LETMESTARTMAINCAM`,De="sip-connector",W=B(De),Nn=()=>{B.enable(De)},gn=()=>{B.enable(`-${De}`)};var A=(r=>(r.PAUSE_MAIN_CAM="PAUSEMAINCAM",r.RESUME_MAIN_CAM="RESUMEMAINCAM",r.MAX_MAIN_CAM_RESOLUTION="MAXMAINCAMRESOLUTION",r.ADMIN_STOP_MAIN_CAM="ADMINSTOPMAINCAM",r.ADMIN_START_MAIN_CAM="ADMINSTARTMAINCAM",r))(A||{}),L=(r=>(r.ADMIN_STOP_MIC="ADMINSTOPMIC",r.ADMIN_START_MIC="ADMINSTARTMIC",r))(L||{}),H=(r=>(r.ADMIN_SYNC_FORCED="1",r.ADMIN_SYNC_NOT_FORCED="0",r))(H||{}),ut=(r=>(r.AUDIO="AUDIO",r.VIDEO="VIDEO",r.AUDIOPLUSPRESENTATION="AUDIOPLUSPRESENTATION",r))(ut||{});function ye(r){return e=>`sip:${e}@${r}`}const Cn=(r,e)=>()=>Math.floor(Math.random()*(e-r))+r,Ue=r=>r.trim().replaceAll(" ","_"),An=Cn(1e5,99999999),k=(r,{videoMode:e,audioMode:t}={})=>{if(!r||e==="recvonly"&&t==="recvonly")return;const n=t==="recvonly"?[]:r.getAudioTracks(),s=e==="recvonly"?[]:r.getVideoTracks(),o=[...n,...s],a=new MediaStream(o);return a.getTracks=()=>[...a.getAudioTracks(),...a.getVideoTracks()],a},Rn=r=>r.some(t=>{const{kind:n}=t;return n==="video"}),In="Error decline with 603",mn=r=>r.message===In,fn=(r,e)=>r.find(t=>t.track&&e.getTracks().includes(t.track)),Tt=1,St=r=>(e,t)=>t!==void 0&&e!==t||t===void 0&&e!==r,On=St(Tt),Dn=(r,e)=>{const t=r===void 0?void 0:Math.max(r,Tt);if(t!==void 0&&On(t,e))return t},Mn=St(),Pn=(r,e)=>{if(Mn(r,e))return r},Nt=async(r,e,t)=>{const n=r.getParameters();(n.encodings===void 0||n.encodings.length===0)&&(n.encodings=[{}]);const[s]=n.encodings,o=s.scaleResolutionDownBy,a=Dn(e.scaleResolutionDownBy,o);let c=!1;a!==void 0&&(n.encodings[0].scaleResolutionDownBy=a,c=!0);const E=s.maxBitrate,_=Pn(e.maxBitrate,E);return _!==void 0&&(n.encodings[0].maxBitrate=_,c=!0),c?(t&&t(n),r.setParameters(n).then(()=>({parameters:n,isChanged:c}))):{parameters:n,isChanged:c}},pn=async(r,e,t)=>{const n=fn(r,e);if(n)return Nt(n,{maxBitrate:t})},vn=486,bn=487,F="local",Le="remote",wn=(r=new Error)=>{const{originator:e,cause:t}=r;return N.isCanceledError(r)?!0:typeof t=="string"?t===He||t===V||e===F&&(t===We||t===ke):!1},g="SipConnector",yn="channels",Un="WebcastStarted",Ln="WebcastStopped",Hn="accountChanged",qn="accountDeleted",kn="addedToListModerators",Wn="removedFromListModerators",Fn="ParticipationRequestAccepted",Bn="ParticipationRequestRejected",Vn="ParticipantMovedToWebcast",Yn="ConferenceParticipantTokenIssued";class xn{constructor({JsSIP:e}){i(this,"_isRegisterConfig",!1);i(this,"_connectionConfiguration",{});i(this,"_remoteStreams",{});i(this,"JsSIP");i(this,"_sessionEvents");i(this,"_uaEvents");i(this,"_cancelableConnect");i(this,"_cancelableInitUa");i(this,"_cancelableDisconnect");i(this,"_cancelableSet");i(this,"_cancelableCall");i(this,"_cancelableAnswer");i(this,"_cancelableSendDTMF");i(this,"getSipServerUrl",e=>e);i(this,"promisePendingStartPresentation");i(this,"promisePendingStopPresentation");i(this,"ua");i(this,"session");i(this,"incomingSession");i(this,"_streamPresentationCurrent");i(this,"socket");i(this,"connect",async e=>(this._cancelRequests(),this._cancelableConnect.request(e)));i(this,"initUa",async e=>this._cancelableInitUa.request(e));i(this,"set",async e=>this._cancelableSet.request(e));i(this,"call",async e=>this._cancelableCall.request(e));i(this,"disconnect",async()=>(this._cancelRequests(),this._disconnectWithoutCancelRequests()));i(this,"answerToIncomingCall",async e=>this._cancelableAnswer.request(e));i(this,"sendDTMF",async e=>this._cancelableSendDTMF.request(e));i(this,"hangUp",async()=>(this._cancelRequests(),this._hangUpWithoutCancelRequests()));i(this,"tryRegister",async()=>{if(!this.isRegisterConfig)throw new Error("Config is not registered");this._uaEvents.trigger(q,void 0);try{await this.unregister()}catch(e){W("tryRegister",e)}return this.register()});i(this,"declineToIncomingCall",async({statusCode:e=bn}={})=>new Promise((t,n)=>{if(!this.isAvailableIncomingCall){n(new Error("no incomingSession"));return}const s=this.incomingSession,o=this.remoteCallerData;this._cancelableCall.cancelRequest(),this._cancelableAnswer.cancelRequest(),this.removeIncomingSession(),this._uaEvents.trigger(x,o),t(s.terminate({status_code:e}))}));i(this,"busyIncomingCall",async()=>this.declineToIncomingCall({statusCode:vn}));i(this,"removeIncomingSession",()=>{delete this.incomingSession});i(this,"handleNewRTCSession",({originator:e,session:t})=>{if(e===Le){this.incomingSession=t;const n=this.remoteCallerData;t.on(C,s=>{this.removeIncomingSession(),s.originator===F?this._uaEvents.trigger(G,n):this._uaEvents.trigger($,n)}),this._uaEvents.trigger(Y,n)}});i(this,"_connect",async e=>this.initUa(e).then(async()=>this._start()));i(this,"_initUa",async({user:e,password:t,sipServerUrl:n,sipWebSocketServerURL:s,remoteAddress:o,sdpSemantics:a,sessionTimers:c,registerExpires:E,connectionRecoveryMinInterval:_,connectionRecoveryMaxInterval:h,userAgent:u,displayName:d="",register:l=!1,extraHeaders:S=[]})=>{if(!n)throw new Error("sipServerUrl is required");if(!s)throw new Error("sipWebSocketServerURL is required");if(l&&!e)throw new Error("user is required for authorized connection");if(l&&!t)throw new Error("password is required for authorized connection");this._connectionConfiguration={sipServerUrl:n,displayName:d,register:l,user:e,password:t},this.getSipServerUrl=ye(n),this.socket=new this.JsSIP.WebSocketInterface(s),this.ua&&await this._disconnectWithoutCancelRequests(),this._isRegisterConfig=!!l;const{socket:I}=this;this.ua=this._createUa({user:e,password:t,socket:I,displayName:d,register:l,sdpSemantics:a,sessionTimers:c,registerExpires:E,connectionRecoveryMinInterval:_,connectionRecoveryMaxInterval:h,userAgent:u,getSipServerUrl:this.getSipServerUrl}),this._uaEvents.eachTriggers((Ct,At)=>{const Me=Ie.find(Rt=>Rt===At);Me&&this.ua&&this.ua.on(Me,Ct)});const gt=[...xt(o),...S];return this.ua.registrator().setExtraHeaders(gt),this.ua});i(this,"_createUa",({user:e,password:t,socket:n,displayName:s,getSipServerUrl:o,register:a=!1,sdpSemantics:c="plan-b",sessionTimers:E=!1,registerExpires:_=60*5,connectionRecoveryMinInterval:h=2,connectionRecoveryMaxInterval:u=6,userAgent:d})=>{if(a&&!t)throw new Error("password is required for authorized connection");const l=a&&e?e.trim():`${An()}`,S=o(l),I={password:t,register:a,uri:S,display_name:Ue(s),user_agent:d,sdp_semantics:c,sockets:[n],session_timers:E,register_expires:_,connection_recovery_min_interval:h,connection_recovery_max_interval:u};return new this.JsSIP.UA(I)});i(this,"_start",async()=>new Promise((e,t)=>{const{ua:n}=this;if(!n){t(new Error("this.ua is not initialized"));return}const s=()=>{c(),e(n)},o=E=>{c(),t(E)},a=()=>{this.isRegisterConfig?(this.on(f,s),this.on(O,o)):this.on(m,s),this.on(T,o)},c=()=>{this.off(f,s),this.off(O,o),this.off(m,s),this.off(T,o)};a(),this.on(P,this.handleNewRTCSession),n.start()}));i(this,"_set",async({displayName:e,password:t})=>new Promise((n,s)=>{const{ua:o}=this;if(!o){s(new Error("this.ua is not initialized"));return}let a=!1,c=!1;e!==void 0&&e!==this._connectionConfiguration.displayName&&(a=o.set("display_name",Ue(e)),this._connectionConfiguration.displayName=e),t!==void 0&&t!==this._connectionConfiguration.password&&(c=o.set("password",t),this._connectionConfiguration.password=t);const E=a||c;c&&this.isRegisterConfig?this.register().then(()=>{n(E)}).catch(_=>{s(_)}):E?n(E):s(new Error("nothing changed"))}));i(this,"_disconnectWithoutCancelRequests",async()=>this._cancelableDisconnect.request());i(this,"_disconnect",async()=>{this.off(P,this.handleNewRTCSession);const e=new Promise(t=>{this.once(T,()=>{delete this.ua,t()})});return this.ua?(await this._hangUpWithoutCancelRequests(),this.ua?this.ua.stop():this._uaEvents.trigger(T,void 0)):this._uaEvents.trigger(T,void 0),e});i(this,"_call",async({number:e,mediaStream:t,extraHeaders:n=[],ontrack:s,iceServers:o,videoMode:a,audioMode:c,degradationPreference:E,offerToReceiveAudio:_=!0,offerToReceiveVideo:h=!0})=>new Promise((u,d)=>{const{ua:l}=this;if(!l){d(new Error("this.ua is not initialized"));return}this._connectionConfiguration.number=e,this._connectionConfiguration.answer=!1,this._handleCall({ontrack:s}).then(u).catch(S=>{d(S)}),this.session=l.call(this.getSipServerUrl(e),{extraHeaders:n,mediaStream:k(t,{videoMode:a,audioMode:c}),eventHandlers:this._sessionEvents.triggers,videoMode:a,audioMode:c,degradationPreference:E,pcConfig:{iceServers:o},rtcOfferConstraints:{offerToReceiveAudio:_,offerToReceiveVideo:h}})}));i(this,"_answer",async({mediaStream:e,ontrack:t,extraHeaders:n=[],iceServers:s,videoMode:o,audioMode:a,degradationPreference:c})=>new Promise((E,_)=>{if(!this.isAvailableIncomingCall){_(new Error("no incomingSession"));return}this.session=this.incomingSession,this.removeIncomingSession();const{session:h}=this;if(!h){_(new Error("No session established"));return}this._sessionEvents.eachTriggers((d,l)=>{const S=me.find(I=>I===l);S&&h.on(S,d)}),this._connectionConfiguration.answer=!0,this._connectionConfiguration.number=h.remote_identity.uri.user,this._handleCall({ontrack:t}).then(E).catch(d=>{_(d)});const u=k(e,{videoMode:o,audioMode:a});h.answer({extraHeaders:n,videoMode:o,audioMode:a,degradationPreference:c,mediaStream:u,pcConfig:{iceServers:s}})}));i(this,"_handleCall",async({ontrack:e})=>new Promise((t,n)=>{const s=()=>{this.onSession(y,h),this.onSession(w,u)},o=()=>{this.offSession(y,h),this.offSession(w,u)},a=()=>{this.onSession(C,E),this.onSession(D,E)},c=()=>{this.offSession(C,E),this.offSession(D,E)},E=d=>{o(),c(),n(d)};let _;const h=({peerconnection:d})=>{_=d,_.ontrack=l=>{this._sessionEvents.trigger(te,_),e&&e(l)}},u=()=>{_&&this._sessionEvents.trigger(ee,_),o(),c(),t(_)};s(),a()}));i(this,"_restoreSession",()=>{this._resetPresentation(),delete this._connectionConfiguration.number,delete this.session,this._remoteStreams={}});i(this,"_sendDTMF",async e=>new Promise((t,n)=>{const{session:s}=this;if(!s){n(new Error("No session established"));return}this.onceSession(Ce,({originator:o})=>{o===F&&t()}),s.sendDTMF(e,{duration:120,interToneGap:600})}));i(this,"_hangUpWithoutCancelRequests",async()=>{if(this.ua&&this.session){const{session:e}=this;this._streamPresentationCurrent&&await this.stopPresentation(),this._restoreSession(),e.isEnded()||e.terminate()}});i(this,"_handleShareState",e=>{switch(e){case ht:{this._sessionEvents.trigger(z,void 0);break}case dt:{this._sessionEvents.trigger(Q,void 0);break}case lt:{this._sessionEvents.trigger(K,void 0);break}}});i(this,"_maybeTriggerChannels",e=>{const t=e.getHeader(ve),n=e.getHeader(be);if(t&&n){const s={inputChannels:t,outputChannels:n};this._sessionEvents.trigger(v,s)}});i(this,"_handleNotify",e=>{switch(e.cmd){case yn:{const t=e;this._triggerChannelsNotify(t);break}case Un:{const t=e;this._triggerWebcastStartedNotify(t);break}case Ln:{const t=e;this._triggerWebcastStoppedNotify(t);break}case kn:{const t=e;this._triggerAddedToListModeratorsNotify(t);break}case Wn:{const t=e;this._triggerRemovedFromListModeratorsNotify(t);break}case Fn:{const t=e;this._triggerParticipationAcceptingWordRequest(t);break}case Bn:{const t=e;this._triggerParticipationCancellingWordRequest(t);break}case Vn:{const t=e;this._triggerParticipantMoveRequestToStream(t);break}case Hn:{this._triggerAccountChangedNotify();break}case qn:{this._triggerAccountDeletedNotify();break}case Yn:{const t=e;this._triggerConferenceParticipantTokenIssued(t);break}default:W("unknown cmd",e.cmd)}});i(this,"_triggerRemovedFromListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(_e,t)});i(this,"_triggerAddedToListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(Ee,t)});i(this,"_triggerWebcastStartedNotify",({body:{conference:e,type:t}})=>{const n={conference:e,type:t};this._uaEvents.trigger(ue,n)});i(this,"_triggerWebcastStoppedNotify",({body:{conference:e,type:t}})=>{const n={conference:e,type:t};this._uaEvents.trigger(Te,n)});i(this,"_triggerAccountChangedNotify",()=>{this._uaEvents.trigger(Se,void 0)});i(this,"_triggerAccountDeletedNotify",()=>{this._uaEvents.trigger(Ne,void 0)});i(this,"_triggerConferenceParticipantTokenIssued",({body:{conference:e,participant:t,jwt:n}})=>{const s={conference:e,participant:t,jwt:n};this._uaEvents.trigger(ge,s)});i(this,"_triggerChannelsNotify",e=>{const t=e.input,n=e.output,s={inputChannels:t,outputChannels:n};this._uaEvents.trigger(ne,s)});i(this,"_triggerParticipationAcceptingWordRequest",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(de,t)});i(this,"_triggerParticipationCancellingWordRequest",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(le,t)});i(this,"_triggerParticipantMoveRequestToStream",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(he,t)});i(this,"_triggerEnterRoom",e=>{const t=e.getHeader(Gt);this._sessionEvents.trigger(j,t)});i(this,"_triggerShareState",e=>{const t=e.getHeader(R);this._sessionEvents.trigger(p,t)});i(this,"_triggerMainCamControl",e=>{const t=e.getHeader(en),n=e.getHeader(we),s=n===H.ADMIN_SYNC_FORCED;if(t===A.ADMIN_START_MAIN_CAM)this._sessionEvents.trigger(oe,{isSyncForced:s});else if(t===A.ADMIN_STOP_MAIN_CAM)this._sessionEvents.trigger(re,{isSyncForced:s});else if((t===A.RESUME_MAIN_CAM||t===A.PAUSE_MAIN_CAM)&&n)this._sessionEvents.trigger(b,{isSyncForced:s});else{const o=e.getHeader(nn);this._sessionEvents.trigger(ie,{mainCam:t,resolutionMainCam:o})}});i(this,"_triggerMicControl",e=>{const t=e.getHeader(tn),s=e.getHeader(we)===H.ADMIN_SYNC_FORCED;t===L.ADMIN_START_MIC?this._sessionEvents.trigger(ce,{isSyncForced:s}):t===L.ADMIN_STOP_MIC&&this._sessionEvents.trigger(ae,{isSyncForced:s})});i(this,"_triggerUseLicense",e=>{const t=e.getHeader(Zt);this._sessionEvents.trigger(Z,t)});i(this,"_handleNewInfo",e=>{const{originator:t}=e;if(t!=="remote")return;const{request:n}=e,s=n.getHeader($t);if(s)switch(s){case Xt:{this._triggerEnterRoom(n),this._maybeTriggerChannels(n);break}case cn:{this._maybeHandleNotify(n);break}case M:{this._triggerShareState(n);break}case pe:{this._triggerMainCamControl(n);break}case Kt:{this._triggerMicControl(n);break}case jt:{this._triggerUseLicense(n);break}}});i(this,"_handleSipEvent",({request:e})=>{this._maybeHandleNotify(e)});i(this,"_maybeHandleNotify",e=>{const t=e.getHeader(En);if(t){const n=JSON.parse(t);this._handleNotify(n)}});i(this,"_handleEnded",e=>{const{originator:t}=e;t===Le&&this._sessionEvents.trigger(se,e),this._restoreSession()});this.JsSIP=e,this._sessionEvents=new Pe(Oe),this._uaEvents=new Pe(fe),this._cancelableConnect=new N.CancelableRequest(this._connect,{moduleName:g,afterCancelRequest:()=>{this._cancelableInitUa.cancelRequest(),this._cancelableDisconnect.cancelRequest()}}),this._cancelableInitUa=new N.CancelableRequest(this._initUa,{moduleName:g}),this._cancelableDisconnect=new N.CancelableRequest(this._disconnect,{moduleName:g}),this._cancelableSet=new N.CancelableRequest(this._set,{moduleName:g}),this._cancelableCall=new N.CancelableRequest(this._call,{moduleName:g}),this._cancelableAnswer=new N.CancelableRequest(this._answer,{moduleName:g}),this._cancelableSendDTMF=new N.CancelableRequest(this._sendDTMF,{moduleName:g}),this.onSession(p,this._handleShareState),this.onSession(Ae,this._handleNewInfo),this.on(J,this._handleSipEvent),this.onSession(C,this._handleEnded),this.onSession(D,this._handleEnded)}async register(){return new Promise((e,t)=>{this.isRegisterConfig&&this.ua?(this.ua.on(f,e),this.ua.on(O,t),this.ua.register()):t(new Error("Config is not registered"))})}async unregister(){return new Promise((e,t)=>{this.isRegistered&&this.ua?(this.ua.on(X,e),this.ua.unregister()):t(new Error("ua is not registered"))})}async sendOptions(e,t,n){if(!this.ua)throw new Error("is not connected");return new Promise((s,o)=>{try{this.ua.sendOptions(e,t,{extraHeaders:n,eventHandlers:{succeeded:()=>{s()},failed:o}})}catch(a){o(a)}})}async ping(e,t){var s;if(!((s=this.ua)!=null&&s.configuration.uri))throw new Error("is not connected");const n=this.ua.configuration.uri;return this.sendOptions(n,e,t)}async checkTelephony({userAgent:e,displayName:t,sipServerUrl:n,sipWebSocketServerURL:s,sdpSemantics:o}){return new Promise((a,c)=>{const E=ye(n),_=new this.JsSIP.WebSocketInterface(s),h=this._createUa({socket:_,displayName:t,sdpSemantics:o,userAgent:e,getSipServerUrl:E}),u=()=>{const l=new Error("Telephony is not available");c(l)};h.once(T,u);const d=()=>{h.removeAllListeners(),h.once(T,a),h.stop()};h.once(m,d),h.start()})}async replaceMediaStream(e,t){if(!this.session)throw new Error("No session established");return this.session.replaceMediaStream(e,t)}async askPermissionToEnableCam(e={}){if(!this.session)throw new Error("No session established");const t=[Sn];return this.session.sendInfo(pe,void 0,{noTerminateWhenError:!0,...e,extraHeaders:t}).catch(n=>{if(mn(n))throw n})}get isPendingPresentation(){return!!this.promisePendingStartPresentation||!!this.promisePendingStopPresentation}async _sendPresentation(e,t,{maxBitrate:n,degradationPreference:s,isNeedReinvite:o=!0,isP2P:a=!1}){const c=k(t);this._streamPresentationCurrent=c;const E=a?[ln]:[_n],_=e.sendInfo(M,void 0,{extraHeaders:E}).then(async()=>e.startPresentation(c,o,s)).then(async()=>{const{connection:h}=this;if(!h||n===void 0)return;const u=h.getSenders();await pn(u,t,n)}).then(()=>t).catch(h=>{throw this._sessionEvents.trigger(U,h),h});return this.promisePendingStartPresentation=_,_.finally(()=>{this.promisePendingStartPresentation=void 0})}async startPresentation(e,{isNeedReinvite:t=!0,isP2P:n=!1,maxBitrate:s,degradationPreference:o}={}){const a=this.establishedSession;if(!a)throw new Error("No session established");if(this._streamPresentationCurrent)throw new Error("Presentation is already started");return n&&await this.sendMustStopPresentation(a),this._sendPresentation(a,e,{isNeedReinvite:t,isP2P:n,maxBitrate:s,degradationPreference:o})}async sendMustStopPresentation(e){await e.sendInfo(M,void 0,{extraHeaders:[dn]})}async stopPresentation({isP2P:e=!1}={}){const t=this._streamPresentationCurrent;let n=this.promisePendingStartPresentation??Promise.resolve();const s=e?[un]:[hn],o=this.establishedSession;return o&&t&&(n=n.then(async()=>o.sendInfo(M,void 0,{extraHeaders:s})).then(async()=>o.stopPresentation(t)).catch(a=>{throw this._sessionEvents.trigger(U,a),a})),!o&&t&&this._sessionEvents.trigger(Re,t),this.promisePendingStopPresentation=n,n.finally(()=>{this._resetPresentation()})}async updatePresentation(e,{isP2P:t=!1,maxBitrate:n,degradationPreference:s}={}){const o=this.establishedSession;if(!o)throw new Error("No session established");if(!this._streamPresentationCurrent)throw new Error("Presentation has not started yet");return this.promisePendingStartPresentation&&await this.promisePendingStartPresentation,this._sendPresentation(o,e,{isP2P:t,maxBitrate:n,degradationPreference:s,isNeedReinvite:!1})}_resetPresentation(){delete this._streamPresentationCurrent,this.promisePendingStartPresentation=void 0,this.promisePendingStopPresentation=void 0}on(e,t){return this._uaEvents.on(e,t)}once(e,t){return this._uaEvents.once(e,t)}onceRace(e,t){return this._uaEvents.onceRace(e,t)}async wait(e){return this._uaEvents.wait(e)}off(e,t){this._uaEvents.off(e,t)}onSession(e,t){return this._sessionEvents.on(e,t)}onceSession(e,t){return this._sessionEvents.once(e,t)}onceRaceSession(e,t){return this._sessionEvents.onceRace(e,t)}async waitSession(e){return this._sessionEvents.wait(e)}offSession(e,t){this._sessionEvents.off(e,t)}isConfigured(){return!!this.ua}getConnectionConfiguration(){return{...this._connectionConfiguration}}getRemoteStreams(){if(!this.connection)return;const t=this.connection.getReceivers().map(({track:n})=>n);return Rn(t)?this._generateStreams(t):this._generateAudioStreams(t)}get connection(){var t;return(t=this.session)==null?void 0:t.connection}get remoteCallerData(){var e,t,n,s,o,a;return{displayName:(t=(e=this.incomingSession)==null?void 0:e.remote_identity)==null?void 0:t.display_name,host:(s=(n=this.incomingSession)==null?void 0:n.remote_identity)==null?void 0:s.uri.host,incomingNumber:(a=(o=this.incomingSession)==null?void 0:o.remote_identity)==null?void 0:a.uri.user,session:this.incomingSession}}get requested(){return this._cancelableConnect.requested||this._cancelableInitUa.requested||this._cancelableCall.requested||this._cancelableAnswer.requested}get establishedSession(){return this.session&&this.session.isEstablished()?this.session:void 0}get isRegistered(){return!!this.ua&&this.ua.isRegistered()}get isRegisterConfig(){return!!this.ua&&this._isRegisterConfig}get isCallActive(){return!!(this.ua&&this.session)}get isAvailableIncomingCall(){return!!this.incomingSession}_generateStream(e,t){const{id:n}=e,s=this._remoteStreams[n]||new MediaStream;return t&&s.addTrack(t),s.addTrack(e),this._remoteStreams[n]=s,s}_generateAudioStream(e){const{id:t}=e,n=this._remoteStreams[t]||new MediaStream;return n.addTrack(e),this._remoteStreams[t]=n,n}_generateStreams(e){const t=[];return e.forEach((n,s)=>{if(n.kind==="audio")return;const o=n,a=e[s-1];let c;a&&a.kind==="audio"&&(c=a);const E=this._generateStream(o,c);t.push(E)}),t}_generateAudioStreams(e){return e.map(n=>this._generateAudioStream(n))}_cancelRequests(){this._cancelActionsRequests(),this._cancelCallRequests(),this._cancelConnectRequests()}_cancelConnectRequests(){this._cancelableConnect.cancelRequest()}_cancelCallRequests(){this._cancelableCall.cancelRequest(),this._cancelableAnswer.cancelRequest()}_cancelActionsRequests(){this._cancelableAnswer.cancelRequest(),this._cancelableSendDTMF.cancelRequest()}async waitChannels(){return this.waitSession(v)}async waitSyncMediaState(){return this.waitSession(b)}async sendChannels({inputChannels:e,outputChannels:t}){if(!this.session)throw new Error("No session established");const n=`${ve}: ${e}`,s=`${be}: ${t}`,o=[n,s];return this.session.sendInfo(Jt,void 0,{extraHeaders:o})}async sendMediaState({cam:e,mic:t},n={}){if(!this.session)throw new Error("No session established");const s=`${sn}: currentstate`,o=`${on}: ${Number(e)}`,a=`${an}: ${Number(t)}`,c=[s,o,a];return this.session.sendInfo(zt,void 0,{noTerminateWhenError:!0,...n,extraHeaders:c})}async _sendRefusalToTurnOn(e,t={}){if(!this.session)throw new Error("No session established");const c=[`${rn}: ${e==="mic"?0:1}`];return this.session.sendInfo(Qt,void 0,{noTerminateWhenError:!0,...t,extraHeaders:c})}async sendRefusalToTurnOnMic(e={}){if(!this.session)throw new Error("No session established");return this._sendRefusalToTurnOn("mic",{noTerminateWhenError:!0,...e})}async sendRefusalToTurnOnCam(e={}){if(!this.session)throw new Error("No session established");return this._sendRefusalToTurnOn("cam",{noTerminateWhenError:!0,...e})}}exports.BAD_MEDIA_DESCRIPTION=Fe;exports.EEventsMainCAM=A;exports.EEventsMic=L;exports.EEventsSyncMediaState=H;exports.EUseLicense=ut;exports.NOT_FOUND=qe;exports.REJECTED=V;exports.SESSION_EVENT_NAMES=Oe;exports.SipConnector=xn;exports.UA_EVENT_NAMES=fe;exports.causes=Bt;exports.constants=Vt;exports.disableDebug=gn;exports.enableDebug=Nn;exports.eventNames=Yt;exports.hasCanceledCallError=wn;exports.logger=W;exports.setEncodingsToSender=Nt;