@telnyx/react-voice-commons-sdk 0.1.2 → 0.1.4
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/CHANGELOG.md +60 -0
- package/README.md +469 -483
- package/ios/CallKitBridge.swift +2 -7
- package/lib/callkit/callkit-coordinator.d.ts +110 -117
- package/lib/callkit/callkit-coordinator.js +664 -727
- package/lib/callkit/callkit.d.ts +41 -41
- package/lib/callkit/callkit.js +252 -242
- package/lib/callkit/index.js +15 -47
- package/lib/callkit/use-callkit.d.ts +19 -19
- package/lib/callkit/use-callkit.js +270 -310
- package/lib/context/TelnyxVoiceContext.d.ts +9 -9
- package/lib/context/TelnyxVoiceContext.js +10 -13
- package/lib/hooks/use-callkit-coordinator.d.ts +9 -17
- package/lib/hooks/use-callkit-coordinator.js +45 -50
- package/lib/hooks/useAppReadyNotifier.js +13 -15
- package/lib/hooks/useAppStateHandler.d.ts +6 -11
- package/lib/hooks/useAppStateHandler.js +95 -110
- package/lib/hooks/useNetworkStateHandler.d.ts +0 -0
- package/lib/hooks/useNetworkStateHandler.js +0 -0
- package/lib/index.d.ts +3 -21
- package/lib/index.js +50 -201
- package/lib/internal/CallKitHandler.d.ts +6 -6
- package/lib/internal/CallKitHandler.js +96 -104
- package/lib/internal/callkit-manager.d.ts +57 -57
- package/lib/internal/callkit-manager.js +299 -316
- package/lib/internal/calls/call-state-controller.d.ts +73 -86
- package/lib/internal/calls/call-state-controller.js +263 -307
- package/lib/internal/session/session-manager.d.ts +71 -75
- package/lib/internal/session/session-manager.js +360 -424
- package/lib/internal/user-defaults-helpers.js +49 -39
- package/lib/internal/voice-pn-bridge.d.ts +114 -12
- package/lib/internal/voice-pn-bridge.js +212 -5
- package/lib/models/call-state.d.ts +46 -44
- package/lib/models/call-state.js +70 -68
- package/lib/models/call.d.ts +161 -133
- package/lib/models/call.js +454 -382
- package/lib/models/config.d.ts +11 -18
- package/lib/models/config.js +37 -35
- package/lib/models/connection-state.d.ts +10 -10
- package/lib/models/connection-state.js +16 -16
- package/lib/telnyx-voice-app.d.ts +28 -28
- package/lib/telnyx-voice-app.js +513 -480
- package/lib/telnyx-voip-client.d.ts +167 -167
- package/lib/telnyx-voip-client.js +385 -390
- package/package.json +115 -104
- package/src/callkit/callkit-coordinator.ts +830 -846
- package/src/hooks/useNetworkStateHandler.ts +0 -0
- package/src/internal/calls/call-state-controller.ts +407 -384
- package/src/internal/session/session-manager.ts +483 -467
- package/src/internal/voice-pn-bridge.ts +266 -18
- package/src/models/call-state.ts +105 -98
- package/src/models/call.ts +502 -388
- package/src/telnyx-voice-app.tsx +788 -690
- package/src/telnyx-voip-client.ts +551 -539
- package/src/types/telnyx-sdk.d.ts +93 -79
|
@@ -6,10 +6,10 @@ import { CredentialConfig, TokenConfig } from './models/config';
|
|
|
6
6
|
* Configuration options for TelnyxVoipClient
|
|
7
7
|
*/
|
|
8
8
|
export interface TelnyxVoipClientOptions {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
/** Enable automatic app state management (background/foreground behavior) - default: true */
|
|
10
|
+
enableAppStateManagement?: boolean;
|
|
11
|
+
/** Enable debug logging */
|
|
12
|
+
debug?: boolean;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* The main public interface for the react-voice-commons module.
|
|
@@ -23,166 +23,168 @@ export interface TelnyxVoipClientOptions {
|
|
|
23
23
|
* into their chosen state management solution naturally.
|
|
24
24
|
*/
|
|
25
25
|
export declare class TelnyxVoipClient {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
26
|
+
private readonly _sessionManager;
|
|
27
|
+
private readonly _callStateController;
|
|
28
|
+
private readonly _options;
|
|
29
|
+
private _disposed;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new TelnyxVoipClient instance.
|
|
32
|
+
*
|
|
33
|
+
* @param options Configuration options for the client
|
|
34
|
+
*/
|
|
35
|
+
constructor(options?: TelnyxVoipClientOptions);
|
|
36
|
+
/**
|
|
37
|
+
* Stream of connection state changes.
|
|
38
|
+
*
|
|
39
|
+
* Emits the current status of the connection to the Telnyx backend.
|
|
40
|
+
* Values include connecting, connected, disconnected, and error states.
|
|
41
|
+
* Listen to this to show connection indicators in your UI.
|
|
42
|
+
*/
|
|
43
|
+
get connectionState$(): Observable<TelnyxConnectionState>;
|
|
44
|
+
/**
|
|
45
|
+
* Stream of all current calls.
|
|
46
|
+
*
|
|
47
|
+
* Emits a list of all current Call objects. Use this for applications
|
|
48
|
+
* that need to support multiple simultaneous calls (e.g., call waiting,
|
|
49
|
+
* conference calls).
|
|
50
|
+
*/
|
|
51
|
+
get calls$(): Observable<Call[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Stream of the currently active call.
|
|
54
|
+
*
|
|
55
|
+
* A convenience stream that emits the currently active Call object.
|
|
56
|
+
* It emits null when no call is in progress. Ideal for applications
|
|
57
|
+
* that only handle a single call at a time.
|
|
58
|
+
*/
|
|
59
|
+
get activeCall$(): Observable<Call | null>;
|
|
60
|
+
/**
|
|
61
|
+
* Current connection state (synchronous access).
|
|
62
|
+
*/
|
|
63
|
+
get currentConnectionState(): TelnyxConnectionState;
|
|
64
|
+
/**
|
|
65
|
+
* Current list of calls (synchronous access).
|
|
66
|
+
*/
|
|
67
|
+
get currentCalls(): Call[];
|
|
68
|
+
/**
|
|
69
|
+
* Current active call (synchronous access).
|
|
70
|
+
*/
|
|
71
|
+
get currentActiveCall(): Call | null;
|
|
72
|
+
/**
|
|
73
|
+
* Current session ID (UUID) for this connection.
|
|
74
|
+
*/
|
|
75
|
+
get sessionId(): string;
|
|
76
|
+
/**
|
|
77
|
+
* Configuration options for this client instance.
|
|
78
|
+
*/
|
|
79
|
+
get options(): Required<TelnyxVoipClientOptions>;
|
|
80
|
+
/**
|
|
81
|
+
* Connects to the Telnyx platform using credential authentication.
|
|
82
|
+
*
|
|
83
|
+
* @param config The credential configuration containing SIP username and password
|
|
84
|
+
* @returns A Promise that completes when the connection attempt is initiated
|
|
85
|
+
*
|
|
86
|
+
* Listen to connectionState$ to monitor the actual connection status.
|
|
87
|
+
* Credentials are automatically stored for future reconnection.
|
|
88
|
+
*/
|
|
89
|
+
login(config: CredentialConfig): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Connects to the Telnyx platform using token authentication.
|
|
92
|
+
*
|
|
93
|
+
* @param config The token configuration containing the authentication token
|
|
94
|
+
* @returns A Promise that completes when the connection attempt is initiated
|
|
95
|
+
*
|
|
96
|
+
* Listen to connectionState$ to monitor the actual connection status.
|
|
97
|
+
* Token is automatically stored for future reconnection.
|
|
98
|
+
*/
|
|
99
|
+
loginWithToken(config: TokenConfig): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Disconnects from the Telnyx platform.
|
|
102
|
+
*
|
|
103
|
+
* This method terminates the connection, ends any active calls, and
|
|
104
|
+
* cleans up all related resources.
|
|
105
|
+
*/
|
|
106
|
+
logout(): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* Attempts to reconnect using previously stored configuration.
|
|
109
|
+
*
|
|
110
|
+
* This method is used for auto-reconnection scenarios where the app
|
|
111
|
+
* comes back to the foreground and needs to restore the connection.
|
|
112
|
+
*
|
|
113
|
+
* @returns Promise<boolean> - true if reconnection was successful, false otherwise
|
|
114
|
+
*/
|
|
115
|
+
loginFromStoredConfig(): Promise<boolean>;
|
|
116
|
+
/**
|
|
117
|
+
* Initiates a new outgoing call.
|
|
118
|
+
*
|
|
119
|
+
* @param destination The destination number or SIP URI to call
|
|
120
|
+
* @param callerName Optional caller name to display
|
|
121
|
+
* @param callerNumber Optional caller ID number
|
|
122
|
+
* @param customHeaders Optional custom headers to include with the call
|
|
123
|
+
* @returns A Promise that completes with the Call object once the invitation has been sent
|
|
124
|
+
*
|
|
125
|
+
* The call's state can be monitored through the returned Call object's streams.
|
|
126
|
+
*/
|
|
127
|
+
newCall(destination: string, callerName?: string, callerNumber?: string, customHeaders?: Record<string, string>): Promise<Call>;
|
|
128
|
+
/**
|
|
129
|
+
* Handle push notification payload.
|
|
130
|
+
*
|
|
131
|
+
* This is the unified entry point for all push notifications. It intelligently
|
|
132
|
+
* determines whether to show a new incoming call UI or to process an already
|
|
133
|
+
* actioned (accepted/declined) call upon app launch.
|
|
134
|
+
*
|
|
135
|
+
* @param payload The push notification payload
|
|
136
|
+
*/
|
|
137
|
+
handlePushNotification(payload: Record<string, any>): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Disables push notifications for the current session.
|
|
140
|
+
*
|
|
141
|
+
* This method sends a request to the Telnyx backend to disable push
|
|
142
|
+
* notifications for the current registered device/session.
|
|
143
|
+
*/
|
|
144
|
+
disablePushNotifications(): void;
|
|
145
|
+
/**
|
|
146
|
+
* Set a call to connecting state (used for push notification calls when answered via CallKit)
|
|
147
|
+
* @param callId The ID of the call to set to connecting state
|
|
148
|
+
* @internal
|
|
149
|
+
*/
|
|
150
|
+
setCallConnecting(callId: string): void;
|
|
151
|
+
/**
|
|
152
|
+
* Find a call by its underlying Telnyx call object
|
|
153
|
+
* @param telnyxCall The Telnyx call object to find
|
|
154
|
+
* @internal
|
|
155
|
+
*/
|
|
156
|
+
findCallByTelnyxCall(telnyxCall: any): Call | null;
|
|
157
|
+
/**
|
|
158
|
+
* Queue an answer action for when the call invite arrives (for CallKit integration)
|
|
159
|
+
* This should be called when the user answers from CallKit before the socket connection is established
|
|
160
|
+
* @param customHeaders Optional custom headers to include with the answer
|
|
161
|
+
*/
|
|
162
|
+
queueAnswerFromCallKit(customHeaders?: Record<string, string>): void;
|
|
163
|
+
/**
|
|
164
|
+
* Queue an end action for when the call invite arrives (for CallKit integration)
|
|
165
|
+
* This should be called when the user ends from CallKit before the socket connection is established
|
|
166
|
+
*/
|
|
167
|
+
queueEndFromCallKit(): void;
|
|
168
|
+
/**
|
|
169
|
+
* Dispose of the client and clean up all resources.
|
|
170
|
+
*
|
|
171
|
+
* After calling this method, the client instance should not be used anymore.
|
|
172
|
+
* This is particularly important for background clients that should be
|
|
173
|
+
* disposed after handling push notifications.
|
|
174
|
+
*/
|
|
175
|
+
dispose(): void;
|
|
176
|
+
/**
|
|
177
|
+
* Store credential configuration for automatic reconnection
|
|
178
|
+
*/
|
|
179
|
+
private _storeCredentials;
|
|
180
|
+
/**
|
|
181
|
+
* Store token configuration for automatic reconnection
|
|
182
|
+
*/
|
|
183
|
+
private _storeToken;
|
|
184
|
+
/**
|
|
185
|
+
* Throw an error if the client has been disposed
|
|
186
|
+
*/
|
|
187
|
+
private _throwIfDisposed;
|
|
186
188
|
}
|
|
187
189
|
/**
|
|
188
190
|
* Create a new TelnyxVoipClient instance for normal app usage
|
|
@@ -191,6 +193,4 @@ export declare function createTelnyxVoipClient(options?: TelnyxVoipClientOptions
|
|
|
191
193
|
/**
|
|
192
194
|
* Create a new TelnyxVoipClient instance for background push notification handling
|
|
193
195
|
*/
|
|
194
|
-
export declare function createBackgroundTelnyxVoipClient(
|
|
195
|
-
options?: TelnyxVoipClientOptions
|
|
196
|
-
): TelnyxVoipClient;
|
|
196
|
+
export declare function createBackgroundTelnyxVoipClient(options?: TelnyxVoipClientOptions): TelnyxVoipClient;
|