whio-api-sdk 1.1.12 → 1.1.14

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.
@@ -30,10 +30,6 @@ export declare class WebSocketModule extends BaseClient {
30
30
  * Get connection statistics
31
31
  */
32
32
  getConnectionStats(): WebSocketConnectionStats;
33
- /**
34
- * Ensure WebSocket connection has a valid token
35
- * Reconnects with fresh token if current token is expired
36
- */
37
33
  private ensureValidConnection;
38
34
  /**
39
35
  * Stream audio chunk to server
@@ -46,8 +46,7 @@ export class WebSocketModule extends BaseClient {
46
46
  const wsUrl = this.getWebSocketUrl();
47
47
  try {
48
48
  // Ensure we have a fresh token before connecting
49
- yield this.getToken();
50
- const token = this.getAccessToken();
49
+ const token = yield this.getValidToken();
51
50
  if (!token) {
52
51
  this.emit('connection-error', new Error('No access token available for WebSocket connection'));
53
52
  throw new Error('No access token available for WebSocket connection');
@@ -122,35 +121,13 @@ export class WebSocketModule extends BaseClient {
122
121
  getConnectionStats() {
123
122
  return Object.assign({}, this.connectionStats);
124
123
  }
125
- /**
126
- * Ensure WebSocket connection has a valid token
127
- * Reconnects with fresh token if current token is expired
128
- */
129
124
  ensureValidConnection() {
130
- var _a, _b;
125
+ var _a;
131
126
  return __awaiter(this, void 0, void 0, function* () {
132
127
  if ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.connected) {
133
128
  return;
134
129
  }
135
- const currentToken = yield this.getValidToken();
136
- // Check if we have a token and if it's expired
137
- if (!currentToken || this.isTokenExpired(currentToken)) {
138
- try {
139
- // Refresh token
140
- yield this.getToken();
141
- // Disconnect current connection and reconnect with fresh token
142
- this.disconnect();
143
- yield this.connect();
144
- }
145
- catch (error) {
146
- console.error('[WebSocket] Failed to refresh token and reconnect:', error);
147
- throw new Error('Authentication failed: Unable to refresh token for WebSocket streaming');
148
- }
149
- }
150
- else if (!((_b = this.socket) === null || _b === void 0 ? void 0 : _b.connected)) {
151
- // Token is valid but not connected - establish connection
152
- yield this.connect();
153
- }
130
+ yield this.connect();
154
131
  });
155
132
  }
156
133
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whio-api-sdk",
3
- "version": "1.1.12",
3
+ "version": "1.1.14",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -63,8 +63,7 @@ export class WebSocketModule extends BaseClient {
63
63
 
64
64
  try {
65
65
  // Ensure we have a fresh token before connecting
66
- await this.getToken();
67
- const token = this.getAccessToken();
66
+ const token = await this.getValidToken();
68
67
 
69
68
  if (!token) {
70
69
  this.emit('connection-error', new Error('No access token available for WebSocket connection'));
@@ -149,37 +148,11 @@ export class WebSocketModule extends BaseClient {
149
148
  return { ...this.connectionStats };
150
149
  }
151
150
 
152
- /**
153
- * Ensure WebSocket connection has a valid token
154
- * Reconnects with fresh token if current token is expired
155
- */
156
151
  private async ensureValidConnection(): Promise<void> {
157
-
158
152
  if(this.socket?.connected) {
159
153
  return;
160
154
  }
161
-
162
- const currentToken = await this.getValidToken();
163
-
164
- // Check if we have a token and if it's expired
165
- if (!currentToken || this.isTokenExpired(currentToken)) {
166
-
167
- try {
168
- // Refresh token
169
- await this.getToken();
170
-
171
- // Disconnect current connection and reconnect with fresh token
172
- this.disconnect();
173
- await this.connect();
174
-
175
- } catch (error) {
176
- console.error('[WebSocket] Failed to refresh token and reconnect:', error);
177
- throw new Error('Authentication failed: Unable to refresh token for WebSocket streaming');
178
- }
179
- } else if (!this.socket?.connected) {
180
- // Token is valid but not connected - establish connection
181
- await this.connect();
182
- }
155
+ await this.connect();
183
156
  }
184
157
 
185
158
  /**