UNPKG

@telnyx/webrtc

Version:
390 lines (389 loc) 30.9 kB
export declare const _SDK_ERRORS: { readonly 40001: { readonly name: "SDP_CREATE_OFFER_FAILED"; readonly message: "Failed to create call offer"; readonly description: "The browser was unable to generate a local SDP offer. This typically indicates a WebRTC API error or invalid media constraints."; readonly causes: readonly ["Browser WebRTC API error", "Missing or invalid media constraints"]; readonly solutions: readonly ["Check getUserMedia permissions", "Verify ICE server configuration"]; readonly fatal: true; }; readonly 40002: { readonly name: "SDP_CREATE_ANSWER_FAILED"; readonly message: "Failed to answer the call"; readonly description: "The browser was unable to generate a local SDP answer. The remote offer may be invalid or the browser state inconsistent."; readonly causes: readonly ["Browser WebRTC API error", "Invalid remote SDP offer"]; readonly solutions: readonly ["Retry the call", "Check browser WebRTC compatibility"]; readonly fatal: true; }; readonly 40003: { readonly name: "SDP_SET_LOCAL_DESCRIPTION_FAILED"; readonly message: "Failed to apply local call settings"; readonly description: "setLocalDescription() was rejected by the browser. The generated SDP may be malformed or the browser state may be inconsistent."; readonly causes: readonly ["Malformed SDP", "Browser state inconsistency"]; readonly solutions: readonly ["Retry the call"]; readonly fatal: true; }; readonly 40004: { readonly name: "SDP_SET_REMOTE_DESCRIPTION_FAILED"; readonly message: "Failed to apply remote call settings"; readonly description: "setRemoteDescription() was rejected by the browser. The remote SDP may be malformed or contain unsupported codecs."; readonly causes: readonly ["Malformed remote SDP", "Browser codec mismatch"]; readonly solutions: readonly ["Retry the call", "Check codec configuration"]; readonly fatal: true; }; readonly 40005: { readonly name: "SDP_SEND_FAILED"; readonly message: "Failed to send call data to server"; readonly description: "The Invite or Answer message could not be delivered via the signaling WebSocket. The connection may have been lost."; readonly causes: readonly ["WebSocket connection lost", "Server error"]; readonly solutions: readonly ["Check network connectivity", "Retry the call"]; readonly fatal: true; }; readonly 42001: { readonly name: "MEDIA_MICROPHONE_PERMISSION_DENIED"; readonly message: "Microphone access denied"; readonly description: "The user or operating system denied microphone permission. The browser permission prompt was dismissed or OS-level access is disabled."; readonly causes: readonly ["User denied browser permission prompt", "OS-level microphone access disabled"]; readonly solutions: readonly ["Ask user to grant microphone permission in browser settings"]; readonly fatal: true; }; readonly 42002: { readonly name: "MEDIA_DEVICE_NOT_FOUND"; readonly message: "No microphone found"; readonly description: "The requested audio input device is not available. No microphone is connected, the device was disconnected, or an invalid deviceId was specified."; readonly causes: readonly ["No microphone connected", "Device was disconnected", "Invalid deviceId"]; readonly solutions: readonly ["Check that a microphone is connected", "Select a valid audio input device"]; readonly fatal: true; }; readonly 42003: { readonly name: "MEDIA_GET_USER_MEDIA_FAILED"; readonly message: "Failed to access microphone"; readonly description: "getUserMedia() was rejected for an unexpected reason. The device may be in use by another application or the browser encountered an internal error."; readonly causes: readonly ["Browser error", "Device in use by another application"]; readonly solutions: readonly ["Close other applications using the microphone", "Retry"]; readonly fatal: true; }; readonly 44001: { readonly name: "HOLD_FAILED"; readonly message: "Failed to hold the call"; readonly description: "The server rejected or did not respond to the hold request. The WebSocket connection may have been lost during the operation."; readonly causes: readonly ["Server error", "WebSocket connection lost during hold"]; readonly solutions: readonly ["Retry the hold operation", "Check network connectivity"]; readonly fatal: false; }; readonly 44002: { readonly name: "INVALID_CALL_PARAMETERS"; readonly message: "Invalid call parameters"; readonly description: "The call could not be initiated because required parameters are missing or invalid. For example, no destination number was provided to newCall()."; readonly causes: readonly ["Missing destinationNumber in call options", "Invalid or empty call parameters"]; readonly solutions: readonly ["Provide a valid destinationNumber when calling newCall()", "Check the call options object for required fields"]; readonly fatal: true; }; readonly 44003: { readonly name: "BYE_SEND_FAILED"; readonly message: "Failed to hang up cleanly"; readonly description: "The hangup signal could not be delivered to the server. The call was terminated locally but the server may not be aware."; readonly causes: readonly ["WebSocket connection lost before BYE sent"]; readonly solutions: readonly ["No action needed — call is terminated locally", "Check network connectivity"]; readonly fatal: false; }; readonly 44004: { readonly name: "SUBSCRIBE_FAILED"; readonly message: "Failed to subscribe to call events"; readonly description: "The Verto subscribe request for the call channel failed. This may prevent receiving call state updates from the server."; readonly causes: readonly ["WebSocket connection lost during subscribe", "Server rejected the subscription request"]; readonly solutions: readonly ["Check network connectivity", "Retry the call"]; readonly fatal: false; }; readonly 44005: { readonly name: "PEER_CLOSED_DURING_INIT"; readonly message: "Call was closed during setup"; readonly description: "The PeerConnection was closed (e.g. by hangup()) while peer.init() was still running. This is a race condition: an async operation such as setRemoteDescription, getUserMedia, or the media recovery flow yielded control, and close() ran during that gap. The init() cannot continue because the underlying RTCPeerConnection has been destroyed."; readonly causes: readonly ["call.hangup() or call.close() was called while the call was still setting up", "A WebSocket Bye message arrived during getUserMedia prompt or SDP negotiation", "User clicked hangup/decline before media permissions were granted"]; readonly solutions: readonly ["This is expected if the user intentionally hung up during setup — no action needed", "If this happens frequently without user action, check for automatic hangup triggers that may fire too early"]; readonly fatal: true; }; readonly 45001: { readonly name: "WEBSOCKET_CONNECTION_FAILED"; readonly message: "Unable to connect to server"; readonly description: "The WebSocket connection to the signaling server could not be established. The server may be unreachable, the URL may be incorrect, or a firewall may be blocking the connection."; readonly causes: readonly ["Server unreachable", "Incorrect WebSocket URL", "Firewall blocking WebSocket connections", "Network interruption"]; readonly solutions: readonly ["Check network connectivity", "Verify the signaling server URL", "Ensure WebSocket connections are not blocked by a firewall"]; readonly fatal: true; }; readonly 45002: { readonly name: "WEBSOCKET_ERROR"; readonly message: "Connection to server lost"; readonly description: "An error occurred on the WebSocket connection after it was established. The connection may have been dropped due to network issues or server-side closure."; readonly causes: readonly ["Network interruption", "Server closed the connection", "Idle timeout"]; readonly solutions: readonly ["Check network connectivity", "SDK will attempt automatic reconnection if configured"]; readonly fatal: false; }; readonly 45003: { readonly name: "RECONNECTION_EXHAUSTED"; readonly message: "Unable to reconnect to server"; readonly description: "All automatic reconnection attempts have been exhausted. The SDK tried to re-establish the WebSocket connection multiple times but failed on every attempt."; readonly causes: readonly ["Prolonged network outage", "Server unreachable", "Firewall or proxy blocking reconnection"]; readonly solutions: readonly ["Check network connectivity", "Call client.disconnect() and client.connect() to manually retry", "Notify the user that the connection was lost"]; readonly fatal: true; }; readonly 45004: { readonly name: "GATEWAY_FAILED"; readonly message: "Gateway connection failed"; readonly description: "The upstream gateway reported a FAILED, FAIL_WAIT, or TIMEOUT state. The signaling server could not establish or maintain a connection to the gateway. When autoReconnect is disabled, this is immediately fatal. When enabled, the SDK will retry until RECONNECTION_EXHAUSTED."; readonly causes: readonly ["Gateway down or unreachable", "Server-side infrastructure issue", "Network partition between signaling server and gateway"]; readonly solutions: readonly ["Wait for automatic reconnection (if autoReconnect is enabled)", "Call client.disconnect() and client.connect() to manually retry", "Check Telnyx service status"]; readonly fatal: false; }; readonly 46001: { readonly name: "LOGIN_FAILED"; readonly message: "Authentication failed"; readonly description: "The login request was rejected by the server. The credentials may be invalid, expired, or the account may be suspended."; readonly causes: readonly ["Invalid credentials (username/password or token)", "Expired authentication token", "Account suspended or disabled"]; readonly solutions: readonly ["Verify credentials", "Generate a new authentication token", "Check account status"]; readonly fatal: true; }; readonly 46002: { readonly name: "INVALID_CREDENTIALS"; readonly message: "Invalid credential parameters"; readonly description: "The SDK rejected the login options before sending any request to the server. This is an internal client-side validation guard — the credentials object is missing required fields or has an invalid structure. No network request was made."; readonly causes: readonly ["Missing login and password fields", "Missing or malformed authentication token", "Invalid combination of credential fields in the options object"]; readonly solutions: readonly ["Provide valid login/password or a valid authentication token", "Check the TelnyxRTC constructor options against the documentation", "Ensure the credential object matches one of the supported auth modes (credentials, token, or anonymous)"]; readonly fatal: true; }; readonly 46003: { readonly name: "AUTHENTICATION_REQUIRED"; readonly message: "Authentication required"; readonly description: "The server rejected a request because the session is not authenticated. This can happen when the client sends a message (e.g. Invite, Subscribe, or Ping) before login completes, after a token expires mid-session, or after the server drops the authenticated state for any reason."; readonly causes: readonly ["Message sent before login completed", "Authentication token expired during the session", "Server-side session was invalidated", "WebSocket reconnected but re-authentication did not complete"]; readonly solutions: readonly ["Ensure the client is fully logged in before sending messages", "Re-authenticate using client.login() with fresh credentials", "Listen for telnyx.ready before making calls or sending requests"]; readonly fatal: false; }; readonly 47001: { readonly name: "ICE_RESTART_FAILED"; readonly message: "ICE restart failed"; readonly description: "The ICE restart Modify request could not be sent or the server returned an error. The media path could not be recovered via ICE restart."; readonly causes: readonly ["WebSocket connection lost during ICE restart", "Server rejected the Modify request", "Timeout waiting for server response"]; readonly solutions: readonly ["The call may recover via WebSocket reconnect + Attach", "If the call does not recover, hang up and retry"]; readonly fatal: false; }; readonly 48001: { readonly name: "NETWORK_OFFLINE"; readonly message: "Device is offline"; readonly description: "The browser reported that the device has lost network connectivity (navigator.onLine === false). All WebSocket and media connections will fail until the network is restored."; readonly causes: readonly ["Wi-Fi or ethernet disconnected", "Airplane mode enabled", "Network interface went down"]; readonly solutions: readonly ["Check network connectivity", "Reconnect to Wi-Fi or ethernet", "Disable airplane mode"]; readonly fatal: false; }; readonly 48501: { readonly name: "SESSION_NOT_REATTACHED"; readonly message: "Active call lost after reconnect"; readonly description: "The WebSocket reconnected successfully but the server did not reattach the active call session. The server no longer knows about the call, so any subsequent call-control operation (hangup, hold, etc.) will fail with CALL_DOES_NOT_EXIST. The call is unrecoverable and must be terminated locally."; readonly causes: readonly ["Server-side session expired during the disconnection window", "Reconnect token was invalidated", "Backend restarted or lost in-memory call state"]; readonly solutions: readonly ["Terminate the local call and notify the user", "Start a new call", "Investigate why the session was not preserved on the server"]; readonly fatal: true; }; readonly 49001: { readonly name: "UNEXPECTED_ERROR"; readonly message: "An unexpected error occurred"; readonly description: "An error was thrown that does not match any known SDK error category. This is a catch-all for unclassified failures."; readonly causes: readonly ["Unknown or unhandled error condition"]; readonly solutions: readonly ["Check the originalError property for the underlying cause", "Report the issue if it persists"]; readonly fatal: true; }; }; export declare const SDK_ERRORS: { readonly 40001: { readonly name: "SDP_CREATE_OFFER_FAILED"; readonly message: "Failed to create call offer"; readonly description: "The browser was unable to generate a local SDP offer. This typically indicates a WebRTC API error or invalid media constraints."; readonly causes: readonly ["Browser WebRTC API error", "Missing or invalid media constraints"]; readonly solutions: readonly ["Check getUserMedia permissions", "Verify ICE server configuration"]; readonly fatal: true; }; readonly 40002: { readonly name: "SDP_CREATE_ANSWER_FAILED"; readonly message: "Failed to answer the call"; readonly description: "The browser was unable to generate a local SDP answer. The remote offer may be invalid or the browser state inconsistent."; readonly causes: readonly ["Browser WebRTC API error", "Invalid remote SDP offer"]; readonly solutions: readonly ["Retry the call", "Check browser WebRTC compatibility"]; readonly fatal: true; }; readonly 40003: { readonly name: "SDP_SET_LOCAL_DESCRIPTION_FAILED"; readonly message: "Failed to apply local call settings"; readonly description: "setLocalDescription() was rejected by the browser. The generated SDP may be malformed or the browser state may be inconsistent."; readonly causes: readonly ["Malformed SDP", "Browser state inconsistency"]; readonly solutions: readonly ["Retry the call"]; readonly fatal: true; }; readonly 40004: { readonly name: "SDP_SET_REMOTE_DESCRIPTION_FAILED"; readonly message: "Failed to apply remote call settings"; readonly description: "setRemoteDescription() was rejected by the browser. The remote SDP may be malformed or contain unsupported codecs."; readonly causes: readonly ["Malformed remote SDP", "Browser codec mismatch"]; readonly solutions: readonly ["Retry the call", "Check codec configuration"]; readonly fatal: true; }; readonly 40005: { readonly name: "SDP_SEND_FAILED"; readonly message: "Failed to send call data to server"; readonly description: "The Invite or Answer message could not be delivered via the signaling WebSocket. The connection may have been lost."; readonly causes: readonly ["WebSocket connection lost", "Server error"]; readonly solutions: readonly ["Check network connectivity", "Retry the call"]; readonly fatal: true; }; readonly 42001: { readonly name: "MEDIA_MICROPHONE_PERMISSION_DENIED"; readonly message: "Microphone access denied"; readonly description: "The user or operating system denied microphone permission. The browser permission prompt was dismissed or OS-level access is disabled."; readonly causes: readonly ["User denied browser permission prompt", "OS-level microphone access disabled"]; readonly solutions: readonly ["Ask user to grant microphone permission in browser settings"]; readonly fatal: true; }; readonly 42002: { readonly name: "MEDIA_DEVICE_NOT_FOUND"; readonly message: "No microphone found"; readonly description: "The requested audio input device is not available. No microphone is connected, the device was disconnected, or an invalid deviceId was specified."; readonly causes: readonly ["No microphone connected", "Device was disconnected", "Invalid deviceId"]; readonly solutions: readonly ["Check that a microphone is connected", "Select a valid audio input device"]; readonly fatal: true; }; readonly 42003: { readonly name: "MEDIA_GET_USER_MEDIA_FAILED"; readonly message: "Failed to access microphone"; readonly description: "getUserMedia() was rejected for an unexpected reason. The device may be in use by another application or the browser encountered an internal error."; readonly causes: readonly ["Browser error", "Device in use by another application"]; readonly solutions: readonly ["Close other applications using the microphone", "Retry"]; readonly fatal: true; }; readonly 44001: { readonly name: "HOLD_FAILED"; readonly message: "Failed to hold the call"; readonly description: "The server rejected or did not respond to the hold request. The WebSocket connection may have been lost during the operation."; readonly causes: readonly ["Server error", "WebSocket connection lost during hold"]; readonly solutions: readonly ["Retry the hold operation", "Check network connectivity"]; readonly fatal: false; }; readonly 44002: { readonly name: "INVALID_CALL_PARAMETERS"; readonly message: "Invalid call parameters"; readonly description: "The call could not be initiated because required parameters are missing or invalid. For example, no destination number was provided to newCall()."; readonly causes: readonly ["Missing destinationNumber in call options", "Invalid or empty call parameters"]; readonly solutions: readonly ["Provide a valid destinationNumber when calling newCall()", "Check the call options object for required fields"]; readonly fatal: true; }; readonly 44003: { readonly name: "BYE_SEND_FAILED"; readonly message: "Failed to hang up cleanly"; readonly description: "The hangup signal could not be delivered to the server. The call was terminated locally but the server may not be aware."; readonly causes: readonly ["WebSocket connection lost before BYE sent"]; readonly solutions: readonly ["No action needed — call is terminated locally", "Check network connectivity"]; readonly fatal: false; }; readonly 44004: { readonly name: "SUBSCRIBE_FAILED"; readonly message: "Failed to subscribe to call events"; readonly description: "The Verto subscribe request for the call channel failed. This may prevent receiving call state updates from the server."; readonly causes: readonly ["WebSocket connection lost during subscribe", "Server rejected the subscription request"]; readonly solutions: readonly ["Check network connectivity", "Retry the call"]; readonly fatal: false; }; readonly 44005: { readonly name: "PEER_CLOSED_DURING_INIT"; readonly message: "Call was closed during setup"; readonly description: "The PeerConnection was closed (e.g. by hangup()) while peer.init() was still running. This is a race condition: an async operation such as setRemoteDescription, getUserMedia, or the media recovery flow yielded control, and close() ran during that gap. The init() cannot continue because the underlying RTCPeerConnection has been destroyed."; readonly causes: readonly ["call.hangup() or call.close() was called while the call was still setting up", "A WebSocket Bye message arrived during getUserMedia prompt or SDP negotiation", "User clicked hangup/decline before media permissions were granted"]; readonly solutions: readonly ["This is expected if the user intentionally hung up during setup — no action needed", "If this happens frequently without user action, check for automatic hangup triggers that may fire too early"]; readonly fatal: true; }; readonly 45001: { readonly name: "WEBSOCKET_CONNECTION_FAILED"; readonly message: "Unable to connect to server"; readonly description: "The WebSocket connection to the signaling server could not be established. The server may be unreachable, the URL may be incorrect, or a firewall may be blocking the connection."; readonly causes: readonly ["Server unreachable", "Incorrect WebSocket URL", "Firewall blocking WebSocket connections", "Network interruption"]; readonly solutions: readonly ["Check network connectivity", "Verify the signaling server URL", "Ensure WebSocket connections are not blocked by a firewall"]; readonly fatal: true; }; readonly 45002: { readonly name: "WEBSOCKET_ERROR"; readonly message: "Connection to server lost"; readonly description: "An error occurred on the WebSocket connection after it was established. The connection may have been dropped due to network issues or server-side closure."; readonly causes: readonly ["Network interruption", "Server closed the connection", "Idle timeout"]; readonly solutions: readonly ["Check network connectivity", "SDK will attempt automatic reconnection if configured"]; readonly fatal: false; }; readonly 45003: { readonly name: "RECONNECTION_EXHAUSTED"; readonly message: "Unable to reconnect to server"; readonly description: "All automatic reconnection attempts have been exhausted. The SDK tried to re-establish the WebSocket connection multiple times but failed on every attempt."; readonly causes: readonly ["Prolonged network outage", "Server unreachable", "Firewall or proxy blocking reconnection"]; readonly solutions: readonly ["Check network connectivity", "Call client.disconnect() and client.connect() to manually retry", "Notify the user that the connection was lost"]; readonly fatal: true; }; readonly 45004: { readonly name: "GATEWAY_FAILED"; readonly message: "Gateway connection failed"; readonly description: "The upstream gateway reported a FAILED, FAIL_WAIT, or TIMEOUT state. The signaling server could not establish or maintain a connection to the gateway. When autoReconnect is disabled, this is immediately fatal. When enabled, the SDK will retry until RECONNECTION_EXHAUSTED."; readonly causes: readonly ["Gateway down or unreachable", "Server-side infrastructure issue", "Network partition between signaling server and gateway"]; readonly solutions: readonly ["Wait for automatic reconnection (if autoReconnect is enabled)", "Call client.disconnect() and client.connect() to manually retry", "Check Telnyx service status"]; readonly fatal: false; }; readonly 46001: { readonly name: "LOGIN_FAILED"; readonly message: "Authentication failed"; readonly description: "The login request was rejected by the server. The credentials may be invalid, expired, or the account may be suspended."; readonly causes: readonly ["Invalid credentials (username/password or token)", "Expired authentication token", "Account suspended or disabled"]; readonly solutions: readonly ["Verify credentials", "Generate a new authentication token", "Check account status"]; readonly fatal: true; }; readonly 46002: { readonly name: "INVALID_CREDENTIALS"; readonly message: "Invalid credential parameters"; readonly description: "The SDK rejected the login options before sending any request to the server. This is an internal client-side validation guard — the credentials object is missing required fields or has an invalid structure. No network request was made."; readonly causes: readonly ["Missing login and password fields", "Missing or malformed authentication token", "Invalid combination of credential fields in the options object"]; readonly solutions: readonly ["Provide valid login/password or a valid authentication token", "Check the TelnyxRTC constructor options against the documentation", "Ensure the credential object matches one of the supported auth modes (credentials, token, or anonymous)"]; readonly fatal: true; }; readonly 46003: { readonly name: "AUTHENTICATION_REQUIRED"; readonly message: "Authentication required"; readonly description: "The server rejected a request because the session is not authenticated. This can happen when the client sends a message (e.g. Invite, Subscribe, or Ping) before login completes, after a token expires mid-session, or after the server drops the authenticated state for any reason."; readonly causes: readonly ["Message sent before login completed", "Authentication token expired during the session", "Server-side session was invalidated", "WebSocket reconnected but re-authentication did not complete"]; readonly solutions: readonly ["Ensure the client is fully logged in before sending messages", "Re-authenticate using client.login() with fresh credentials", "Listen for telnyx.ready before making calls or sending requests"]; readonly fatal: false; }; readonly 47001: { readonly name: "ICE_RESTART_FAILED"; readonly message: "ICE restart failed"; readonly description: "The ICE restart Modify request could not be sent or the server returned an error. The media path could not be recovered via ICE restart."; readonly causes: readonly ["WebSocket connection lost during ICE restart", "Server rejected the Modify request", "Timeout waiting for server response"]; readonly solutions: readonly ["The call may recover via WebSocket reconnect + Attach", "If the call does not recover, hang up and retry"]; readonly fatal: false; }; readonly 48001: { readonly name: "NETWORK_OFFLINE"; readonly message: "Device is offline"; readonly description: "The browser reported that the device has lost network connectivity (navigator.onLine === false). All WebSocket and media connections will fail until the network is restored."; readonly causes: readonly ["Wi-Fi or ethernet disconnected", "Airplane mode enabled", "Network interface went down"]; readonly solutions: readonly ["Check network connectivity", "Reconnect to Wi-Fi or ethernet", "Disable airplane mode"]; readonly fatal: false; }; readonly 48501: { readonly name: "SESSION_NOT_REATTACHED"; readonly message: "Active call lost after reconnect"; readonly description: "The WebSocket reconnected successfully but the server did not reattach the active call session. The server no longer knows about the call, so any subsequent call-control operation (hangup, hold, etc.) will fail with CALL_DOES_NOT_EXIST. The call is unrecoverable and must be terminated locally."; readonly causes: readonly ["Server-side session expired during the disconnection window", "Reconnect token was invalidated", "Backend restarted or lost in-memory call state"]; readonly solutions: readonly ["Terminate the local call and notify the user", "Start a new call", "Investigate why the session was not preserved on the server"]; readonly fatal: true; }; readonly 49001: { readonly name: "UNEXPECTED_ERROR"; readonly message: "An unexpected error occurred"; readonly description: "An error was thrown that does not match any known SDK error category. This is a catch-all for unclassified failures."; readonly causes: readonly ["Unknown or unhandled error condition"]; readonly solutions: readonly ["Check the originalError property for the underlying cause", "Report the issue if it persists"]; readonly fatal: true; }; }; export declare type SdkErrorCode = keyof typeof SDK_ERRORS;