@tarunzyraclavis/zyra-twilio-wrapper 1.0.0 → 1.0.9

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/dist/index.d.mts CHANGED
@@ -4,6 +4,7 @@ interface Config {
4
4
  serverUrl: string;
5
5
  identity: string;
6
6
  waitUrl?: string;
7
+ sdkToken: string;
7
8
  }
8
9
  interface TwilioConferenceParticipant {
9
10
  accountSid: string;
@@ -44,23 +45,6 @@ interface TwilioConferenceDetails {
44
45
  };
45
46
  uri: string;
46
47
  }
47
- interface CallResult {
48
- message: string;
49
- status: boolean;
50
- }
51
- interface HoldAndAddResult extends CallResult {
52
- holdResponse?: any;
53
- addParticipantResponse?: any;
54
- }
55
- interface GetConferenceResult extends CallResult {
56
- conferenceDetail?: TwilioConference;
57
- }
58
- interface GetParticipantsResult extends CallResult {
59
- participants?: TwilioConferenceParticipant[];
60
- }
61
- interface RemoveParticipantResult extends CallResult {
62
- data?: any;
63
- }
64
48
  type CallResponse<T = void> = {
65
49
  success: true;
66
50
  message: string;
@@ -73,10 +57,13 @@ type CallResponse<T = void> = {
73
57
  declare class ZyraTwilioWrapper {
74
58
  private readonly serverUrl;
75
59
  private readonly identity;
60
+ private readonly sdkToken;
76
61
  private device;
77
62
  private activeConnection;
78
63
  private isInitialized;
79
64
  private isInitializing;
65
+ private isAuthenticated;
66
+ private axiosInstance;
80
67
  activeCallSid: string | null;
81
68
  conferenceName: string;
82
69
  conferenceDetail: TwilioConference | null;
@@ -88,8 +75,10 @@ declare class ZyraTwilioWrapper {
88
75
  onError?: (error: Error) => void;
89
76
  onConnect?: (conn: Call) => void;
90
77
  onMissedCall?: () => void;
91
- onAnswerOutGoing?: (conn: Call) => void;
92
- constructor(configObj: Config);
78
+ constructor(config: Config);
79
+ private setupAxiosAuth;
80
+ private ensureAuthenticated;
81
+ verifySDKToken(): Promise<boolean>;
93
82
  /**
94
83
  * Initialize the SDK. Can only be called once.
95
84
  *
@@ -100,57 +89,49 @@ declare class ZyraTwilioWrapper {
100
89
  private generateToken;
101
90
  private setupDeviceEventHandlers;
102
91
  /**
103
- * Check if SDK is initialized
104
- */
105
- get initialized(): boolean;
106
- /**
107
- * Destroy the SDK instance and clean up resources
108
- */
109
- destroy(): void;
110
- /**
111
- * Make an outgoing call or add participant to an existing call
112
- */
92
+ * Make an outgoing call or add participant to an existing call
93
+ */
113
94
  makeCall(to: string): Promise<CallResponse<Call>>;
114
95
  /**
115
- * Accept incoming call
116
- */
96
+ * Accept incoming call
97
+ */
117
98
  acceptCall(): CallResponse<Call>;
118
99
  /**
119
- * Hang up active call
120
- */
121
- hangup(): CallResponse<Call | null>;
100
+ * Hang up active call
101
+ */
102
+ hangup(): CallResponse<null>;
122
103
  /**
123
- * Reject incoming call
124
- */
125
- rejectCall(): CallResponse<Call | null>;
104
+ * Reject incoming call
105
+ */
106
+ rejectCall(): CallResponse<null>;
126
107
  /**
127
- * Toggle mute/unmute
128
- */
108
+ * Toggle mute/unmute
109
+ */
129
110
  toggleMute(mute: boolean): CallResponse<Call>;
130
111
  /**
131
- * Hold a call
132
- */
133
- hold(callSid: string): Promise<CallResponse<Call>>;
112
+ * Hold a call
113
+ */
114
+ hold(callSid: string): Promise<CallResponse<Call | null>>;
134
115
  /**
135
- * Resume a held call
136
- */
137
- resume(callSid: string): Promise<CallResponse<Call>>;
116
+ * Resume a held call
117
+ */
118
+ resume(callSid: string): Promise<CallResponse<Call | null>>;
138
119
  /**
139
- * Hold active call and add a new participant
140
- */
141
- holdAndAddParticipant(callSid: string, newParticipantNo: string): Promise<HoldAndAddResult | CallResponse>;
120
+ * Hold active call and add a new participant
121
+ */
122
+ holdAndAddParticipant(callSid: string, number: string): Promise<CallResponse<any>>;
142
123
  /**
143
- * Fetch conference details
144
- */
145
- getConferenceId(): Promise<GetConferenceResult | CallResponse<TwilioConference>>;
124
+ * Fetch conference details
125
+ */
126
+ getConferenceId(): Promise<CallResponse<TwilioConference | null>>;
146
127
  /**
147
- * Get participants of a conference
148
- */
149
- getParticipants(conferenceSid: string): Promise<GetParticipantsResult | CallResponse<TwilioConferenceParticipant[]>>;
128
+ * Get participants of a conference
129
+ */
130
+ getParticipants(conferenceSid: string): Promise<CallResponse<TwilioConferenceParticipant[]>>;
150
131
  /**
151
- * Remove a participant from a conference
152
- */
153
- removeParticipant(conferenceSid: string, callSid: string): Promise<RemoveParticipantResult | CallResponse>;
132
+ * Remove a participant from a conference
133
+ */ removeParticipant(conferenceSid: string, callSid: string): Promise<CallResponse<any>>;
134
+ destroy(): void;
154
135
  }
155
136
 
156
137
  export { ZyraTwilioWrapper as default };
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ interface Config {
4
4
  serverUrl: string;
5
5
  identity: string;
6
6
  waitUrl?: string;
7
+ sdkToken: string;
7
8
  }
8
9
  interface TwilioConferenceParticipant {
9
10
  accountSid: string;
@@ -44,23 +45,6 @@ interface TwilioConferenceDetails {
44
45
  };
45
46
  uri: string;
46
47
  }
47
- interface CallResult {
48
- message: string;
49
- status: boolean;
50
- }
51
- interface HoldAndAddResult extends CallResult {
52
- holdResponse?: any;
53
- addParticipantResponse?: any;
54
- }
55
- interface GetConferenceResult extends CallResult {
56
- conferenceDetail?: TwilioConference;
57
- }
58
- interface GetParticipantsResult extends CallResult {
59
- participants?: TwilioConferenceParticipant[];
60
- }
61
- interface RemoveParticipantResult extends CallResult {
62
- data?: any;
63
- }
64
48
  type CallResponse<T = void> = {
65
49
  success: true;
66
50
  message: string;
@@ -73,10 +57,13 @@ type CallResponse<T = void> = {
73
57
  declare class ZyraTwilioWrapper {
74
58
  private readonly serverUrl;
75
59
  private readonly identity;
60
+ private readonly sdkToken;
76
61
  private device;
77
62
  private activeConnection;
78
63
  private isInitialized;
79
64
  private isInitializing;
65
+ private isAuthenticated;
66
+ private axiosInstance;
80
67
  activeCallSid: string | null;
81
68
  conferenceName: string;
82
69
  conferenceDetail: TwilioConference | null;
@@ -88,8 +75,10 @@ declare class ZyraTwilioWrapper {
88
75
  onError?: (error: Error) => void;
89
76
  onConnect?: (conn: Call) => void;
90
77
  onMissedCall?: () => void;
91
- onAnswerOutGoing?: (conn: Call) => void;
92
- constructor(configObj: Config);
78
+ constructor(config: Config);
79
+ private setupAxiosAuth;
80
+ private ensureAuthenticated;
81
+ verifySDKToken(): Promise<boolean>;
93
82
  /**
94
83
  * Initialize the SDK. Can only be called once.
95
84
  *
@@ -100,57 +89,49 @@ declare class ZyraTwilioWrapper {
100
89
  private generateToken;
101
90
  private setupDeviceEventHandlers;
102
91
  /**
103
- * Check if SDK is initialized
104
- */
105
- get initialized(): boolean;
106
- /**
107
- * Destroy the SDK instance and clean up resources
108
- */
109
- destroy(): void;
110
- /**
111
- * Make an outgoing call or add participant to an existing call
112
- */
92
+ * Make an outgoing call or add participant to an existing call
93
+ */
113
94
  makeCall(to: string): Promise<CallResponse<Call>>;
114
95
  /**
115
- * Accept incoming call
116
- */
96
+ * Accept incoming call
97
+ */
117
98
  acceptCall(): CallResponse<Call>;
118
99
  /**
119
- * Hang up active call
120
- */
121
- hangup(): CallResponse<Call | null>;
100
+ * Hang up active call
101
+ */
102
+ hangup(): CallResponse<null>;
122
103
  /**
123
- * Reject incoming call
124
- */
125
- rejectCall(): CallResponse<Call | null>;
104
+ * Reject incoming call
105
+ */
106
+ rejectCall(): CallResponse<null>;
126
107
  /**
127
- * Toggle mute/unmute
128
- */
108
+ * Toggle mute/unmute
109
+ */
129
110
  toggleMute(mute: boolean): CallResponse<Call>;
130
111
  /**
131
- * Hold a call
132
- */
133
- hold(callSid: string): Promise<CallResponse<Call>>;
112
+ * Hold a call
113
+ */
114
+ hold(callSid: string): Promise<CallResponse<Call | null>>;
134
115
  /**
135
- * Resume a held call
136
- */
137
- resume(callSid: string): Promise<CallResponse<Call>>;
116
+ * Resume a held call
117
+ */
118
+ resume(callSid: string): Promise<CallResponse<Call | null>>;
138
119
  /**
139
- * Hold active call and add a new participant
140
- */
141
- holdAndAddParticipant(callSid: string, newParticipantNo: string): Promise<HoldAndAddResult | CallResponse>;
120
+ * Hold active call and add a new participant
121
+ */
122
+ holdAndAddParticipant(callSid: string, number: string): Promise<CallResponse<any>>;
142
123
  /**
143
- * Fetch conference details
144
- */
145
- getConferenceId(): Promise<GetConferenceResult | CallResponse<TwilioConference>>;
124
+ * Fetch conference details
125
+ */
126
+ getConferenceId(): Promise<CallResponse<TwilioConference | null>>;
146
127
  /**
147
- * Get participants of a conference
148
- */
149
- getParticipants(conferenceSid: string): Promise<GetParticipantsResult | CallResponse<TwilioConferenceParticipant[]>>;
128
+ * Get participants of a conference
129
+ */
130
+ getParticipants(conferenceSid: string): Promise<CallResponse<TwilioConferenceParticipant[]>>;
150
131
  /**
151
- * Remove a participant from a conference
152
- */
153
- removeParticipant(conferenceSid: string, callSid: string): Promise<RemoveParticipantResult | CallResponse>;
132
+ * Remove a participant from a conference
133
+ */ removeParticipant(conferenceSid: string, callSid: string): Promise<CallResponse<any>>;
134
+ destroy(): void;
154
135
  }
155
136
 
156
137
  export { ZyraTwilioWrapper as default };