tsvesync
Version:
A TypeScript library for interacting with VeSync smart home devices
48 lines (47 loc) • 1.59 kB
JavaScript
;
/**
* VeSync API Error Codes
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.APP_VERSION_ERROR_CODES = exports.TOKEN_ERROR_CODES = exports.CROSS_REGION_ERROR_CODES = exports.CREDENTIAL_ERROR_CODES = void 0;
exports.isCredentialError = isCredentialError;
exports.isCrossRegionError = isCrossRegionError;
exports.isTokenError = isTokenError;
// Authentication error codes that indicate bad credentials (no point retrying)
exports.CREDENTIAL_ERROR_CODES = [
-11201129, // account or password incorrect
-11202129, // the account does not exist
-11000129, // illegal argument (empty credentials)
];
// Cross-region error codes that require region switching
exports.CROSS_REGION_ERROR_CODES = [
-11260022, // cross region error
-11261022, // access region conflict error
];
// Token/auth invalidation error codes
// pyvesync parity: `-11001000` maps to TOKEN_EXPIRED (invalid token)
exports.TOKEN_ERROR_CODES = [
-11001000, // token expired/invalid
];
// Other error codes
exports.APP_VERSION_ERROR_CODES = [
-11012022, // app version is too low
];
/**
* Check if an error code indicates bad credentials
*/
function isCredentialError(code) {
return exports.CREDENTIAL_ERROR_CODES.includes(code);
}
/**
* Check if an error code indicates cross-region issue
*/
function isCrossRegionError(code) {
return exports.CROSS_REGION_ERROR_CODES.includes(code);
}
/**
* Check if an error code indicates the token is invalid/expired.
*/
function isTokenError(code) {
return exports.TOKEN_ERROR_CODES.includes(code);
}