LanDeviceController.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. var lanControlAuthenticationUtils_1 = __importDefault(require("../utils/lanControlAuthenticationUtils"));
  7. var logger_1 = require("../utils/logger");
  8. var LanDeviceController = (function () {
  9. function LanDeviceController(props) {
  10. this.type = 2;
  11. var deviceId = props.deviceId, ip = props.ip, _a = props.port, port = _a === void 0 ? 8081 : _a, disabled = props.disabled, encryptedData = props.encryptedData, iv = props.iv, target = props.target, index = props.index;
  12. this.ip = ip;
  13. this.target = target;
  14. this.port = port;
  15. this.deviceId = deviceId;
  16. this.iv = iv;
  17. this.disabled = disabled;
  18. this.encryptedData = encryptedData;
  19. this.online = true;
  20. var devicekey = props.devicekey, selfApikey = props.selfApikey, deviceName = props.deviceName, extra = props.extra, params = props.params, uiid = props.uiid;
  21. this.devicekey = devicekey;
  22. this.selfApikey = selfApikey;
  23. this.deviceName = deviceName;
  24. this.extra = extra;
  25. this.params = params;
  26. this.uiid = uiid;
  27. if (index) {
  28. this.index = index;
  29. }
  30. }
  31. return LanDeviceController;
  32. }());
  33. LanDeviceController.prototype.parseEncryptedData = function () {
  34. try {
  35. if (this.iv && this.devicekey && this.encryptedData) {
  36. var res = lanControlAuthenticationUtils_1.default.decryptionData({
  37. iv: this.iv,
  38. key: this.devicekey,
  39. data: this.encryptedData,
  40. });
  41. return JSON.parse(res);
  42. }
  43. return null;
  44. }
  45. catch (error) {
  46. logger_1.logger.warn("LanDeviceController error: ".concat(error));
  47. return null;
  48. }
  49. };
  50. exports.default = LanDeviceController;