@tuya-miniapp/ark-extension-virtual-device 1.7.3-beta-2 → 1.7.3-beta-4

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.
Files changed (2) hide show
  1. package/dist/worker/index.js +261 -93
  2. package/package.json +2 -1
@@ -42423,68 +42423,108 @@ var require_crypto_js = __commonJS({
42423
42423
  }
42424
42424
  });
42425
42425
 
42426
- // node_modules/crc32/lib/crc32.js
42427
- var require_crc32 = __commonJS({
42428
- "node_modules/crc32/lib/crc32.js"(exports, module2) {
42426
+ // node_modules/js-crc/src/crc.js
42427
+ var require_crc = __commonJS({
42428
+ "node_modules/js-crc/src/crc.js"(exports, module2) {
42429
42429
  (function() {
42430
42430
  "use strict";
42431
- var table = [], poly = 3988292384;
42432
- function makeTable() {
42433
- var c2, n2, k2;
42434
- for (n2 = 0; n2 < 256; n2 += 1) {
42435
- c2 = n2;
42436
- for (k2 = 0; k2 < 8; k2 += 1) {
42437
- if (c2 & 1) {
42438
- c2 = poly ^ c2 >>> 1;
42439
- } else {
42440
- c2 = c2 >>> 1;
42441
- }
42431
+ var root = typeof window === "object" ? window : {};
42432
+ var NODE_JS = !root.JS_CRC_NO_NODE_JS && typeof process === "object" && process.versions && process.versions.node;
42433
+ if (NODE_JS) {
42434
+ root = global;
42435
+ }
42436
+ var COMMON_JS = !root.JS_CRC_NO_COMMON_JS && typeof module2 === "object" && module2.exports;
42437
+ var AMD = typeof define === "function" && define.amd;
42438
+ var ARRAY_BUFFER = !root.JS_CRC_NO_ARRAY_BUFFER && typeof ArrayBuffer !== "undefined";
42439
+ var HEX_CHARS = "0123456789abcdef".split("");
42440
+ var Modules = [
42441
+ {
42442
+ name: "crc32",
42443
+ polynom: 3988292384,
42444
+ initValue: -1,
42445
+ bytes: 4
42446
+ },
42447
+ {
42448
+ name: "crc16",
42449
+ polynom: 40961,
42450
+ initValue: 0,
42451
+ bytes: 2
42452
+ }
42453
+ ];
42454
+ var i2, j2, k2, b2;
42455
+ for (i2 = 0; i2 < Modules.length; ++i2) {
42456
+ var m2 = Modules[i2];
42457
+ m2.method = function(m3) {
42458
+ return function(message) {
42459
+ return crc(message, m3);
42460
+ };
42461
+ }(m2);
42462
+ m2.table = [];
42463
+ for (j2 = 0; j2 < 256; ++j2) {
42464
+ b2 = j2;
42465
+ for (k2 = 0; k2 < 8; ++k2) {
42466
+ b2 = b2 & 1 ? m2.polynom ^ b2 >>> 1 : b2 >>> 1;
42442
42467
  }
42443
- table[n2] = c2 >>> 0;
42468
+ m2.table[j2] = b2 >>> 0;
42444
42469
  }
42445
42470
  }
42446
- function strToArr(str) {
42447
- return Array.prototype.map.call(str, function(c2) {
42448
- return c2.charCodeAt(0);
42449
- });
42450
- }
42451
- function crcDirect(arr) {
42452
- var crc = -1, i2, j2, l2, temp;
42453
- for (i2 = 0, l2 = arr.length; i2 < l2; i2 += 1) {
42454
- temp = (crc ^ arr[i2]) & 255;
42455
- for (j2 = 0; j2 < 8; j2 += 1) {
42456
- if ((temp & 1) === 1) {
42457
- temp = temp >>> 1 ^ poly;
42471
+ var crc = function(message, module3) {
42472
+ var notString = typeof message !== "string";
42473
+ if (notString && ARRAY_BUFFER && message instanceof ArrayBuffer) {
42474
+ message = new Uint8Array(message);
42475
+ }
42476
+ var crc2 = module3.initValue, code, i3, length = message.length, table = module3.table;
42477
+ if (notString) {
42478
+ for (i3 = 0; i3 < length; ++i3) {
42479
+ crc2 = table[(crc2 ^ message[i3]) & 255] ^ crc2 >>> 8;
42480
+ }
42481
+ } else {
42482
+ for (i3 = 0; i3 < length; ++i3) {
42483
+ code = message.charCodeAt(i3);
42484
+ if (code < 128) {
42485
+ crc2 = table[(crc2 ^ code) & 255] ^ crc2 >>> 8;
42486
+ } else if (code < 2048) {
42487
+ crc2 = table[(crc2 ^ (192 | code >> 6)) & 255] ^ crc2 >>> 8;
42488
+ crc2 = table[(crc2 ^ (128 | code & 63)) & 255] ^ crc2 >>> 8;
42489
+ } else if (code < 55296 || code >= 57344) {
42490
+ crc2 = table[(crc2 ^ (224 | code >> 12)) & 255] ^ crc2 >>> 8;
42491
+ crc2 = table[(crc2 ^ (128 | code >> 6 & 63)) & 255] ^ crc2 >>> 8;
42492
+ crc2 = table[(crc2 ^ (128 | code & 63)) & 255] ^ crc2 >>> 8;
42458
42493
  } else {
42459
- temp = temp >>> 1;
42494
+ code = 65536 + ((code & 1023) << 10 | message.charCodeAt(++i3) & 1023);
42495
+ crc2 = table[(crc2 ^ (240 | code >> 18)) & 255] ^ crc2 >>> 8;
42496
+ crc2 = table[(crc2 ^ (128 | code >> 12 & 63)) & 255] ^ crc2 >>> 8;
42497
+ crc2 = table[(crc2 ^ (128 | code >> 6 & 63)) & 255] ^ crc2 >>> 8;
42498
+ crc2 = table[(crc2 ^ (128 | code & 63)) & 255] ^ crc2 >>> 8;
42460
42499
  }
42461
42500
  }
42462
- crc = crc >>> 8 ^ temp;
42463
42501
  }
42464
- return crc ^ -1;
42502
+ crc2 ^= module3.initValue;
42503
+ var hex = "";
42504
+ if (module3.bytes > 2) {
42505
+ hex += HEX_CHARS[crc2 >> 28 & 15] + HEX_CHARS[crc2 >> 24 & 15] + HEX_CHARS[crc2 >> 20 & 15] + HEX_CHARS[crc2 >> 16 & 15];
42506
+ }
42507
+ hex += HEX_CHARS[crc2 >> 12 & 15] + HEX_CHARS[crc2 >> 8 & 15] + HEX_CHARS[crc2 >> 4 & 15] + HEX_CHARS[crc2 & 15];
42508
+ return hex;
42509
+ };
42510
+ var exports2 = {};
42511
+ for (i2 = 0; i2 < Modules.length; ++i2) {
42512
+ var m2 = Modules[i2];
42513
+ exports2[m2.name] = m2.method;
42465
42514
  }
42466
- function crcTable(arr, append2) {
42467
- var crc, i2, l2;
42468
- if (typeof crcTable.crc === "undefined" || !append2 || !arr) {
42469
- crcTable.crc = 0 ^ -1;
42470
- if (!arr) {
42471
- return;
42472
- }
42515
+ if (COMMON_JS) {
42516
+ module2.exports = exports2;
42517
+ } else {
42518
+ for (i2 = 0; i2 < Modules.length; ++i2) {
42519
+ var m2 = Modules[i2];
42520
+ root[m2.name] = m2.method;
42473
42521
  }
42474
- crc = crcTable.crc;
42475
- for (i2 = 0, l2 = arr.length; i2 < l2; i2 += 1) {
42476
- crc = crc >>> 8 ^ table[(crc ^ arr[i2]) & 255];
42522
+ if (AMD) {
42523
+ define(function() {
42524
+ return exports2;
42525
+ });
42477
42526
  }
42478
- crcTable.crc = crc;
42479
- return crc ^ -1;
42480
42527
  }
42481
- makeTable();
42482
- module2.exports = function(val, direct) {
42483
- var val = typeof val === "string" ? strToArr(val) : val, ret = direct ? crcDirect(val) : crcTable(val);
42484
- return (ret >>> 0).toString(16);
42485
- };
42486
- module2.exports.direct = crcDirect;
42487
- module2.exports.table = crcTable;
42488
42528
  })();
42489
42529
  }
42490
42530
  });
@@ -220712,7 +220752,7 @@ var require_package2 = __commonJS({
220712
220752
  "package.json"(exports, module2) {
220713
220753
  module2.exports = {
220714
220754
  name: "@tuya-miniapp/ark-extension-virtual-device",
220715
- version: "1.7.3-beta-1",
220755
+ version: "1.7.3-beta-4",
220716
220756
  license: "MIT",
220717
220757
  files: [
220718
220758
  "manifest.json",
@@ -220795,6 +220835,7 @@ var require_package2 = __commonJS({
220795
220835
  fs: "^0.0.1-security",
220796
220836
  "fs-extra": "*",
220797
220837
  glob: "^10.3.4",
220838
+ "js-crc": "^0.2.0",
220798
220839
  json5: "^2.2.1",
220799
220840
  "lz-string": "^1.4.4",
220800
220841
  matt: "^0.0.5",
@@ -262740,6 +262781,8 @@ var getDeviceInfo = async (body) => {
262740
262781
  devId: body?.deviceId
262741
262782
  }
262742
262783
  });
262784
+ console.log("devInfo>>>>>", JSON.stringify(devInfo));
262785
+ console.log("devINfo2>>>", JSON.stringify(devInfo32));
262743
262786
  if (!devInfo.success && !devInfo.result) {
262744
262787
  return null;
262745
262788
  }
@@ -262761,6 +262804,7 @@ var getDeviceInfo = async (body) => {
262761
262804
  });
262762
262805
  const pro = pInfo?.result[0];
262763
262806
  devInfo.result.bizAttribute = pro?.bizAttribute;
262807
+ console.log("productInfo>>>>", JSON.stringify(pInfo));
262764
262808
  } catch (error) {
262765
262809
  console.log("-----error tuya.m.product.ext.prop.batch.get", error);
262766
262810
  }
@@ -262980,7 +263024,7 @@ var import_crypto3 = require("crypto");
262980
263024
  var import_crypto = require("crypto");
262981
263025
  var CryptoJS = require_crypto_js();
262982
263026
  var crypto = require("crypto");
262983
- var crc32 = require_crc32();
263027
+ var crc32 = require_crc().crc32;
262984
263028
  var md5 = require_md5();
262985
263029
  function Decrypt(serect, config) {
262986
263030
  try {
@@ -263015,19 +263059,14 @@ function Decrypt20(secret, localKey) {
263015
263059
  }
263016
263060
  function Encrypt20(message, localKey, gwId) {
263017
263061
  try {
263018
- const data = Buffer.from(JSON.stringify(message.data), "utf8");
263019
- const keyData = Buffer.from(localKey, "utf8");
263020
- const t2 = `${(/* @__PURE__ */ new Date()).getTime()}`.substring(0, 10);
263021
- console.log("messageData", data.toString("hex"));
263022
- console.log("$localKeyData", keyData.toString("hex"));
263062
+ const t2 = Number(`${(/* @__PURE__ */ new Date()).getTime()}`.substring(0, 10));
263023
263063
  const cipher = CryptoJS.AES.encrypt(JSON.stringify(message.data), CryptoJS.enc.Utf8.parse(localKey), {
263024
263064
  mode: CryptoJS.mode.ECB,
263025
263065
  padding: CryptoJS.pad.Pkcs7,
263026
263066
  iv: ""
263027
263067
  });
263028
263068
  const encryptData = cipher.ciphertext.toString(CryptoJS.enc.Hex);
263029
- console.log("encryptData", encryptData);
263030
- const d2 = `${encryptData}||gwId=${gwId}||protocol=${message.protocol || 5}||pv=2.0||t=${t2}||${localKey}`;
263069
+ const d2 = `data=${encryptData}||gwId=${gwId}||protocol=${message.protocol || 5}||pv=2.0||t=${t2}||${localKey}`;
263031
263070
  const signData = md5(d2);
263032
263071
  const p2 = {
263033
263072
  pv: "2.0",
@@ -263037,11 +263076,7 @@ function Encrypt20(message, localKey, gwId) {
263037
263076
  gwId,
263038
263077
  t: t2
263039
263078
  };
263040
- console.log("signData", signData);
263041
- console.log("p", p2);
263042
263079
  const buffer = Buffer.from(JSON.stringify(p2), "utf8");
263043
- const de2 = Decrypt20(encryptData, localKey);
263044
- console.log("----de", de2);
263045
263080
  return buffer;
263046
263081
  } catch (e2) {
263047
263082
  console.log("Encrypt is error", e2);
@@ -263092,7 +263127,7 @@ function Encrypt22(data, key) {
263092
263127
  msg += cipher.final("hex");
263093
263128
  const encryptData = msg;
263094
263129
  const crc32Data = sData + rData + encryptData;
263095
- const signData = crc32(crc32Data).toString("hex");
263130
+ const signData = crc32(strToHexArr(crc32Data)).toString(16);
263096
263131
  console.log("------signData", signData);
263097
263132
  const result = `${version}${signData}${sData}${rData}${encryptData}`;
263098
263133
  const decr = Decrypt22(Buffer.from(result, "hex"), key);
@@ -263187,6 +263222,20 @@ var numberToHex = (str, len = str.length) => {
263187
263222
  }
263188
263223
  return val;
263189
263224
  };
263225
+ function strToHexArr(str) {
263226
+ const hexArr = [];
263227
+ if (!str) {
263228
+ return hexArr;
263229
+ }
263230
+ if (!str.match(/^[0-9a-fA-F]+$/)) {
263231
+ throw new Error("Input is not a hex string.");
263232
+ }
263233
+ const len = str.length;
263234
+ for (let t2 = 0; t2 < len; t2 += 2) {
263235
+ hexArr.push(parseInt(str.substr(t2, 2), 16));
263236
+ }
263237
+ return hexArr;
263238
+ }
263190
263239
  function generateRandomHash(length) {
263191
263240
  const bytes = crypto.randomBytes(length);
263192
263241
  const hex = bytes.toString("hex");
@@ -265906,21 +265955,10 @@ var getVirtualBindInfo = async (params) => {
265906
265955
  };
265907
265956
 
265908
265957
  // worker/api/services/queryDps.ts
265909
- var queryDps = async ({ deviceId, dpIds }) => {
265910
- const deviceInfo2 = await getDeviceInfo({ "deviceId": deviceId });
265911
- const dps = deviceInfo2?.result?.dps || {};
265912
- const schema = JSON.parse(deviceInfo2?.result?.schema || "[]");
265913
- JSON.parse(schema).map((item) => {
265914
- const { id, code, property, type: oType } = item;
265915
- const { type } = property || {};
265916
- if (type === "raw" || oType === "raw") {
265917
- const b2 = Buffer.from(dps[id], "base64");
265918
- dps[id] = b2.toString("hex");
265919
- }
265920
- });
265958
+ var queryDps = ({ deviceId, dpIds }) => {
265921
265959
  const result = {};
265922
265960
  for (const dpId of dpIds) {
265923
- result[dpId] = dps[dpId];
265961
+ result[dpId] = null;
265924
265962
  }
265925
265963
  return result;
265926
265964
  };
@@ -266154,7 +266192,7 @@ var parseI18nCheckResult = async () => {
266154
266192
  const langCheck = i18nMap[key] ?? {};
266155
266193
  for (const lang of langs) {
266156
266194
  langCheck[lang] = key in result[lang];
266157
- if (!langCheck[lang]) {
266195
+ if (!langCheck[lang] && ["zh", "en"].includes(lang)) {
266158
266196
  errorKeys.push(key);
266159
266197
  }
266160
266198
  }
@@ -279762,6 +279800,7 @@ async function getDeviceInfo2(params) {
279762
279800
  const { id, code } = item;
279763
279801
  objSchema[code] = dps[id];
279764
279802
  });
279803
+ console.log("--------objSchema", dev);
279765
279804
  const d2 = {
279766
279805
  ...devInfo,
279767
279806
  attributeString: parseInt(productInfo.attribute, 10).toString(2),
@@ -279830,7 +279869,7 @@ async function getDeviceInfo2(params) {
279830
279869
  };
279831
279870
  }
279832
279871
  async function publishDps2(params) {
279833
- const { deviceId, dps } = params;
279872
+ const { deviceId, dps, showPublish = true } = params;
279834
279873
  try {
279835
279874
  let dev = cachedDevices2[deviceId];
279836
279875
  if (!dev) {
@@ -279838,6 +279877,7 @@ async function publishDps2(params) {
279838
279877
  dev = cachedDevices2[deviceId];
279839
279878
  }
279840
279879
  let _dps = { ...dps };
279880
+ let _atopDps = { ...dps };
279841
279881
  if (dev) {
279842
279882
  const { schema } = dev;
279843
279883
  const idCodes = {};
@@ -279848,6 +279888,7 @@ async function publishDps2(params) {
279848
279888
  });
279849
279889
  const publish = {};
279850
279890
  const pudp = {};
279891
+ const s2 = typeof schema === "string" ? JSON.parse(schema) : schema;
279851
279892
  Object.keys(dps).map((key) => {
279852
279893
  if (isNumeric(key)) {
279853
279894
  const code2 = idCodes[key];
@@ -279857,12 +279898,28 @@ async function publishDps2(params) {
279857
279898
  pudp[codeIds[key]] = dps[key];
279858
279899
  }
279859
279900
  });
279860
- ark.runtime.sendMessage(
279901
+ showPublish && ark.runtime.sendMessage(
279861
279902
  JSON.stringify({ type: "publishDps", value: publish, protocol: 5 })
279862
279903
  );
279863
279904
  if (Object.keys(pudp).length > 0) {
279864
279905
  _dps = pudp;
279906
+ _atopDps = { ...pudp };
279907
+ console.log("--------pudp", pudp);
279865
279908
  }
279909
+ s2.map((item) => {
279910
+ const { id, code: code2, property, type: oType } = item;
279911
+ const { type } = property || {};
279912
+ if (Object.keys(_dps).includes(`${id}`) && (type === "raw" || oType === "raw") && isHexString(_dps[id])) {
279913
+ const b2 = Buffer.from(_dps[id], "hex");
279914
+ _dps[id] = b2.toString("base64");
279915
+ }
279916
+ if (Object.keys(_dps).includes(`${id}`) && (type === "raw" || oType === "raw") && !_dps[id]) {
279917
+ delete _dps[id];
279918
+ }
279919
+ if (Object.keys(_dps).includes(`${id}`) && (type === "value" || oType === "value") && !isInteger(_dps[id])) {
279920
+ viewLog("@i18n(number_publish_error)");
279921
+ }
279922
+ });
279866
279923
  }
279867
279924
  console.log("--------result publishDpsWithMqtt", deviceId, _dps);
279868
279925
  let reason;
@@ -279877,15 +279934,29 @@ async function publishDps2(params) {
279877
279934
  }
279878
279935
  };
279879
279936
  const topic = `smart/mb/out/${deviceId}`;
279880
- const { pv } = dev;
279937
+ const { pv = "2.2" } = dev;
279881
279938
  let data = null;
279882
279939
  console.log("--------pv", pv);
279883
279940
  switch (pv) {
279941
+ case "2.0":
279942
+ data = crypto_default.Encrypt20(message, dev.localKey, dev.gwId || dev.devId);
279943
+ console.log("---------data", data);
279944
+ break;
279945
+ case "2.2":
279946
+ if (dev.localKey) {
279947
+ data = crypto_default.Encrypt22(message, dev.localKey);
279948
+ } else {
279949
+ result = await publishDps({ deviceId, dps: _dps }, (err) => {
279950
+ reason = err;
279951
+ console.log("--------error", err);
279952
+ });
279953
+ }
279954
+ break;
279884
279955
  case "2.3":
279885
279956
  data = crypto_default.Encrypt23(message, dev.localKey);
279886
279957
  break;
279887
279958
  default:
279888
- result = await publishDps({ deviceId, dps: _dps }, (err) => {
279959
+ result = await publishDps({ deviceId, dps: _atopDps }, (err) => {
279889
279960
  reason = err;
279890
279961
  console.log("--------error", err);
279891
279962
  });
@@ -279990,11 +280061,58 @@ async function getProductInfo2(params) {
279990
280061
  }
279991
280062
  async function queryDps2(params) {
279992
280063
  try {
279993
- const dps = await queryDps(params);
280064
+ const { deviceId, dpIds } = params;
280065
+ const dev = cachedDevices2[deviceId];
280066
+ console.log("--------queryDps", dpIds);
280067
+ const message = {
280068
+ protocol: 31,
280069
+ t: Number(`${(/* @__PURE__ */ new Date()).getTime()}`.substring(0, 10)),
280070
+ data: {
280071
+ dpId: dpIds.map(Number)
280072
+ }
280073
+ };
280074
+ const topic = `smart/mb/out/${deviceId}`;
280075
+ const { pv = "2.2" } = dev;
280076
+ let data = null;
280077
+ switch (pv) {
280078
+ case "2.0":
280079
+ data = crypto_default.Encrypt20(message, dev.localKey, dev.gwId || dev.devId);
280080
+ break;
280081
+ case "2.2":
280082
+ data = crypto_default.Encrypt22(message, dev.localKey);
280083
+ break;
280084
+ case "2.3":
280085
+ data = crypto_default.Encrypt23(message, dev.localKey);
280086
+ break;
280087
+ default:
280088
+ break;
280089
+ }
280090
+ if (data) {
280091
+ initMqttClient_default._client.publish(
280092
+ topic,
280093
+ data,
280094
+ { qos: 1, retain: true },
280095
+ (error, pocket) => {
280096
+ console.log("------publish", error, pocket, data);
280097
+ }
280098
+ );
280099
+ }
280100
+ const q2 = dpIds.reduce((a2, c2) => {
280101
+ a2[c2] = null;
280102
+ return a2;
280103
+ }, {});
280104
+ publishDps2({
280105
+ deviceId,
280106
+ dps: q2,
280107
+ mode: 2,
280108
+ pipelines: [1, 2, 3, 4, 5, 6],
280109
+ options: {},
280110
+ showPublish: false
280111
+ });
279994
280112
  return {
279995
- data: dps,
279996
- errorCode: !!dps ? 0 : import_TYUniCode3.TYUniPluginError.DEVICEKIT_QUERY_DPS_ERROR.code,
279997
- errorMsg: !!dps ? import_TYUniCode3.TYUniPluginError.SUCCESS.des : import_TYUniCode3.TYUniPluginError.DEVICEKIT_QUERY_DPS_ERROR.des
280113
+ data: true,
280114
+ errorCode: 0,
280115
+ errorMsg: import_TYUniCode3.TYUniPluginError.SUCCESS.des
279998
280116
  };
279999
280117
  } catch (e2) {
280000
280118
  return {
@@ -280350,7 +280468,9 @@ function dpTranslateAdvancedCapability(params) {
280350
280468
  targetStatusValue = leftDisplayValue;
280351
280469
  } else {
280352
280470
  let showValuePerStep = (rightDisplayValue - leftDisplayValue) / (rightOriginalValue - leftOriginalValue);
280353
- targetStatusValue = Math.floor((statusValue - leftOriginalValue) * showValuePerStep + leftDisplayValue);
280471
+ targetStatusValue = Math.floor(
280472
+ (statusValue - leftOriginalValue) * showValuePerStep + leftDisplayValue
280473
+ );
280354
280474
  }
280355
280475
  return {
280356
280476
  dpCode,
@@ -281529,6 +281649,22 @@ async function addTimer(params) {
281529
281649
  };
281530
281650
  }
281531
281651
  }
281652
+ let isDpId = true;
281653
+ const keys = Object.keys(dps);
281654
+ for (const key of keys) {
281655
+ if (!isNumeric(key)) {
281656
+ isDpId = false;
281657
+ break;
281658
+ }
281659
+ }
281660
+ if (!isDpId) {
281661
+ return {
281662
+ errorCode: import_TYUniCode11.TYUniPluginError.DEVICEKIT_DEVICE_NETWORK_ERROR.code,
281663
+ errorMsg: import_TYUniCode11.TYUniPluginError.DEVICEKIT_DEVICE_NETWORK_ERROR.des,
281664
+ ext: { errorCode: "1501", errorMsg: "dpId is not a number" },
281665
+ data: null
281666
+ };
281667
+ }
281532
281668
  try {
281533
281669
  const data = await apiRequestByAtop({
281534
281670
  api: "tuya.m.clock.dps.add",
@@ -281578,6 +281714,22 @@ async function updateTimer(params) {
281578
281714
  };
281579
281715
  }
281580
281716
  }
281717
+ let isDpId = true;
281718
+ const keys = Object.keys(dps);
281719
+ for (const key of keys) {
281720
+ if (!isNumeric(key)) {
281721
+ isDpId = false;
281722
+ break;
281723
+ }
281724
+ }
281725
+ if (!isDpId) {
281726
+ return {
281727
+ errorCode: import_TYUniCode11.TYUniPluginError.DEVICEKIT_DEVICE_NETWORK_ERROR.code,
281728
+ errorMsg: import_TYUniCode11.TYUniPluginError.DEVICEKIT_DEVICE_NETWORK_ERROR.des,
281729
+ ext: { errorCode: "1501", errorMsg: "dpId is not a number" },
281730
+ data: null
281731
+ };
281732
+ }
281581
281733
  try {
281582
281734
  const data = await apiRequestByAtop({
281583
281735
  api: "tuya.m.clock.dps.update",
@@ -282031,12 +282183,17 @@ async function getRemoteRebootTimers(params) {
282031
282183
  const data = crypto_default.Encrypt23(message, device.localKey);
282032
282184
  console.log("------publish data", data);
282033
282185
  const topic = `smart/mb/out/${deviceId}`;
282034
- initMqttClient_default._client.publish(topic, data, {
282035
- qos: 1,
282036
- retain: true
282037
- }, (error, pocket) => {
282038
- console.log("------publish", error, pocket);
282039
- });
282186
+ initMqttClient_default._client.publish(
282187
+ topic,
282188
+ data,
282189
+ {
282190
+ qos: 1,
282191
+ retain: true
282192
+ },
282193
+ (error, pocket) => {
282194
+ console.log("------publish", error, pocket);
282195
+ }
282196
+ );
282040
282197
  } catch (e2) {
282041
282198
  console.log("============fail", e2);
282042
282199
  }
@@ -282161,7 +282318,7 @@ async function publishThingModelMessage(params) {
282161
282318
  "0": `tylink/${devId}/thing/property/set`,
282162
282319
  "1": `tylink/${devId}/thing/action/execute`
282163
282320
  };
282164
- initMqttClient_default._client.publish(topics[type], JSON.stringify(payload));
282321
+ initMqttClient_default._client.publish(topics[type], JSON.stringify({ data: payload, time: Number(`${Date.now()}`.substring(0, 10)) }));
282165
282322
  return {
282166
282323
  data: true,
282167
282324
  errorCode: 0,
@@ -282500,6 +282657,17 @@ crypto-js/mode-ctr-gladman.js:
282500
282657
  * Jan Hruby jhruby.web@gmail.com
282501
282658
  *)
282502
282659
 
282660
+ js-crc/src/crc.js:
282661
+ (**
282662
+ * [js-crc]{@link https://github.com/emn178/js-crc}
282663
+ *
282664
+ * @namespace crc
282665
+ * @version 0.2.0
282666
+ * @author Chen, Yi-Cyuan [emn178@gmail.com]
282667
+ * @copyright Chen, Yi-Cyuan 2015-2017
282668
+ * @license MIT
282669
+ *)
282670
+
282503
282671
  typescript/lib/typescript.js:
282504
282672
  (*! *****************************************************************************
282505
282673
  Copyright (c) Microsoft Corporation. All rights reserved.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-miniapp/ark-extension-virtual-device",
3
- "version": "1.7.3-beta-2",
3
+ "version": "1.7.3-beta-4",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "manifest.json",
@@ -83,6 +83,7 @@
83
83
  "fs": "^0.0.1-security",
84
84
  "fs-extra": "*",
85
85
  "glob": "^10.3.4",
86
+ "js-crc": "^0.2.0",
86
87
  "json5": "^2.2.1",
87
88
  "lz-string": "^1.4.4",
88
89
  "matt": "^0.0.5",