@telnyx/react-voice-commons-sdk 1.1.0 → 1.2.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 (35) hide show
  1. package/CHANGELOG.md +38 -1
  2. package/TelnyxVoiceCommons.podspec +3 -3
  3. package/ios/CallKitBridge.m +7 -0
  4. package/ios/CallKitBridge.swift +239 -91
  5. package/lib/callkit/callkit-coordinator.d.ts +19 -0
  6. package/lib/callkit/callkit-coordinator.js +105 -5
  7. package/lib/index.d.ts +4 -1
  8. package/lib/index.js +9 -0
  9. package/lib/internal/calls/call-state-controller.d.ts +1 -0
  10. package/lib/internal/calls/call-state-controller.js +35 -1
  11. package/lib/internal/ice-servers-storage.d.ts +9 -0
  12. package/lib/internal/ice-servers-storage.js +37 -0
  13. package/lib/internal/sdk-identity.d.ts +4 -0
  14. package/lib/internal/sdk-identity.js +60 -0
  15. package/lib/internal/session/session-manager.d.ts +7 -2
  16. package/lib/internal/session/session-manager.js +35 -4
  17. package/lib/internal/signaling-environment.d.ts +13 -0
  18. package/lib/internal/signaling-environment.js +18 -0
  19. package/lib/models/call.d.ts +23 -2
  20. package/lib/models/call.js +37 -2
  21. package/lib/models/config.d.ts +28 -0
  22. package/lib/telnyx-voip-client.d.ts +4 -2
  23. package/lib/telnyx-voip-client.js +60 -2
  24. package/package.json +3 -4
  25. package/src/callkit/callkit-coordinator.ts +129 -7
  26. package/src/index.ts +6 -1
  27. package/src/internal/calls/call-state-controller.ts +41 -2
  28. package/src/internal/ice-servers-storage.ts +37 -0
  29. package/src/internal/sdk-identity.ts +6 -0
  30. package/src/internal/session/session-manager.ts +38 -4
  31. package/src/internal/signaling-environment.ts +20 -0
  32. package/src/models/call.ts +44 -2
  33. package/src/models/config.ts +30 -0
  34. package/src/telnyx-voip-client.ts +60 -3
  35. package/src/types/telnyx-sdk.d.ts +67 -2
@@ -24,7 +24,15 @@ declare module '@telnyx/react-native-voice-sdk' {
24
24
  };
25
25
  }
26
26
 
27
+ /** A STUN/TURN server for WebRTC peer connections (core `TelnyxIceServer`). */
28
+ export interface TelnyxIceServer {
29
+ urls: string;
30
+ username?: string;
31
+ credential?: string;
32
+ }
33
+
27
34
  export interface ClientOptions {
35
+ environment?: 'production' | 'development';
28
36
  login?: string;
29
37
  password?: string;
30
38
  token?: string;
@@ -38,9 +46,13 @@ declare module '@telnyx/react-native-voice-sdk' {
38
46
  enableMissedCallNotifications?: boolean;
39
47
  useTrickleIce?: boolean;
40
48
  enableCallReports?: boolean;
49
+ enableQualityMetrics?: boolean;
41
50
  callReportInterval?: number;
42
51
  callReportLogLevel?: string;
43
52
  callReportMaxLogEntries?: number;
53
+ /** Custom ICE servers (STUN/TURN) for WebRTC peer connections */
54
+ iceServers?: TelnyxIceServer[];
55
+ sdkName?: string;
44
56
  sdkVersion?: string;
45
57
  }
46
58
 
@@ -55,6 +67,52 @@ declare module '@telnyx/react-native-voice-sdk' {
55
67
  PURGE = 'purge',
56
68
  }
57
69
 
70
+ /**
71
+ * Quality rating derived from the MOS score (same bands as iOS and Android).
72
+ */
73
+ export enum CallQualityLevel {
74
+ EXCELLENT = 'excellent',
75
+ GOOD = 'good',
76
+ FAIR = 'fair',
77
+ POOR = 'poor',
78
+ BAD = 'bad',
79
+ UNKNOWN = 'unknown',
80
+ }
81
+
82
+ /** A raw WebRTC stats report, copied as a plain object. */
83
+ export type QualityStatsRecord = Record<string, unknown>;
84
+
85
+ /**
86
+ * Snapshot of call quality metrics at a single sampling point. Field names
87
+ * and units match iOS `CallQualityMetrics`.
88
+ */
89
+ export interface CallQualityMetrics {
90
+ /** The call identifier this metrics snapshot belongs to. */
91
+ callId: string;
92
+ /** ISO-8601 timestamp of when the metrics were collected. */
93
+ timestamp: string;
94
+ /** Jitter in seconds, or null when unavailable. */
95
+ jitter: number | null;
96
+ /** Round-trip time in seconds, or null when unavailable. */
97
+ rtt: number | null;
98
+ /** Mean Opinion Score (1.0–5.0), or null when it cannot be calculated. */
99
+ mos: number | null;
100
+ /** Quality rating derived from `mos`; UNKNOWN when `mos` is null. */
101
+ quality: CallQualityLevel;
102
+ /** Instantaneous inbound (remote) audio level, 0.0–1.0. */
103
+ inboundAudioLevel: number;
104
+ /** Instantaneous outbound (local) audio level, 0.0–1.0. */
105
+ outboundAudioLevel: number;
106
+ /** Raw `inbound-rtp` audio stats, or null when unavailable. */
107
+ inboundAudio: QualityStatsRecord | null;
108
+ /** Raw `outbound-rtp` audio stats, or null when unavailable. */
109
+ outboundAudio: QualityStatsRecord | null;
110
+ /** Raw `remote-inbound-rtp` audio stats, or null when unavailable. */
111
+ remoteInboundAudio: QualityStatsRecord | null;
112
+ /** Raw `remote-outbound-rtp` audio stats, or null when unavailable. */
113
+ remoteOutboundAudio: QualityStatsRecord | null;
114
+ }
115
+
58
116
  export class Call extends EventEmitter {
59
117
  callId: string;
60
118
  state: CallState;
@@ -67,17 +125,24 @@ declare module '@telnyx/react-native-voice-sdk' {
67
125
  /**
68
126
  * Custom headers received from the WebRTC INVITE message.
69
127
  * These headers are passed during call initiation and can contain application-specific information.
70
- * Format should be [{"name": "X-Header-Name", "value": "Value"}] where header names must start with "X-".
128
+ * Format: `[{"name": "X-Header-Name", "value": "Value"}]`; header names must start with `X-`.
71
129
  */
72
130
  inviteCustomHeaders: { name: string; value: string }[] | null;
73
131
 
74
132
  /**
75
133
  * Custom headers received from the WebRTC ANSWER message.
76
134
  * These headers are passed during call acceptance and can contain application-specific information.
77
- * Format should be [{"name": "X-Header-Name", "value": "Value"}] where header names must start with "X-".
135
+ * Format: `[{"name": "X-Header-Name", "value": "Value"}]`; header names must start with `X-`.
78
136
  */
79
137
  answerCustomHeaders: { name: string; value: string }[] | null;
80
138
 
139
+ /**
140
+ * Callback invoked with each call quality metrics snapshot (every 200 ms by
141
+ * default) while collection is active. Snapshots are also emitted as the
142
+ * `telnyx.call.qualityMetrics` event.
143
+ */
144
+ onQualityMetrics: ((metrics: CallQualityMetrics) => void) | null;
145
+
81
146
  constructor(options: any);
82
147
 
83
148
  answer(customHeaders?: { name: string; value: string }[]): Promise<void>;