call-control-sdk 6.4.1-dev.0 → 6.4.2

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/README.md CHANGED
@@ -298,6 +298,20 @@ export default function LogoutButton() {
298
298
  }
299
299
  ```
300
300
 
301
+ ### 🔐 Authorization Token
302
+
303
+ get Authorization token for external API call
304
+
305
+ ```tsx
306
+ import { getAuthorizationToken } from "call-control-sdk";
307
+
308
+ export default function axios() {
309
+ const token = getAuthorizationToken();
310
+
311
+ console.log(token);
312
+ }
313
+ ```
314
+
301
315
  ---
302
316
 
303
317
  ## 🔧 Configuration Options
package/dist/index.d.mts CHANGED
@@ -979,6 +979,148 @@ interface UseLogoutReturn extends LogoutHookStateTypes {
979
979
  */
980
980
  declare const useLogout: () => UseLogoutReturn;
981
981
 
982
+ /**
983
+ * 🔐 Authorization Token Custom Hook
984
+ *
985
+ * @function useGetAuthorizationToken
986
+ * @description 🎯 Custom hook that provides reactive access to the current SDK authorization token.
987
+ * Automatically updates when the token changes, making it perfect for external API calls
988
+ * and authentication headers.
989
+ *
990
+ * @returns {string | undefined} Current authorization token or undefined if not available
991
+ *
992
+ * @example
993
+ * ```typescript
994
+ * // Basic usage in a component
995
+ * const ApiCallComponent = () => {
996
+ * const token = useGetAuthorizationToken();
997
+ *
998
+ * const makeExternalApiCall = async () => {
999
+ * if (!token) {
1000
+ * console.error('No authorization token available');
1001
+ * return;
1002
+ * }
1003
+ *
1004
+ * try {
1005
+ * const response = await fetch('/api/external', {
1006
+ * headers: {
1007
+ * 'Authorization': `Bearer ${token}`,
1008
+ * 'Content-Type': 'application/json'
1009
+ * }
1010
+ * });
1011
+ * const data = await response.json();
1012
+ * console.log('External API response:', data);
1013
+ * } catch (error) {
1014
+ * console.error('API call failed:', error);
1015
+ * }
1016
+ * };
1017
+ *
1018
+ * return (
1019
+ * <button onClick={makeExternalApiCall} disabled={!token}>
1020
+ * {token ? 'Make API Call' : 'No Token Available'}
1021
+ * </button>
1022
+ * );
1023
+ * };
1024
+ * ```
1025
+ *
1026
+ * @example
1027
+ * ```typescript
1028
+ * // Usage with axios
1029
+ * const ApiService = () => {
1030
+ * const token = useGetAuthorizationToken();
1031
+ *
1032
+ * useEffect(() => {
1033
+ * if (token) {
1034
+ * // Configure axios with the token
1035
+ * axios.defaults.headers.common['Authorization'] = `Bearer ${token}`;
1036
+ * }
1037
+ * }, [token]);
1038
+ *
1039
+ * return null; // This is just for token management
1040
+ * };
1041
+ * ```
1042
+ *
1043
+ *
1044
+ * @since 1.0.0
1045
+ * @author CTI SDK Team
1046
+ */
1047
+ declare const useGetAuthorizationToken: () => string | undefined;
1048
+
1049
+ /**
1050
+ * 📞 Caller Data Custom Hook
1051
+ *
1052
+ * @function useGetCallerData
1053
+ * @description 🎯 Custom hook that provides reactive access to current call data.
1054
+ * This is an independent alternative to the CallControlPanel's onDataChange prop,
1055
+ * allowing you to access call information anywhere in your application without
1056
+ * depending on the CallControlPanel component.
1057
+ *
1058
+ * @returns {CallData} Current call data object containing all available call information
1059
+ *
1060
+ * @example
1061
+ * ```typescript
1062
+ * // Basic usage in a component
1063
+ * const CallStatusWidget = () => {
1064
+ * const callerData = useGetCallerData();
1065
+ *
1066
+ * return (
1067
+ * <div className="call-status-widget">
1068
+ * <h3>Current Call Status</h3>
1069
+ * {callerData.status === "ONCALL" ? (
1070
+ * <div>
1071
+ * <p>📞 Active Call: {callerData.phone_number}</p>
1072
+ * <p>Agent: {callerData.agent_id}</p>
1073
+ * <p>Process: {callerData.process_name}</p>
1074
+ * <p>Call ID: {callerData.callReferenceId}</p>
1075
+ * </div>
1076
+ * ) : (
1077
+ * <p>No active call</p>
1078
+ * )}
1079
+ * </div>
1080
+ * );
1081
+ * };
1082
+ * ```
1083
+ *
1084
+ * @example
1085
+ * ```typescript
1086
+ * // Usage for call analytics
1087
+ * const CallAnalytics = () => {
1088
+ * const callerData = useGetCallerData();
1089
+ *
1090
+ * useEffect(() => {
1091
+ * if (callerData.status === "ONCALL") {
1092
+ * // Track call start
1093
+ * analytics.track('call_started', {
1094
+ * phone_number: callerData.phone_number,
1095
+ * agent_id: callerData.agent_id,
1096
+ * process_name: callerData.process_name
1097
+ * });
1098
+ * }
1099
+ * }, [callerData.status]);
1100
+ *
1101
+ * return null; // This is just for analytics
1102
+ * };
1103
+ * ```
1104
+ *
1105
+ *
1106
+ *
1107
+ * @returns_data_structure
1108
+ * ```typescript
1109
+ * {
1110
+ * phone_number: string, // Phone number involved in the call
1111
+ * status: string, // Current call status (ONCALL, RINGING, WRAPUP, etc.)
1112
+ * callReferenceId: string, // Unique identifier for the call
1113
+ * agent_id: string, // ID of the agent handling the call
1114
+ * process_id: string, // Process identifier for the call
1115
+ * process_name: string // Name of the process handling the call
1116
+ * }
1117
+ * ```
1118
+ *
1119
+ * @since 1.0.0
1120
+ * @author CTI SDK Team
1121
+ */
1122
+ declare const useGetCallerData: () => CallData;
1123
+
982
1124
  /**
983
1125
  * 🗃️ SDK State Interface
984
1126
  *
@@ -1635,4 +1777,4 @@ interface ErrorResponse {
1635
1777
  details?: any;
1636
1778
  }
1637
1779
 
1638
- export { type APIResponse, type AgentStatus, CallControlPanel, type CallControlPanelProps, type CallData, type CallInitiationFunction, type CallTerminationFunction, type CleanupOperation, type ConferenceLine, type DispositionType, type EndCallData, type EndCallPayLoadData, type EndCallPayload, type ErrorResponse, type FollowUpType, type HookStateTypes, type InitSDKParams, type LogoutFunction, type LogoutHookStateTypes, type LogoutPayload, type ProcessData, type SDKConfig, type SDKState, type StartCallPayload, type StartCalltData, type StartCalltHookStateTypes, type StorageType, type UseClickToCallReturn, type UseEndCallReturn, type UseLogoutReturn, getSDKVersion, initSDK, isSDKInitialized, useClickToCall, useEndCall, useLogout };
1780
+ export { type APIResponse, type AgentStatus, CallControlPanel, type CallControlPanelProps, type CallData, type CallInitiationFunction, type CallTerminationFunction, type CleanupOperation, type ConferenceLine, type DispositionType, type EndCallData, type EndCallPayLoadData, type EndCallPayload, type ErrorResponse, type FollowUpType, type HookStateTypes, type InitSDKParams, type LogoutFunction, type LogoutHookStateTypes, type LogoutPayload, type ProcessData, type SDKConfig, type SDKState, type StartCallPayload, type StartCalltData, type StartCalltHookStateTypes, type StorageType, type UseClickToCallReturn, type UseEndCallReturn, type UseLogoutReturn, getSDKVersion, initSDK, isSDKInitialized, useClickToCall, useEndCall, useGetAuthorizationToken, useGetCallerData, useLogout };
package/dist/index.d.ts CHANGED
@@ -979,6 +979,148 @@ interface UseLogoutReturn extends LogoutHookStateTypes {
979
979
  */
980
980
  declare const useLogout: () => UseLogoutReturn;
981
981
 
982
+ /**
983
+ * 🔐 Authorization Token Custom Hook
984
+ *
985
+ * @function useGetAuthorizationToken
986
+ * @description 🎯 Custom hook that provides reactive access to the current SDK authorization token.
987
+ * Automatically updates when the token changes, making it perfect for external API calls
988
+ * and authentication headers.
989
+ *
990
+ * @returns {string | undefined} Current authorization token or undefined if not available
991
+ *
992
+ * @example
993
+ * ```typescript
994
+ * // Basic usage in a component
995
+ * const ApiCallComponent = () => {
996
+ * const token = useGetAuthorizationToken();
997
+ *
998
+ * const makeExternalApiCall = async () => {
999
+ * if (!token) {
1000
+ * console.error('No authorization token available');
1001
+ * return;
1002
+ * }
1003
+ *
1004
+ * try {
1005
+ * const response = await fetch('/api/external', {
1006
+ * headers: {
1007
+ * 'Authorization': `Bearer ${token}`,
1008
+ * 'Content-Type': 'application/json'
1009
+ * }
1010
+ * });
1011
+ * const data = await response.json();
1012
+ * console.log('External API response:', data);
1013
+ * } catch (error) {
1014
+ * console.error('API call failed:', error);
1015
+ * }
1016
+ * };
1017
+ *
1018
+ * return (
1019
+ * <button onClick={makeExternalApiCall} disabled={!token}>
1020
+ * {token ? 'Make API Call' : 'No Token Available'}
1021
+ * </button>
1022
+ * );
1023
+ * };
1024
+ * ```
1025
+ *
1026
+ * @example
1027
+ * ```typescript
1028
+ * // Usage with axios
1029
+ * const ApiService = () => {
1030
+ * const token = useGetAuthorizationToken();
1031
+ *
1032
+ * useEffect(() => {
1033
+ * if (token) {
1034
+ * // Configure axios with the token
1035
+ * axios.defaults.headers.common['Authorization'] = `Bearer ${token}`;
1036
+ * }
1037
+ * }, [token]);
1038
+ *
1039
+ * return null; // This is just for token management
1040
+ * };
1041
+ * ```
1042
+ *
1043
+ *
1044
+ * @since 1.0.0
1045
+ * @author CTI SDK Team
1046
+ */
1047
+ declare const useGetAuthorizationToken: () => string | undefined;
1048
+
1049
+ /**
1050
+ * 📞 Caller Data Custom Hook
1051
+ *
1052
+ * @function useGetCallerData
1053
+ * @description 🎯 Custom hook that provides reactive access to current call data.
1054
+ * This is an independent alternative to the CallControlPanel's onDataChange prop,
1055
+ * allowing you to access call information anywhere in your application without
1056
+ * depending on the CallControlPanel component.
1057
+ *
1058
+ * @returns {CallData} Current call data object containing all available call information
1059
+ *
1060
+ * @example
1061
+ * ```typescript
1062
+ * // Basic usage in a component
1063
+ * const CallStatusWidget = () => {
1064
+ * const callerData = useGetCallerData();
1065
+ *
1066
+ * return (
1067
+ * <div className="call-status-widget">
1068
+ * <h3>Current Call Status</h3>
1069
+ * {callerData.status === "ONCALL" ? (
1070
+ * <div>
1071
+ * <p>📞 Active Call: {callerData.phone_number}</p>
1072
+ * <p>Agent: {callerData.agent_id}</p>
1073
+ * <p>Process: {callerData.process_name}</p>
1074
+ * <p>Call ID: {callerData.callReferenceId}</p>
1075
+ * </div>
1076
+ * ) : (
1077
+ * <p>No active call</p>
1078
+ * )}
1079
+ * </div>
1080
+ * );
1081
+ * };
1082
+ * ```
1083
+ *
1084
+ * @example
1085
+ * ```typescript
1086
+ * // Usage for call analytics
1087
+ * const CallAnalytics = () => {
1088
+ * const callerData = useGetCallerData();
1089
+ *
1090
+ * useEffect(() => {
1091
+ * if (callerData.status === "ONCALL") {
1092
+ * // Track call start
1093
+ * analytics.track('call_started', {
1094
+ * phone_number: callerData.phone_number,
1095
+ * agent_id: callerData.agent_id,
1096
+ * process_name: callerData.process_name
1097
+ * });
1098
+ * }
1099
+ * }, [callerData.status]);
1100
+ *
1101
+ * return null; // This is just for analytics
1102
+ * };
1103
+ * ```
1104
+ *
1105
+ *
1106
+ *
1107
+ * @returns_data_structure
1108
+ * ```typescript
1109
+ * {
1110
+ * phone_number: string, // Phone number involved in the call
1111
+ * status: string, // Current call status (ONCALL, RINGING, WRAPUP, etc.)
1112
+ * callReferenceId: string, // Unique identifier for the call
1113
+ * agent_id: string, // ID of the agent handling the call
1114
+ * process_id: string, // Process identifier for the call
1115
+ * process_name: string // Name of the process handling the call
1116
+ * }
1117
+ * ```
1118
+ *
1119
+ * @since 1.0.0
1120
+ * @author CTI SDK Team
1121
+ */
1122
+ declare const useGetCallerData: () => CallData;
1123
+
982
1124
  /**
983
1125
  * 🗃️ SDK State Interface
984
1126
  *
@@ -1635,4 +1777,4 @@ interface ErrorResponse {
1635
1777
  details?: any;
1636
1778
  }
1637
1779
 
1638
- export { type APIResponse, type AgentStatus, CallControlPanel, type CallControlPanelProps, type CallData, type CallInitiationFunction, type CallTerminationFunction, type CleanupOperation, type ConferenceLine, type DispositionType, type EndCallData, type EndCallPayLoadData, type EndCallPayload, type ErrorResponse, type FollowUpType, type HookStateTypes, type InitSDKParams, type LogoutFunction, type LogoutHookStateTypes, type LogoutPayload, type ProcessData, type SDKConfig, type SDKState, type StartCallPayload, type StartCalltData, type StartCalltHookStateTypes, type StorageType, type UseClickToCallReturn, type UseEndCallReturn, type UseLogoutReturn, getSDKVersion, initSDK, isSDKInitialized, useClickToCall, useEndCall, useLogout };
1780
+ export { type APIResponse, type AgentStatus, CallControlPanel, type CallControlPanelProps, type CallData, type CallInitiationFunction, type CallTerminationFunction, type CleanupOperation, type ConferenceLine, type DispositionType, type EndCallData, type EndCallPayLoadData, type EndCallPayload, type ErrorResponse, type FollowUpType, type HookStateTypes, type InitSDKParams, type LogoutFunction, type LogoutHookStateTypes, type LogoutPayload, type ProcessData, type SDKConfig, type SDKState, type StartCallPayload, type StartCalltData, type StartCalltHookStateTypes, type StorageType, type UseClickToCallReturn, type UseEndCallReturn, type UseLogoutReturn, getSDKVersion, initSDK, isSDKInitialized, useClickToCall, useEndCall, useGetAuthorizationToken, useGetCallerData, useLogout };