@telnyx/webrtc 2.25.18 → 2.25.20
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/lib/bundle.js +1 -1
- package/lib/bundle.mjs +1 -1
- package/lib/packages/js/src/Modules/Verto/BaseSession.d.ts +3 -2
- package/lib/packages/js/src/Modules/Verto/index.d.ts +1 -0
- package/lib/packages/js/src/Modules/Verto/services/Connection.d.ts +9 -2
- package/lib/packages/js/src/Modules/Verto/util/LogCollector.d.ts +30 -0
- package/lib/packages/js/src/Modules/Verto/util/constants/index.d.ts +12 -0
- package/lib/packages/js/src/Modules/Verto/util/interfaces.d.ts +4 -0
- package/lib/packages/js/src/Modules/Verto/util/logger.d.ts +1 -0
- package/lib/packages/js/src/Modules/Verto/webrtc/BaseCall.d.ts +3 -0
- package/lib/packages/js/src/Modules/Verto/webrtc/CallReportCollector.d.ts +100 -0
- package/lib/packages/js/src/Modules/Verto/webrtc/VertoHandler.d.ts +3 -3
- package/lib/packages/js/src/utils/interfaces.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { Logger } from 'loglevel';
|
|
2
2
|
import BaseMessage from './messages/BaseMessage';
|
|
3
3
|
import Connection from './services/Connection';
|
|
4
4
|
import { BroadcastParams, ILoginParams, IVertoOptions } from './util/interfaces';
|
|
@@ -17,6 +17,7 @@ export default abstract class BaseSession {
|
|
|
17
17
|
timeoutErrorCode: number;
|
|
18
18
|
invalidMethodErrorCode: number;
|
|
19
19
|
authenticationRequiredErrorCode: number;
|
|
20
|
+
callReportId: string | null;
|
|
20
21
|
connection: Connection;
|
|
21
22
|
protected _jwtAuth: boolean;
|
|
22
23
|
protected _keepAliveTimeout: any;
|
|
@@ -27,7 +28,7 @@ export default abstract class BaseSession {
|
|
|
27
28
|
private _pong;
|
|
28
29
|
private registerAgent;
|
|
29
30
|
constructor(options: IVertoOptions);
|
|
30
|
-
get __logger():
|
|
31
|
+
get __logger(): Logger;
|
|
31
32
|
get connected(): boolean;
|
|
32
33
|
getIsRegistered(): Promise<boolean>;
|
|
33
34
|
get reconnectDelay(): number;
|
|
@@ -6,6 +6,7 @@ export declare const VERTO_PROTOCOL = "verto-protocol";
|
|
|
6
6
|
export default class Verto extends BrowserSession {
|
|
7
7
|
relayProtocol: string;
|
|
8
8
|
timeoutErrorCode: number;
|
|
9
|
+
private _vertoHandler;
|
|
9
10
|
constructor(options: IVertoOptions);
|
|
10
11
|
validateOptions(): boolean;
|
|
11
12
|
newCall(options: IVertoCallOptions): Call;
|
|
@@ -8,8 +8,9 @@ export default class Connection {
|
|
|
8
8
|
private _timers;
|
|
9
9
|
private _useCanaryRtcServer;
|
|
10
10
|
private _hasCanaryBeenUsed;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
private _safetyTimeoutId;
|
|
12
|
+
upDur: number | null;
|
|
13
|
+
downDur: number | null;
|
|
13
14
|
constructor(session: BaseSession);
|
|
14
15
|
get connected(): boolean;
|
|
15
16
|
get connecting(): boolean;
|
|
@@ -17,10 +18,16 @@ export default class Connection {
|
|
|
17
18
|
get closed(): boolean;
|
|
18
19
|
get isAlive(): boolean;
|
|
19
20
|
get isDead(): boolean;
|
|
21
|
+
get host(): string;
|
|
20
22
|
connect(): void;
|
|
21
23
|
sendRawText(request: string): void;
|
|
22
24
|
send(bladeObj: any): Promise<any>;
|
|
23
25
|
close(): void;
|
|
26
|
+
private _registerSocketEvents;
|
|
27
|
+
private _deregisterSocketEvents;
|
|
28
|
+
private _handleCloseTimeout;
|
|
29
|
+
private _clearSafetyTimeout;
|
|
30
|
+
private _safetyCleanupSocket;
|
|
24
31
|
private _unsetTimer;
|
|
25
32
|
private _handleStringResponse;
|
|
26
33
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
drain(): ILogEntry[];
|
|
24
|
+
clear(): void;
|
|
25
|
+
isActive(): boolean;
|
|
26
|
+
isEnabled(): boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare function getGlobalLogCollector(): LogCollector | null;
|
|
29
|
+
export declare function setGlobalLogCollector(collector: LogCollector | null): void;
|
|
30
|
+
export declare function createLogCollector(options: Partial<ILogCollectorOptions>): LogCollector;
|
|
@@ -5,6 +5,18 @@ export declare const SESSION_ID = "sessId";
|
|
|
5
5
|
export declare const TIME_CALL_INVITE = "Time to call invite";
|
|
6
6
|
export declare const PROD_HOST = "wss://rtc.telnyx.com";
|
|
7
7
|
export declare const DEV_HOST = "wss://rtcdev.telnyx.com";
|
|
8
|
+
export declare const WS_CLOSE_CODES: {
|
|
9
|
+
readonly NORMAL_CLOSURE: 1000;
|
|
10
|
+
readonly GOING_AWAY: 1001;
|
|
11
|
+
readonly PROTOCOL_ERROR: 1002;
|
|
12
|
+
readonly UNSUPPORTED_DATA: 1003;
|
|
13
|
+
readonly NO_STATUS_RECEIVED: 1005;
|
|
14
|
+
readonly ABNORMAL_CLOSURE: 1006;
|
|
15
|
+
readonly INVALID_FRAME_PAYLOAD: 1007;
|
|
16
|
+
readonly POLICY_VIOLATION: 1008;
|
|
17
|
+
readonly MESSAGE_TOO_BIG: 1009;
|
|
18
|
+
readonly INTERNAL_ERROR: 1011;
|
|
19
|
+
};
|
|
8
20
|
export declare const GOOGLE_STUN_SERVER: {
|
|
9
21
|
urls: string;
|
|
10
22
|
};
|
|
@@ -31,6 +31,10 @@ 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
38
|
}
|
|
35
39
|
export interface ILoginParams {
|
|
36
40
|
login?: string;
|
|
@@ -7,6 +7,7 @@ export default abstract class BaseCall implements IWebRTCCall {
|
|
|
7
7
|
protected session: BrowserSession;
|
|
8
8
|
private _isRecovering;
|
|
9
9
|
private _webRTCStats;
|
|
10
|
+
private _callReportCollector;
|
|
10
11
|
id: string;
|
|
11
12
|
state: string;
|
|
12
13
|
prevState: string;
|
|
@@ -113,6 +114,8 @@ export default abstract class BaseCall implements IWebRTCCall {
|
|
|
113
114
|
private _execute;
|
|
114
115
|
private _init;
|
|
115
116
|
protected _finalize(): void;
|
|
117
|
+
private _flushIntermediateReport;
|
|
118
|
+
private _postCallReport;
|
|
116
119
|
private _startStats;
|
|
117
120
|
private _stopStats;
|
|
118
121
|
private _doStats;
|
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
segment?: number;
|
|
63
|
+
}
|
|
64
|
+
export declare class CallReportCollector {
|
|
65
|
+
private options;
|
|
66
|
+
private logCollectorOptions;
|
|
67
|
+
private peerConnection;
|
|
68
|
+
private intervalId;
|
|
69
|
+
private statsBuffer;
|
|
70
|
+
private intervalStartTime;
|
|
71
|
+
private callStartTime;
|
|
72
|
+
private callEndTime;
|
|
73
|
+
private logCollector;
|
|
74
|
+
private intervalAudioLevels;
|
|
75
|
+
private intervalJitters;
|
|
76
|
+
private intervalRTTs;
|
|
77
|
+
private intervalBitrates;
|
|
78
|
+
private previousStats;
|
|
79
|
+
private readonly MAX_BUFFER_SIZE;
|
|
80
|
+
private static readonly STATS_FLUSH_THRESHOLD;
|
|
81
|
+
private static readonly LOGS_FLUSH_THRESHOLD;
|
|
82
|
+
onFlushNeeded: (() => void) | null;
|
|
83
|
+
private _segmentIndex;
|
|
84
|
+
private _flushing;
|
|
85
|
+
constructor(options: ICallReportOptions, logCollectorOptions?: ILogCollectorOptions);
|
|
86
|
+
start(peerConnection: RTCPeerConnection): void;
|
|
87
|
+
stop(): void;
|
|
88
|
+
flush(summary: ICallSummary): ICallReportPayload | null;
|
|
89
|
+
postReport(summary: ICallSummary, callReportId: string, host: string, voiceSdkId?: string): Promise<void>;
|
|
90
|
+
sendPayload(payload: ICallReportPayload, callReportId: string, host: string, voiceSdkId?: string): Promise<void>;
|
|
91
|
+
private _sendPayload;
|
|
92
|
+
getStatsBuffer(): IStatsInterval[];
|
|
93
|
+
getLogs(): ILogEntry[];
|
|
94
|
+
cleanup(): void;
|
|
95
|
+
private _collectStats;
|
|
96
|
+
private _createStatsEntry;
|
|
97
|
+
private _getTrackAudioLevel;
|
|
98
|
+
private _average;
|
|
99
|
+
private _resetIntervalAccumulators;
|
|
100
|
+
}
|
|
@@ -2,9 +2,9 @@ import BrowserSession from '../BrowserSession';
|
|
|
2
2
|
declare class VertoHandler {
|
|
3
3
|
session: BrowserSession;
|
|
4
4
|
nodeId: string;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
retriedConnect: number;
|
|
6
|
+
retriedRegister: number;
|
|
7
|
+
receivedAuthenticationRequired: number;
|
|
8
8
|
constructor(session: BrowserSession);
|
|
9
9
|
private _ack;
|
|
10
10
|
private reconnectDelay;
|