@telnyx/webrtc 2.25.17-beta.2 → 2.25.18

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.
@@ -1,7 +1,7 @@
1
1
  import * as log from 'loglevel';
2
2
  import BaseMessage from './messages/BaseMessage';
3
3
  import Connection from './services/Connection';
4
- import { BroadcastParams, IVertoOptions } from './util/interfaces';
4
+ import { BroadcastParams, ILoginParams, IVertoOptions } from './util/interfaces';
5
5
  export default abstract class BaseSession {
6
6
  options: IVertoOptions;
7
7
  uuid: string;
@@ -17,7 +17,6 @@ export default abstract class BaseSession {
17
17
  timeoutErrorCode: number;
18
18
  invalidMethodErrorCode: number;
19
19
  authenticationRequiredErrorCode: number;
20
- callReportId: string | null;
21
20
  connection: Connection;
22
21
  protected _jwtAuth: boolean;
23
22
  protected _keepAliveTimeout: any;
@@ -41,6 +40,12 @@ export default abstract class BaseSession {
41
40
  off(eventName: string, callback?: Function): this;
42
41
  connect(): Promise<void>;
43
42
  protected _handleLoginError(error: any): void;
43
+ login({ creds, onSuccess, onError, }?: {
44
+ creds?: ILoginParams;
45
+ onSuccess?: () => void;
46
+ onError?: (error: any) => void;
47
+ }): Promise<void>;
48
+ private _login;
44
49
  protected _onSocketOpen(): Promise<void>;
45
50
  onNetworkClose(): void;
46
51
  protected _onSocketMessage(response: any): void;
@@ -4,7 +4,7 @@ declare type AnonymousLoginConstructorParams = {
4
4
  target_type: string;
5
5
  target_version_id?: string;
6
6
  sessionId?: string;
7
- userVariables?: Object;
7
+ userVariables?: Record<string, any>;
8
8
  reconnection?: boolean;
9
9
  };
10
10
  declare class AnonymousLogin extends BaseRequest {
@@ -1,6 +1,6 @@
1
1
  import BaseRequest from './BaseRequest';
2
2
  declare class Login extends BaseRequest {
3
3
  method: string;
4
- constructor(login: string, passwd: string, login_token: string, sessionid: string, userVariables: Object, reconnection: boolean);
4
+ constructor(login: string, passwd: string, login_token: string, sessionid: string, userVariables: Record<string, any>, reconnection: boolean);
5
5
  }
6
6
  export { Login };
@@ -17,7 +17,6 @@ export default class Connection {
17
17
  get closed(): boolean;
18
18
  get isAlive(): boolean;
19
19
  get isDead(): boolean;
20
- get host(): string;
21
20
  connect(): void;
22
21
  sendRawText(request: string): void;
23
22
  send(bladeObj: any): Promise<any>;
@@ -18,12 +18,12 @@ export declare const TURN_SERVER: {
18
18
  urls: string;
19
19
  username: string;
20
20
  credential: string;
21
- };
21
+ }[];
22
22
  export declare const TURN_DEV_SERVER: {
23
23
  urls: string;
24
24
  username: string;
25
25
  credential: string;
26
- };
26
+ }[];
27
27
  export declare const DEFAULT_PROD_ICE_SERVERS: RTCIceServer[];
28
28
  export declare const DEFAULT_DEV_ICE_SERVERS: RTCIceServer[];
29
29
  export declare enum SwEvent {
@@ -8,7 +8,7 @@ export interface IVertoOptions {
8
8
  passwd?: string;
9
9
  password?: string;
10
10
  login_token?: string;
11
- userVariables?: Object;
11
+ userVariables?: Record<string, any>;
12
12
  ringtoneFile?: string;
13
13
  ringbackFile?: string;
14
14
  env?: Environment;
@@ -31,10 +31,18 @@ export interface IVertoOptions {
31
31
  rtcIp?: string;
32
32
  rtcPort?: number;
33
33
  mutedMicOnStart?: boolean;
34
- enableCallReports?: boolean;
35
- callReportInterval?: number;
36
- debugLogLevel?: 'debug' | 'info' | 'warn' | 'error';
37
- debugLogMaxEntries?: number;
34
+ }
35
+ export interface ILoginParams {
36
+ login?: string;
37
+ password?: string;
38
+ passwd?: string;
39
+ login_token?: string;
40
+ userVariables?: Record<string, any>;
41
+ anonymous_login?: {
42
+ target_type: string;
43
+ target_id: string;
44
+ target_version_id?: string;
45
+ };
38
46
  }
39
47
  export interface SubscribeParams {
40
48
  channels?: string[];
@@ -2,11 +2,11 @@ import BrowserSession from '../BrowserSession';
2
2
  import Call from './Call';
3
3
  import Peer from './Peer';
4
4
  import { Direction, State } from './constants';
5
- import { AnswerParams, IVertoCallOptions, IWebRTCCall } from './interfaces';
5
+ import { AnswerParams, IHangupParams, IVertoCallOptions, IWebRTCCall } from './interfaces';
6
6
  export default abstract class BaseCall implements IWebRTCCall {
7
7
  protected session: BrowserSession;
8
+ private _isRecovering;
8
9
  private _webRTCStats;
9
- private _callReportCollector;
10
10
  id: string;
11
11
  state: string;
12
12
  prevState: string;
@@ -39,7 +39,7 @@ export default abstract class BaseCall implements IWebRTCCall {
39
39
  private _isRemoteDescriptionSet;
40
40
  private _signalingStateClosed;
41
41
  private _creatingPeer;
42
- constructor(session: BrowserSession, opts?: IVertoCallOptions);
42
+ constructor(session: BrowserSession, opts?: IVertoCallOptions, _isRecovering?: boolean);
43
43
  private get performanceMetrics();
44
44
  get nodeId(): string;
45
45
  set nodeId(what: string);
@@ -60,7 +60,7 @@ export default abstract class BaseCall implements IWebRTCCall {
60
60
  playRingback(): void;
61
61
  stopRingback(): void;
62
62
  hangup(): void;
63
- hangup(hangupParams: any, hangupExecute: any): void;
63
+ hangup(hangupParams: IHangupParams, hangupExecute: boolean): void;
64
64
  hold(): Promise<any>;
65
65
  unhold(): Promise<any>;
66
66
  toggleHold(): Promise<any>;
@@ -113,7 +113,6 @@ export default abstract class BaseCall implements IWebRTCCall {
113
113
  private _execute;
114
114
  private _init;
115
115
  protected _finalize(): void;
116
- private _postCallReport;
117
116
  private _startStats;
118
117
  private _stopStats;
119
118
  private _doStats;
@@ -6,7 +6,7 @@ export default class Peer {
6
6
  type: PeerType;
7
7
  private options;
8
8
  instance: RTCPeerConnection;
9
- onSdpReadyTwice: Function;
9
+ onSdpReadyTwice: ((data: RTCSessionDescription) => void) | null;
10
10
  statsReporter: WebRTCStatsReporter | null;
11
11
  private _constraints;
12
12
  private _session;
@@ -21,8 +21,8 @@ export default class Peer {
21
21
  get isAnswer(): boolean;
22
22
  get isDebugEnabled(): boolean;
23
23
  get debugOutput(): "socket" | "file";
24
- get keepConnectionAliveOnSocketClose(): boolean;
25
24
  get restartedIceOnConnectionStateFailed(): boolean;
25
+ isConnectionHealthy(): boolean;
26
26
  startNegotiation(): void;
27
27
  startTrickleIceNegotiation(): Promise<void>;
28
28
  private _logTransceivers;
@@ -8,8 +8,6 @@ declare class VertoHandler {
8
8
  constructor(session: BrowserSession);
9
9
  private _ack;
10
10
  private reconnectDelay;
11
- private handleLogin;
12
- private handleAnonymousLogin;
13
11
  handleMessage(msg: any): Promise<void>;
14
12
  private _retrieveCallId;
15
13
  private _handlePvtEvent;
@@ -40,6 +40,9 @@ export declare const NOTIFICATION_TYPE: {
40
40
  peerConnectionFailureError: string;
41
41
  signalingStateClosed: string;
42
42
  };
43
+ export declare const ERROR_TYPE: {
44
+ invalidCredentialsOptions: string;
45
+ };
43
46
  export declare const DEFAULT_CALL_OPTIONS: IVertoCallOptions;
44
47
  export declare enum State {
45
48
  New = 0,
@@ -1,7 +1,22 @@
1
+ import { State } from './constants';
1
2
  export interface IMediaSettings {
2
3
  useSdpASBandwidthKbps?: boolean;
3
4
  sdpASBandwidthKbps?: number;
4
5
  }
6
+ export interface IHangupParams {
7
+ cause?: string;
8
+ causeCode?: number;
9
+ sipCode?: number;
10
+ sipReason?: string;
11
+ sip_call_id?: string;
12
+ dialogParams?: {
13
+ customHeaders?: Array<{
14
+ name: string;
15
+ value: string;
16
+ }>;
17
+ };
18
+ isRecovering?: boolean;
19
+ }
5
20
  export interface IVertoCallOptions {
6
21
  destinationNumber?: string;
7
22
  remoteCallerName?: string;
@@ -24,9 +39,7 @@ export interface IVertoCallOptions {
24
39
  camId?: string;
25
40
  camLabel?: string;
26
41
  speakerId?: string;
27
- userVariables?: {
28
- [key: string]: any;
29
- };
42
+ userVariables?: Record<string, any>;
30
43
  screenShare?: boolean;
31
44
  onNotification?: Function;
32
45
  googleMaxBitrate?: number;
@@ -75,6 +88,8 @@ export interface IWebRTCCall {
75
88
  instance?: RTCPeerConnection | null;
76
89
  restartedIceOnConnectionStateFailed?: boolean;
77
90
  restartStatsReporter?: () => Promise<void>;
91
+ isConnectionHealthy?: () => boolean;
92
+ close?: () => Promise<void>;
78
93
  } | null;
79
94
  options: IVertoCallOptions;
80
95
  cause: string;
@@ -89,7 +104,7 @@ export interface IWebRTCCall {
89
104
  signalingStateClosed: boolean;
90
105
  invite: () => void;
91
106
  answer: (params: AnswerParams) => void;
92
- hangup: (params: any, execute: boolean) => void;
107
+ hangup: (params: IHangupParams, execute: boolean) => void;
93
108
  hold: () => void;
94
109
  unhold: () => void;
95
110
  toggleHold: () => void;
@@ -109,7 +124,7 @@ export interface IWebRTCCall {
109
124
  setAudioBandwidthEncodingsMaxBps: (max: number) => void;
110
125
  setVideoBandwidthEncodingsMaxBps: (max: number) => void;
111
126
  getStats: (callback: Function, constraints: any) => void;
112
- setState: (state: any) => void;
127
+ setState: (state: State) => void;
113
128
  handleMessage: (msg: any) => void;
114
129
  _addChannel: (laChannel: any) => void;
115
130
  handleConferenceUpdate: (packet: any, pvtData: any) => Promise<string>;
@@ -1,6 +1,7 @@
1
1
  import TelnyxRTC from './TelnyxRTC';
2
2
  import { IClientOptions, ICallOptions, ICredentials, INotification } from './utils/interfaces';
3
3
  import { SwEvent } from './Modules/Verto/util/constants';
4
+ import { NOTIFICATION_TYPE, ERROR_TYPE } from './Modules/Verto/webrtc/constants';
4
5
  import Call from './Modules/Verto/webrtc/Call';
5
- export { Call, TelnyxRTC, IClientOptions, ICallOptions, ICredentials, INotification, SwEvent, };
6
+ export { Call, TelnyxRTC, IClientOptions, ICallOptions, ICredentials, INotification, SwEvent, NOTIFICATION_TYPE, ERROR_TYPE, };
6
7
  export * from './PreCallDiagnosis';
@@ -29,8 +29,6 @@ export interface IClientOptions {
29
29
  env?: Environment;
30
30
  iceServers?: RTCIceServer[];
31
31
  mutedMicOnStart?: boolean;
32
- enableCallReports?: boolean;
33
- callReportInterval?: number;
34
32
  }
35
33
  export interface ICallOptions {
36
34
  destinationNumber?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telnyx/webrtc",
3
- "version": "2.25.17-beta.2",
3
+ "version": "2.25.18",
4
4
  "description": "Telnyx WebRTC Client",
5
5
  "keywords": [
6
6
  "telnyx",
@@ -105,7 +105,7 @@
105
105
  "yarn eslint --fix",
106
106
  "yarn prettier --write"
107
107
  ],
108
- "**/*.{md}": [
108
+ "**/*.md": [
109
109
  "yarn eslint",
110
110
  "yarn prettier --write"
111
111
  ]
@@ -1,29 +0,0 @@
1
- export declare type LogLevel = 'debug' | 'info' | 'warn' | 'error';
2
- export interface ILogEntry {
3
- timestamp: string;
4
- level: LogLevel;
5
- message: string;
6
- context?: Record<string, unknown>;
7
- }
8
- export interface ILogCollectorOptions {
9
- enabled: boolean;
10
- level: LogLevel;
11
- maxEntries: number;
12
- }
13
- export declare class LogCollector {
14
- private options;
15
- private buffer;
16
- private isCapturing;
17
- constructor(options?: Partial<ILogCollectorOptions>);
18
- start(): void;
19
- stop(): void;
20
- addEntry(level: LogLevel, message: string, context?: Record<string, unknown>): void;
21
- getLogs(): ILogEntry[];
22
- getLogCount(): number;
23
- clear(): void;
24
- isActive(): boolean;
25
- isEnabled(): boolean;
26
- }
27
- export declare function getGlobalLogCollector(): LogCollector | null;
28
- export declare function setGlobalLogCollector(collector: LogCollector | null): void;
29
- export declare function createLogCollector(options: Partial<ILogCollectorOptions>): LogCollector;
@@ -1,91 +0,0 @@
1
- import { ILogEntry } from '../../../Modules/Verto/util/LogCollector';
2
- export interface ICallReportOptions {
3
- enabled: boolean;
4
- interval: number;
5
- }
6
- export interface ILogCollectorOptions {
7
- enabled: boolean;
8
- level: 'debug' | 'info' | 'warn' | 'error';
9
- maxEntries: number;
10
- }
11
- export interface IStatsInterval {
12
- intervalStartUtc: string;
13
- intervalEndUtc: string;
14
- audio?: {
15
- outbound?: {
16
- packetsSent?: number;
17
- bytesSent?: number;
18
- audioLevelAvg?: number;
19
- bitrateAvg?: number;
20
- };
21
- inbound?: {
22
- packetsReceived?: number;
23
- bytesReceived?: number;
24
- packetsLost?: number;
25
- packetsDiscarded?: number;
26
- jitterBufferDelay?: number;
27
- jitterBufferEmittedCount?: number;
28
- totalSamplesReceived?: number;
29
- concealedSamples?: number;
30
- concealmentEvents?: number;
31
- audioLevelAvg?: number;
32
- jitterAvg?: number;
33
- bitrateAvg?: number;
34
- };
35
- };
36
- connection?: {
37
- roundTripTimeAvg?: number;
38
- packetsSent?: number;
39
- packetsReceived?: number;
40
- bytesSent?: number;
41
- bytesReceived?: number;
42
- };
43
- }
44
- export interface ICallSummary {
45
- callId: string;
46
- destinationNumber?: string;
47
- callerNumber?: string;
48
- direction?: 'inbound' | 'outbound';
49
- state?: string;
50
- durationSeconds?: number;
51
- telnyxSessionId?: string;
52
- telnyxLegId?: string;
53
- voiceSdkSessionId?: string;
54
- sdkVersion?: string;
55
- startTimestamp?: string;
56
- endTimestamp?: string;
57
- }
58
- export interface ICallReportPayload {
59
- summary: ICallSummary;
60
- stats: IStatsInterval[];
61
- logs?: ILogEntry[];
62
- }
63
- export declare class CallReportCollector {
64
- private options;
65
- private logCollectorOptions;
66
- private peerConnection;
67
- private intervalId;
68
- private statsBuffer;
69
- private intervalStartTime;
70
- private callStartTime;
71
- private callEndTime;
72
- private logCollector;
73
- private intervalAudioLevels;
74
- private intervalJitters;
75
- private intervalRTTs;
76
- private intervalBitrates;
77
- private previousStats;
78
- private readonly MAX_BUFFER_SIZE;
79
- constructor(options: ICallReportOptions, logCollectorOptions?: ILogCollectorOptions);
80
- start(peerConnection: RTCPeerConnection): void;
81
- stop(): void;
82
- postReport(summary: ICallSummary, callReportId: string, host: string, voiceSdkId?: string): Promise<void>;
83
- getStatsBuffer(): IStatsInterval[];
84
- getLogs(): ILogEntry[];
85
- cleanup(): void;
86
- private _collectStats;
87
- private _createStatsEntry;
88
- private _getTrackAudioLevel;
89
- private _average;
90
- private _resetIntervalAccumulators;
91
- }