tsvesync 1.0.89 → 1.0.90
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 +1 -36
- package/dist/lib/helpers.d.ts +0 -13
- package/dist/lib/helpers.js +4 -158
- package/dist/lib/vesync.d.ts +1 -1
- package/dist/lib/vesync.js +5 -5
- package/package.json +1 -1
- package/src/lib/helpers.ts +3 -169
- package/src/lib/vesync.ts +6 -6
package/README.md
CHANGED
|
@@ -201,42 +201,7 @@ The library supports configuration through environment variables:
|
|
|
201
201
|
```env
|
|
202
202
|
VESYNC_USERNAME=your_email@example.com
|
|
203
203
|
VESYNC_PASSWORD=your_password
|
|
204
|
-
VESYNC_API_URL=https://smartapi.vesync.com # Optional,
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
### Regional API Support
|
|
208
|
-
|
|
209
|
-
The library automatically detects the correct regional API endpoint based on your timezone:
|
|
210
|
-
|
|
211
|
-
- **Europe**: `https://smartapi.vesync.eu` (for European timezones like `Europe/Berlin`, `Europe/London`)
|
|
212
|
-
- **Asia**: `https://smartapi.vesync.com.cn` (for Asian timezones like `Asia/Shanghai`, `Asia/Tokyo`)
|
|
213
|
-
- **US/Others**: `https://smartapi.vesync.com` (default for all other timezones)
|
|
214
|
-
|
|
215
|
-
**For German users experiencing authentication issues:**
|
|
216
|
-
|
|
217
|
-
```typescript
|
|
218
|
-
// This will automatically use the EU API endpoint
|
|
219
|
-
const manager = new VeSync(
|
|
220
|
-
'your_email@example.com',
|
|
221
|
-
'your_password',
|
|
222
|
-
'Europe/Berlin' // This triggers EU endpoint selection
|
|
223
|
-
);
|
|
224
|
-
|
|
225
|
-
await manager.login();
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
**Manual API endpoint override:**
|
|
229
|
-
|
|
230
|
-
```typescript
|
|
231
|
-
// Force a specific regional endpoint
|
|
232
|
-
const manager = new VeSync(
|
|
233
|
-
'your_email@example.com',
|
|
234
|
-
'your_password',
|
|
235
|
-
'Europe/Berlin',
|
|
236
|
-
false, // debug
|
|
237
|
-
true, // redact
|
|
238
|
-
'https://smartapi.vesync.eu' // Force EU endpoint
|
|
239
|
-
);
|
|
204
|
+
VESYNC_API_URL=https://smartapi.vesync.com # Optional, defaults to standard API URL
|
|
240
205
|
```
|
|
241
206
|
|
|
242
207
|
## Testing
|
package/dist/lib/helpers.d.ts
CHANGED
|
@@ -2,21 +2,8 @@
|
|
|
2
2
|
* Helper functions for VeSync API
|
|
3
3
|
*/
|
|
4
4
|
import { VeSync } from './vesync';
|
|
5
|
-
export declare const REGIONAL_ENDPOINTS: {
|
|
6
|
-
readonly US: "https://smartapi.vesync.com";
|
|
7
|
-
readonly EU: "https://smartapi.vesync.eu";
|
|
8
|
-
readonly ASIA: "https://smartapi.vesync.com.cn";
|
|
9
|
-
};
|
|
10
5
|
export declare function getApiBaseUrl(): string;
|
|
11
6
|
export declare function setApiBaseUrl(url: string): void;
|
|
12
|
-
/**
|
|
13
|
-
* Get regional API endpoint based on timezone
|
|
14
|
-
*/
|
|
15
|
-
export declare function getRegionalEndpoint(timeZone: string): string;
|
|
16
|
-
/**
|
|
17
|
-
* Set API endpoint based on timezone if not explicitly set
|
|
18
|
-
*/
|
|
19
|
-
export declare function setRegionalEndpoint(timeZone: string): void;
|
|
20
7
|
export declare const API_RATE_LIMIT = 30;
|
|
21
8
|
export declare const API_TIMEOUT = 15000;
|
|
22
9
|
export declare const APP_VERSION = "2.8.6";
|
package/dist/lib/helpers.js
CHANGED
|
@@ -6,174 +6,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
6
6
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.Helpers = exports.BYPASS_HEADER_UA = exports.MOBILE_ID = exports.DEFAULT_REGION = exports.DEFAULT_TZ = exports.USER_TYPE = exports.PHONE_OS = exports.PHONE_BRAND = exports.APP_VERSION = exports.API_TIMEOUT = exports.API_RATE_LIMIT =
|
|
9
|
+
exports.Helpers = exports.BYPASS_HEADER_UA = exports.MOBILE_ID = exports.DEFAULT_REGION = exports.DEFAULT_TZ = exports.USER_TYPE = exports.PHONE_OS = exports.PHONE_BRAND = exports.APP_VERSION = exports.API_TIMEOUT = exports.API_RATE_LIMIT = void 0;
|
|
10
10
|
exports.getApiBaseUrl = getApiBaseUrl;
|
|
11
11
|
exports.setApiBaseUrl = setApiBaseUrl;
|
|
12
|
-
exports.getRegionalEndpoint = getRegionalEndpoint;
|
|
13
|
-
exports.setRegionalEndpoint = setRegionalEndpoint;
|
|
14
12
|
const axios_1 = __importDefault(require("axios"));
|
|
15
13
|
const crypto_1 = __importDefault(require("crypto"));
|
|
16
14
|
const logger_1 = require("./logger");
|
|
17
|
-
// API configuration
|
|
15
|
+
// API configuration - Always use US endpoint
|
|
18
16
|
let _apiBaseUrl = 'https://smartapi.vesync.com';
|
|
19
|
-
// Regional API endpoints
|
|
20
|
-
exports.REGIONAL_ENDPOINTS = {
|
|
21
|
-
US: 'https://smartapi.vesync.com',
|
|
22
|
-
EU: 'https://smartapi.vesync.eu',
|
|
23
|
-
ASIA: 'https://smartapi.vesync.com.cn'
|
|
24
|
-
};
|
|
25
|
-
// Timezone to region mapping for API endpoint detection
|
|
26
|
-
const TIMEZONE_REGION_MAP = {
|
|
27
|
-
// European timezones - Western Europe
|
|
28
|
-
'Europe/Berlin': 'EU',
|
|
29
|
-
'Europe/London': 'EU',
|
|
30
|
-
'Europe/Paris': 'EU',
|
|
31
|
-
'Europe/Rome': 'EU',
|
|
32
|
-
'Europe/Madrid': 'EU',
|
|
33
|
-
'Europe/Amsterdam': 'EU',
|
|
34
|
-
'Europe/Vienna': 'EU',
|
|
35
|
-
'Europe/Brussels': 'EU',
|
|
36
|
-
'Europe/Copenhagen': 'EU',
|
|
37
|
-
'Europe/Dublin': 'EU',
|
|
38
|
-
'Europe/Helsinki': 'EU',
|
|
39
|
-
'Europe/Lisbon': 'EU',
|
|
40
|
-
'Europe/Luxembourg': 'EU',
|
|
41
|
-
'Europe/Oslo': 'EU',
|
|
42
|
-
'Europe/Prague': 'EU',
|
|
43
|
-
'Europe/Stockholm': 'EU',
|
|
44
|
-
'Europe/Warsaw': 'EU',
|
|
45
|
-
'Europe/Zurich': 'EU',
|
|
46
|
-
// European timezones - Eastern Europe
|
|
47
|
-
'Europe/Athens': 'EU',
|
|
48
|
-
'Europe/Budapest': 'EU',
|
|
49
|
-
'Europe/Bucharest': 'EU',
|
|
50
|
-
'Europe/Sofia': 'EU',
|
|
51
|
-
'Europe/Kiev': 'EU',
|
|
52
|
-
'Europe/Riga': 'EU',
|
|
53
|
-
'Europe/Vilnius': 'EU',
|
|
54
|
-
'Europe/Tallinn': 'EU',
|
|
55
|
-
'Europe/Zagreb': 'EU',
|
|
56
|
-
'Europe/Ljubljana': 'EU',
|
|
57
|
-
'Europe/Bratislava': 'EU',
|
|
58
|
-
'Europe/Belgrade': 'EU',
|
|
59
|
-
'Europe/Sarajevo': 'EU',
|
|
60
|
-
'Europe/Podgorica': 'EU',
|
|
61
|
-
'Europe/Skopje': 'EU',
|
|
62
|
-
'Europe/Tirane': 'EU',
|
|
63
|
-
// European timezones - Nordic/Baltic
|
|
64
|
-
'Europe/Reykjavik': 'EU',
|
|
65
|
-
'Europe/Moscow': 'EU',
|
|
66
|
-
'Europe/Kaliningrad': 'EU',
|
|
67
|
-
'Europe/Minsk': 'EU',
|
|
68
|
-
// European timezones - Other
|
|
69
|
-
'Europe/Malta': 'EU',
|
|
70
|
-
'Europe/Monaco': 'EU',
|
|
71
|
-
'Europe/Vatican': 'EU',
|
|
72
|
-
'Europe/San_Marino': 'EU',
|
|
73
|
-
'Europe/Andorra': 'EU',
|
|
74
|
-
'Europe/Gibraltar': 'EU',
|
|
75
|
-
'Europe/Isle_of_Man': 'EU',
|
|
76
|
-
'Europe/Jersey': 'EU',
|
|
77
|
-
'Europe/Guernsey': 'EU',
|
|
78
|
-
// Asian timezones - East Asia
|
|
79
|
-
'Asia/Shanghai': 'ASIA',
|
|
80
|
-
'Asia/Beijing': 'ASIA',
|
|
81
|
-
'Asia/Hong_Kong': 'ASIA',
|
|
82
|
-
'Asia/Tokyo': 'ASIA',
|
|
83
|
-
'Asia/Seoul': 'ASIA',
|
|
84
|
-
'Asia/Singapore': 'ASIA',
|
|
85
|
-
'Asia/Taipei': 'ASIA',
|
|
86
|
-
'Asia/Macau': 'ASIA',
|
|
87
|
-
// Asian timezones - Southeast Asia
|
|
88
|
-
'Asia/Bangkok': 'ASIA',
|
|
89
|
-
'Asia/Jakarta': 'ASIA',
|
|
90
|
-
'Asia/Manila': 'ASIA',
|
|
91
|
-
'Asia/Ho_Chi_Minh': 'ASIA',
|
|
92
|
-
'Asia/Kuala_Lumpur': 'ASIA',
|
|
93
|
-
'Asia/Phnom_Penh': 'ASIA',
|
|
94
|
-
'Asia/Vientiane': 'ASIA',
|
|
95
|
-
'Asia/Yangon': 'ASIA',
|
|
96
|
-
'Asia/Brunei': 'ASIA',
|
|
97
|
-
// Asian timezones - South Asia
|
|
98
|
-
'Asia/Mumbai': 'ASIA',
|
|
99
|
-
'Asia/Delhi': 'ASIA',
|
|
100
|
-
'Asia/Kolkata': 'ASIA',
|
|
101
|
-
'Asia/Dhaka': 'ASIA',
|
|
102
|
-
'Asia/Karachi': 'ASIA',
|
|
103
|
-
'Asia/Colombo': 'ASIA',
|
|
104
|
-
'Asia/Kathmandu': 'ASIA',
|
|
105
|
-
'Asia/Thimphu': 'ASIA',
|
|
106
|
-
// Asian timezones - Central Asia
|
|
107
|
-
'Asia/Almaty': 'ASIA',
|
|
108
|
-
'Asia/Bishkek': 'ASIA',
|
|
109
|
-
'Asia/Dushanbe': 'ASIA',
|
|
110
|
-
'Asia/Tashkent': 'ASIA',
|
|
111
|
-
'Asia/Ashgabat': 'ASIA',
|
|
112
|
-
// Asian timezones - West Asia / Middle East
|
|
113
|
-
'Asia/Dubai': 'ASIA',
|
|
114
|
-
'Asia/Riyadh': 'ASIA',
|
|
115
|
-
'Asia/Tehran': 'ASIA',
|
|
116
|
-
'Asia/Baghdad': 'ASIA',
|
|
117
|
-
'Asia/Kuwait': 'ASIA',
|
|
118
|
-
'Asia/Qatar': 'ASIA',
|
|
119
|
-
'Asia/Bahrain': 'ASIA',
|
|
120
|
-
'Asia/Muscat': 'ASIA',
|
|
121
|
-
'Asia/Baku': 'ASIA',
|
|
122
|
-
'Asia/Yerevan': 'ASIA',
|
|
123
|
-
'Asia/Tbilisi': 'ASIA',
|
|
124
|
-
// Oceania (using ASIA endpoint for now)
|
|
125
|
-
'Australia/Sydney': 'ASIA',
|
|
126
|
-
'Australia/Melbourne': 'ASIA',
|
|
127
|
-
'Australia/Brisbane': 'ASIA',
|
|
128
|
-
'Australia/Perth': 'ASIA',
|
|
129
|
-
'Australia/Adelaide': 'ASIA',
|
|
130
|
-
'Australia/Hobart': 'ASIA',
|
|
131
|
-
'Australia/Darwin': 'ASIA',
|
|
132
|
-
'Australia/Canberra': 'ASIA',
|
|
133
|
-
'Pacific/Auckland': 'ASIA',
|
|
134
|
-
'Pacific/Wellington': 'ASIA',
|
|
135
|
-
'Pacific/Fiji': 'ASIA',
|
|
136
|
-
'Pacific/Honolulu': 'US',
|
|
137
|
-
// North America (Canada)
|
|
138
|
-
'America/Toronto': 'US',
|
|
139
|
-
'America/Montreal': 'US',
|
|
140
|
-
'America/Vancouver': 'US',
|
|
141
|
-
'America/Calgary': 'US',
|
|
142
|
-
'America/Edmonton': 'US',
|
|
143
|
-
'America/Winnipeg': 'US',
|
|
144
|
-
'America/Halifax': 'US',
|
|
145
|
-
'America/St_Johns': 'US',
|
|
146
|
-
// North America (Mexico)
|
|
147
|
-
'America/Mexico_City': 'US',
|
|
148
|
-
'America/Tijuana': 'US',
|
|
149
|
-
'America/Cancun': 'US',
|
|
150
|
-
'America/Merida': 'US',
|
|
151
|
-
'America/Monterrey': 'US'
|
|
152
|
-
// US and other timezones default to US endpoint
|
|
153
|
-
};
|
|
154
17
|
function getApiBaseUrl() {
|
|
155
18
|
return _apiBaseUrl;
|
|
156
19
|
}
|
|
157
20
|
function setApiBaseUrl(url) {
|
|
158
21
|
_apiBaseUrl = url;
|
|
159
22
|
}
|
|
160
|
-
/**
|
|
161
|
-
* Get regional API endpoint based on timezone
|
|
162
|
-
*/
|
|
163
|
-
function getRegionalEndpoint(timeZone) {
|
|
164
|
-
const region = TIMEZONE_REGION_MAP[timeZone] || 'US';
|
|
165
|
-
return exports.REGIONAL_ENDPOINTS[region];
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Set API endpoint based on timezone if not explicitly set
|
|
169
|
-
*/
|
|
170
|
-
function setRegionalEndpoint(timeZone) {
|
|
171
|
-
const regionalUrl = getRegionalEndpoint(timeZone);
|
|
172
|
-
if (_apiBaseUrl === exports.REGIONAL_ENDPOINTS.US && regionalUrl !== exports.REGIONAL_ENDPOINTS.US) {
|
|
173
|
-
logger_1.logger.debug(`Setting regional API endpoint for ${timeZone}: ${regionalUrl}`);
|
|
174
|
-
setApiBaseUrl(regionalUrl);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
23
|
exports.API_RATE_LIMIT = 30;
|
|
178
24
|
exports.API_TIMEOUT = 15000;
|
|
179
25
|
exports.APP_VERSION = '2.8.6';
|
|
@@ -320,8 +166,8 @@ class Helpers {
|
|
|
320
166
|
try {
|
|
321
167
|
// Ensure API base URL is properly set
|
|
322
168
|
if (!_apiBaseUrl || _apiBaseUrl === 'undefined') {
|
|
323
|
-
logger_1.logger.error('API base URL is not properly configured. Setting
|
|
324
|
-
|
|
169
|
+
logger_1.logger.error('API base URL is not properly configured. Setting to default US endpoint...');
|
|
170
|
+
setApiBaseUrl('https://smartapi.vesync.com');
|
|
325
171
|
}
|
|
326
172
|
const url = _apiBaseUrl + endpoint;
|
|
327
173
|
logger_1.logger.debug(`Making API call to: ${url}`);
|
package/dist/lib/vesync.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export declare class VeSync {
|
|
|
43
43
|
* Initialize VeSync Manager
|
|
44
44
|
* @param username - VeSync account username
|
|
45
45
|
* @param password - VeSync account password
|
|
46
|
-
* @param timeZone - Optional timezone (defaults to America/New_York)
|
|
46
|
+
* @param timeZone - Optional timezone for device operations (defaults to America/New_York)
|
|
47
47
|
* @param debug - Optional debug mode flag
|
|
48
48
|
* @param redact - Optional redact mode flag
|
|
49
49
|
* @param apiUrl - Optional API base URL override
|
package/dist/lib/vesync.js
CHANGED
|
@@ -124,7 +124,7 @@ class VeSync {
|
|
|
124
124
|
* Initialize VeSync Manager
|
|
125
125
|
* @param username - VeSync account username
|
|
126
126
|
* @param password - VeSync account password
|
|
127
|
-
* @param timeZone - Optional timezone (defaults to America/New_York)
|
|
127
|
+
* @param timeZone - Optional timezone for device operations (defaults to America/New_York)
|
|
128
128
|
* @param debug - Optional debug mode flag
|
|
129
129
|
* @param redact - Optional redact mode flag
|
|
130
130
|
* @param apiUrl - Optional API base URL override
|
|
@@ -173,13 +173,13 @@ class VeSync {
|
|
|
173
173
|
this.timeZone = helpers_1.DEFAULT_TZ;
|
|
174
174
|
logger_1.logger.debug('Time zone is not a string');
|
|
175
175
|
}
|
|
176
|
-
// Set custom API URL if provided, otherwise use
|
|
176
|
+
// Set custom API URL if provided, otherwise use default US endpoint
|
|
177
177
|
if (apiUrl) {
|
|
178
178
|
(0, helpers_1.setApiBaseUrl)(apiUrl);
|
|
179
179
|
}
|
|
180
180
|
else {
|
|
181
|
-
//
|
|
182
|
-
(0, helpers_1.
|
|
181
|
+
// Always use US endpoint
|
|
182
|
+
(0, helpers_1.setApiBaseUrl)('https://smartapi.vesync.com');
|
|
183
183
|
}
|
|
184
184
|
// Set custom logger if provided
|
|
185
185
|
if (customLogger) {
|
|
@@ -428,7 +428,7 @@ class VeSync {
|
|
|
428
428
|
switch (response.code) {
|
|
429
429
|
case -11012022:
|
|
430
430
|
logger_1.logger.error('App version too low error. Current version:', body.appVersion);
|
|
431
|
-
logger_1.logger.error('This typically indicates
|
|
431
|
+
logger_1.logger.error('This typically indicates an API version compatibility issue.');
|
|
432
432
|
break;
|
|
433
433
|
case -11003:
|
|
434
434
|
logger_1.logger.error('Authentication failed - check credentials');
|
package/package.json
CHANGED
package/src/lib/helpers.ts
CHANGED
|
@@ -7,157 +7,9 @@ import crypto from 'crypto';
|
|
|
7
7
|
import { VeSync } from './vesync';
|
|
8
8
|
import { logger } from './logger';
|
|
9
9
|
|
|
10
|
-
// API configuration
|
|
10
|
+
// API configuration - Always use US endpoint
|
|
11
11
|
let _apiBaseUrl = 'https://smartapi.vesync.com';
|
|
12
12
|
|
|
13
|
-
// Regional API endpoints
|
|
14
|
-
export const REGIONAL_ENDPOINTS = {
|
|
15
|
-
US: 'https://smartapi.vesync.com',
|
|
16
|
-
EU: 'https://smartapi.vesync.eu',
|
|
17
|
-
ASIA: 'https://smartapi.vesync.com.cn'
|
|
18
|
-
} as const;
|
|
19
|
-
|
|
20
|
-
// Timezone to region mapping for API endpoint detection
|
|
21
|
-
const TIMEZONE_REGION_MAP: Record<string, keyof typeof REGIONAL_ENDPOINTS> = {
|
|
22
|
-
// European timezones - Western Europe
|
|
23
|
-
'Europe/Berlin': 'EU',
|
|
24
|
-
'Europe/London': 'EU',
|
|
25
|
-
'Europe/Paris': 'EU',
|
|
26
|
-
'Europe/Rome': 'EU',
|
|
27
|
-
'Europe/Madrid': 'EU',
|
|
28
|
-
'Europe/Amsterdam': 'EU',
|
|
29
|
-
'Europe/Vienna': 'EU',
|
|
30
|
-
'Europe/Brussels': 'EU',
|
|
31
|
-
'Europe/Copenhagen': 'EU',
|
|
32
|
-
'Europe/Dublin': 'EU',
|
|
33
|
-
'Europe/Helsinki': 'EU',
|
|
34
|
-
'Europe/Lisbon': 'EU',
|
|
35
|
-
'Europe/Luxembourg': 'EU',
|
|
36
|
-
'Europe/Oslo': 'EU',
|
|
37
|
-
'Europe/Prague': 'EU',
|
|
38
|
-
'Europe/Stockholm': 'EU',
|
|
39
|
-
'Europe/Warsaw': 'EU',
|
|
40
|
-
'Europe/Zurich': 'EU',
|
|
41
|
-
|
|
42
|
-
// European timezones - Eastern Europe
|
|
43
|
-
'Europe/Athens': 'EU',
|
|
44
|
-
'Europe/Budapest': 'EU',
|
|
45
|
-
'Europe/Bucharest': 'EU',
|
|
46
|
-
'Europe/Sofia': 'EU',
|
|
47
|
-
'Europe/Kiev': 'EU',
|
|
48
|
-
'Europe/Riga': 'EU',
|
|
49
|
-
'Europe/Vilnius': 'EU',
|
|
50
|
-
'Europe/Tallinn': 'EU',
|
|
51
|
-
'Europe/Zagreb': 'EU',
|
|
52
|
-
'Europe/Ljubljana': 'EU',
|
|
53
|
-
'Europe/Bratislava': 'EU',
|
|
54
|
-
'Europe/Belgrade': 'EU',
|
|
55
|
-
'Europe/Sarajevo': 'EU',
|
|
56
|
-
'Europe/Podgorica': 'EU',
|
|
57
|
-
'Europe/Skopje': 'EU',
|
|
58
|
-
'Europe/Tirane': 'EU',
|
|
59
|
-
|
|
60
|
-
// European timezones - Nordic/Baltic
|
|
61
|
-
'Europe/Reykjavik': 'EU',
|
|
62
|
-
'Europe/Moscow': 'EU',
|
|
63
|
-
'Europe/Kaliningrad': 'EU',
|
|
64
|
-
'Europe/Minsk': 'EU',
|
|
65
|
-
|
|
66
|
-
// European timezones - Other
|
|
67
|
-
'Europe/Malta': 'EU',
|
|
68
|
-
'Europe/Monaco': 'EU',
|
|
69
|
-
'Europe/Vatican': 'EU',
|
|
70
|
-
'Europe/San_Marino': 'EU',
|
|
71
|
-
'Europe/Andorra': 'EU',
|
|
72
|
-
'Europe/Gibraltar': 'EU',
|
|
73
|
-
'Europe/Isle_of_Man': 'EU',
|
|
74
|
-
'Europe/Jersey': 'EU',
|
|
75
|
-
'Europe/Guernsey': 'EU',
|
|
76
|
-
|
|
77
|
-
// Asian timezones - East Asia
|
|
78
|
-
'Asia/Shanghai': 'ASIA',
|
|
79
|
-
'Asia/Beijing': 'ASIA',
|
|
80
|
-
'Asia/Hong_Kong': 'ASIA',
|
|
81
|
-
'Asia/Tokyo': 'ASIA',
|
|
82
|
-
'Asia/Seoul': 'ASIA',
|
|
83
|
-
'Asia/Singapore': 'ASIA',
|
|
84
|
-
'Asia/Taipei': 'ASIA',
|
|
85
|
-
'Asia/Macau': 'ASIA',
|
|
86
|
-
|
|
87
|
-
// Asian timezones - Southeast Asia
|
|
88
|
-
'Asia/Bangkok': 'ASIA',
|
|
89
|
-
'Asia/Jakarta': 'ASIA',
|
|
90
|
-
'Asia/Manila': 'ASIA',
|
|
91
|
-
'Asia/Ho_Chi_Minh': 'ASIA',
|
|
92
|
-
'Asia/Kuala_Lumpur': 'ASIA',
|
|
93
|
-
'Asia/Phnom_Penh': 'ASIA',
|
|
94
|
-
'Asia/Vientiane': 'ASIA',
|
|
95
|
-
'Asia/Yangon': 'ASIA',
|
|
96
|
-
'Asia/Brunei': 'ASIA',
|
|
97
|
-
|
|
98
|
-
// Asian timezones - South Asia
|
|
99
|
-
'Asia/Mumbai': 'ASIA',
|
|
100
|
-
'Asia/Delhi': 'ASIA',
|
|
101
|
-
'Asia/Kolkata': 'ASIA',
|
|
102
|
-
'Asia/Dhaka': 'ASIA',
|
|
103
|
-
'Asia/Karachi': 'ASIA',
|
|
104
|
-
'Asia/Colombo': 'ASIA',
|
|
105
|
-
'Asia/Kathmandu': 'ASIA',
|
|
106
|
-
'Asia/Thimphu': 'ASIA',
|
|
107
|
-
|
|
108
|
-
// Asian timezones - Central Asia
|
|
109
|
-
'Asia/Almaty': 'ASIA',
|
|
110
|
-
'Asia/Bishkek': 'ASIA',
|
|
111
|
-
'Asia/Dushanbe': 'ASIA',
|
|
112
|
-
'Asia/Tashkent': 'ASIA',
|
|
113
|
-
'Asia/Ashgabat': 'ASIA',
|
|
114
|
-
|
|
115
|
-
// Asian timezones - West Asia / Middle East
|
|
116
|
-
'Asia/Dubai': 'ASIA',
|
|
117
|
-
'Asia/Riyadh': 'ASIA',
|
|
118
|
-
'Asia/Tehran': 'ASIA',
|
|
119
|
-
'Asia/Baghdad': 'ASIA',
|
|
120
|
-
'Asia/Kuwait': 'ASIA',
|
|
121
|
-
'Asia/Qatar': 'ASIA',
|
|
122
|
-
'Asia/Bahrain': 'ASIA',
|
|
123
|
-
'Asia/Muscat': 'ASIA',
|
|
124
|
-
'Asia/Baku': 'ASIA',
|
|
125
|
-
'Asia/Yerevan': 'ASIA',
|
|
126
|
-
'Asia/Tbilisi': 'ASIA',
|
|
127
|
-
|
|
128
|
-
// Oceania (using ASIA endpoint for now)
|
|
129
|
-
'Australia/Sydney': 'ASIA',
|
|
130
|
-
'Australia/Melbourne': 'ASIA',
|
|
131
|
-
'Australia/Brisbane': 'ASIA',
|
|
132
|
-
'Australia/Perth': 'ASIA',
|
|
133
|
-
'Australia/Adelaide': 'ASIA',
|
|
134
|
-
'Australia/Hobart': 'ASIA',
|
|
135
|
-
'Australia/Darwin': 'ASIA',
|
|
136
|
-
'Australia/Canberra': 'ASIA',
|
|
137
|
-
'Pacific/Auckland': 'ASIA',
|
|
138
|
-
'Pacific/Wellington': 'ASIA',
|
|
139
|
-
'Pacific/Fiji': 'ASIA',
|
|
140
|
-
'Pacific/Honolulu': 'US',
|
|
141
|
-
|
|
142
|
-
// North America (Canada)
|
|
143
|
-
'America/Toronto': 'US',
|
|
144
|
-
'America/Montreal': 'US',
|
|
145
|
-
'America/Vancouver': 'US',
|
|
146
|
-
'America/Calgary': 'US',
|
|
147
|
-
'America/Edmonton': 'US',
|
|
148
|
-
'America/Winnipeg': 'US',
|
|
149
|
-
'America/Halifax': 'US',
|
|
150
|
-
'America/St_Johns': 'US',
|
|
151
|
-
|
|
152
|
-
// North America (Mexico)
|
|
153
|
-
'America/Mexico_City': 'US',
|
|
154
|
-
'America/Tijuana': 'US',
|
|
155
|
-
'America/Cancun': 'US',
|
|
156
|
-
'America/Merida': 'US',
|
|
157
|
-
'America/Monterrey': 'US'
|
|
158
|
-
// US and other timezones default to US endpoint
|
|
159
|
-
};
|
|
160
|
-
|
|
161
13
|
export function getApiBaseUrl(): string {
|
|
162
14
|
return _apiBaseUrl;
|
|
163
15
|
}
|
|
@@ -166,24 +18,6 @@ export function setApiBaseUrl(url: string): void {
|
|
|
166
18
|
_apiBaseUrl = url;
|
|
167
19
|
}
|
|
168
20
|
|
|
169
|
-
/**
|
|
170
|
-
* Get regional API endpoint based on timezone
|
|
171
|
-
*/
|
|
172
|
-
export function getRegionalEndpoint(timeZone: string): string {
|
|
173
|
-
const region = TIMEZONE_REGION_MAP[timeZone] || 'US';
|
|
174
|
-
return REGIONAL_ENDPOINTS[region];
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Set API endpoint based on timezone if not explicitly set
|
|
179
|
-
*/
|
|
180
|
-
export function setRegionalEndpoint(timeZone: string): void {
|
|
181
|
-
const regionalUrl = getRegionalEndpoint(timeZone);
|
|
182
|
-
if (_apiBaseUrl === REGIONAL_ENDPOINTS.US && regionalUrl !== REGIONAL_ENDPOINTS.US) {
|
|
183
|
-
logger.debug(`Setting regional API endpoint for ${timeZone}: ${regionalUrl}`);
|
|
184
|
-
setApiBaseUrl(regionalUrl);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
21
|
|
|
188
22
|
export const API_RATE_LIMIT = 30;
|
|
189
23
|
export const API_TIMEOUT = 15000;
|
|
@@ -375,8 +209,8 @@ export class Helpers {
|
|
|
375
209
|
try {
|
|
376
210
|
// Ensure API base URL is properly set
|
|
377
211
|
if (!_apiBaseUrl || _apiBaseUrl === 'undefined') {
|
|
378
|
-
logger.error('API base URL is not properly configured. Setting
|
|
379
|
-
|
|
212
|
+
logger.error('API base URL is not properly configured. Setting to default US endpoint...');
|
|
213
|
+
setApiBaseUrl('https://smartapi.vesync.com');
|
|
380
214
|
}
|
|
381
215
|
|
|
382
216
|
const url = _apiBaseUrl + endpoint;
|
package/src/lib/vesync.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* VeSync API Device Library
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { Helpers, API_RATE_LIMIT, DEFAULT_TZ, setApiBaseUrl,
|
|
5
|
+
import { Helpers, API_RATE_LIMIT, DEFAULT_TZ, setApiBaseUrl, getApiBaseUrl } from './helpers';
|
|
6
6
|
import { VeSyncBaseDevice } from './vesyncBaseDevice';
|
|
7
7
|
import { fanModules } from './vesyncFanImpl';
|
|
8
8
|
import { outletModules } from './vesyncOutletImpl';
|
|
@@ -180,7 +180,7 @@ export class VeSync {
|
|
|
180
180
|
* Initialize VeSync Manager
|
|
181
181
|
* @param username - VeSync account username
|
|
182
182
|
* @param password - VeSync account password
|
|
183
|
-
* @param timeZone - Optional timezone (defaults to America/New_York)
|
|
183
|
+
* @param timeZone - Optional timezone for device operations (defaults to America/New_York)
|
|
184
184
|
* @param debug - Optional debug mode flag
|
|
185
185
|
* @param redact - Optional redact mode flag
|
|
186
186
|
* @param apiUrl - Optional API base URL override
|
|
@@ -241,12 +241,12 @@ export class VeSync {
|
|
|
241
241
|
logger.debug('Time zone is not a string');
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
// Set custom API URL if provided, otherwise use
|
|
244
|
+
// Set custom API URL if provided, otherwise use default US endpoint
|
|
245
245
|
if (apiUrl) {
|
|
246
246
|
setApiBaseUrl(apiUrl);
|
|
247
247
|
} else {
|
|
248
|
-
//
|
|
249
|
-
|
|
248
|
+
// Always use US endpoint
|
|
249
|
+
setApiBaseUrl('https://smartapi.vesync.com');
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
// Set custom logger if provided
|
|
@@ -535,7 +535,7 @@ export class VeSync {
|
|
|
535
535
|
switch (response.code) {
|
|
536
536
|
case -11012022:
|
|
537
537
|
logger.error('App version too low error. Current version:', body.appVersion);
|
|
538
|
-
logger.error('This typically indicates
|
|
538
|
+
logger.error('This typically indicates an API version compatibility issue.');
|
|
539
539
|
break;
|
|
540
540
|
case -11003:
|
|
541
541
|
logger.error('Authentication failed - check credentials');
|