@tuya-miniapp/ark-extension-virtual-device 1.7.3-beta-2 → 1.7.3-beta-3
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/dist/worker/index.js +240 -90
- package/package.json +2 -1
package/dist/worker/index.js
CHANGED
|
@@ -42423,68 +42423,108 @@ var require_crypto_js = __commonJS({
|
|
|
42423
42423
|
}
|
|
42424
42424
|
});
|
|
42425
42425
|
|
|
42426
|
-
// node_modules/
|
|
42427
|
-
var
|
|
42428
|
-
"node_modules/
|
|
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
|
|
42432
|
-
|
|
42433
|
-
|
|
42434
|
-
|
|
42435
|
-
|
|
42436
|
-
|
|
42437
|
-
|
|
42438
|
-
|
|
42439
|
-
|
|
42440
|
-
|
|
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[
|
|
42468
|
+
m2.table[j2] = b2 >>> 0;
|
|
42444
42469
|
}
|
|
42445
42470
|
}
|
|
42446
|
-
function
|
|
42447
|
-
|
|
42448
|
-
|
|
42449
|
-
|
|
42450
|
-
|
|
42451
|
-
|
|
42452
|
-
|
|
42453
|
-
|
|
42454
|
-
|
|
42455
|
-
|
|
42456
|
-
|
|
42457
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
42467
|
-
|
|
42468
|
-
|
|
42469
|
-
|
|
42470
|
-
|
|
42471
|
-
|
|
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
|
-
|
|
42475
|
-
|
|
42476
|
-
|
|
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-
|
|
220755
|
+
version: "1.7.3-beta-3",
|
|
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 =
|
|
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
|
|
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
|
-
|
|
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(
|
|
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 =
|
|
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] =
|
|
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),
|
|
@@ -279862,6 +279901,7 @@ async function publishDps2(params) {
|
|
|
279862
279901
|
);
|
|
279863
279902
|
if (Object.keys(pudp).length > 0) {
|
|
279864
279903
|
_dps = pudp;
|
|
279904
|
+
console.log("--------pudp", pudp);
|
|
279865
279905
|
}
|
|
279866
279906
|
}
|
|
279867
279907
|
console.log("--------result publishDpsWithMqtt", deviceId, _dps);
|
|
@@ -279877,10 +279917,24 @@ async function publishDps2(params) {
|
|
|
279877
279917
|
}
|
|
279878
279918
|
};
|
|
279879
279919
|
const topic = `smart/mb/out/${deviceId}`;
|
|
279880
|
-
const { pv } = dev;
|
|
279920
|
+
const { pv = "2.2" } = dev;
|
|
279881
279921
|
let data = null;
|
|
279882
279922
|
console.log("--------pv", pv);
|
|
279883
279923
|
switch (pv) {
|
|
279924
|
+
case "2.0":
|
|
279925
|
+
data = crypto_default.Encrypt20(message, dev.localKey, dev.gwId || dev.devId);
|
|
279926
|
+
console.log("---------data", data);
|
|
279927
|
+
break;
|
|
279928
|
+
case "2.2":
|
|
279929
|
+
if (dev.localKey) {
|
|
279930
|
+
data = crypto_default.Encrypt22(message, dev.localKey);
|
|
279931
|
+
} else {
|
|
279932
|
+
result = await publishDps({ deviceId, dps: _dps }, (err) => {
|
|
279933
|
+
reason = err;
|
|
279934
|
+
console.log("--------error", err);
|
|
279935
|
+
});
|
|
279936
|
+
}
|
|
279937
|
+
break;
|
|
279884
279938
|
case "2.3":
|
|
279885
279939
|
data = crypto_default.Encrypt23(message, dev.localKey);
|
|
279886
279940
|
break;
|
|
@@ -279990,11 +280044,57 @@ async function getProductInfo2(params) {
|
|
|
279990
280044
|
}
|
|
279991
280045
|
async function queryDps2(params) {
|
|
279992
280046
|
try {
|
|
279993
|
-
const
|
|
280047
|
+
const { deviceId, dpIds } = params;
|
|
280048
|
+
const dev = cachedDevices2[deviceId];
|
|
280049
|
+
console.log("--------queryDps", dpIds);
|
|
280050
|
+
const message = {
|
|
280051
|
+
protocol: 31,
|
|
280052
|
+
t: Number(`${(/* @__PURE__ */ new Date()).getTime()}`.substring(0, 10)),
|
|
280053
|
+
data: {
|
|
280054
|
+
dpId: dpIds.map(Number)
|
|
280055
|
+
}
|
|
280056
|
+
};
|
|
280057
|
+
const topic = `smart/mb/out/${deviceId}`;
|
|
280058
|
+
const { pv = "2.2" } = dev;
|
|
280059
|
+
let data = null;
|
|
280060
|
+
switch (pv) {
|
|
280061
|
+
case "2.0":
|
|
280062
|
+
data = crypto_default.Encrypt20(message, dev.localKey, dev.gwId || dev.devId);
|
|
280063
|
+
break;
|
|
280064
|
+
case "2.2":
|
|
280065
|
+
data = crypto_default.Encrypt22(message, dev.localKey);
|
|
280066
|
+
break;
|
|
280067
|
+
case "2.3":
|
|
280068
|
+
data = crypto_default.Encrypt23(message, dev.localKey);
|
|
280069
|
+
break;
|
|
280070
|
+
default:
|
|
280071
|
+
break;
|
|
280072
|
+
}
|
|
280073
|
+
if (data) {
|
|
280074
|
+
initMqttClient_default._client.publish(
|
|
280075
|
+
topic,
|
|
280076
|
+
data,
|
|
280077
|
+
{ qos: 1, retain: true },
|
|
280078
|
+
(error, pocket) => {
|
|
280079
|
+
console.log("------publish", error, pocket, data);
|
|
280080
|
+
}
|
|
280081
|
+
);
|
|
280082
|
+
}
|
|
280083
|
+
const q2 = dpIds.reduce((a2, c2) => {
|
|
280084
|
+
a2[c2] = null;
|
|
280085
|
+
return a2;
|
|
280086
|
+
}, {});
|
|
280087
|
+
publishDps2({
|
|
280088
|
+
deviceId,
|
|
280089
|
+
dps: q2,
|
|
280090
|
+
mode: 2,
|
|
280091
|
+
pipelines: [1, 2, 3, 4, 5, 6],
|
|
280092
|
+
options: {}
|
|
280093
|
+
});
|
|
279994
280094
|
return {
|
|
279995
|
-
data:
|
|
279996
|
-
errorCode:
|
|
279997
|
-
errorMsg:
|
|
280095
|
+
data: true,
|
|
280096
|
+
errorCode: 0,
|
|
280097
|
+
errorMsg: import_TYUniCode3.TYUniPluginError.SUCCESS.des
|
|
279998
280098
|
};
|
|
279999
280099
|
} catch (e2) {
|
|
280000
280100
|
return {
|
|
@@ -280350,7 +280450,9 @@ function dpTranslateAdvancedCapability(params) {
|
|
|
280350
280450
|
targetStatusValue = leftDisplayValue;
|
|
280351
280451
|
} else {
|
|
280352
280452
|
let showValuePerStep = (rightDisplayValue - leftDisplayValue) / (rightOriginalValue - leftOriginalValue);
|
|
280353
|
-
targetStatusValue = Math.floor(
|
|
280453
|
+
targetStatusValue = Math.floor(
|
|
280454
|
+
(statusValue - leftOriginalValue) * showValuePerStep + leftDisplayValue
|
|
280455
|
+
);
|
|
280354
280456
|
}
|
|
280355
280457
|
return {
|
|
280356
280458
|
dpCode,
|
|
@@ -281529,6 +281631,22 @@ async function addTimer(params) {
|
|
|
281529
281631
|
};
|
|
281530
281632
|
}
|
|
281531
281633
|
}
|
|
281634
|
+
let isDpId = true;
|
|
281635
|
+
const keys = Object.keys(dps);
|
|
281636
|
+
for (const key of keys) {
|
|
281637
|
+
if (!isNumeric(key)) {
|
|
281638
|
+
isDpId = false;
|
|
281639
|
+
break;
|
|
281640
|
+
}
|
|
281641
|
+
}
|
|
281642
|
+
if (!isDpId) {
|
|
281643
|
+
return {
|
|
281644
|
+
errorCode: import_TYUniCode11.TYUniPluginError.DEVICEKIT_DEVICE_NETWORK_ERROR.code,
|
|
281645
|
+
errorMsg: import_TYUniCode11.TYUniPluginError.DEVICEKIT_DEVICE_NETWORK_ERROR.des,
|
|
281646
|
+
ext: { errorCode: "1501", errorMsg: "dpId is not a number" },
|
|
281647
|
+
data: null
|
|
281648
|
+
};
|
|
281649
|
+
}
|
|
281532
281650
|
try {
|
|
281533
281651
|
const data = await apiRequestByAtop({
|
|
281534
281652
|
api: "tuya.m.clock.dps.add",
|
|
@@ -281578,6 +281696,22 @@ async function updateTimer(params) {
|
|
|
281578
281696
|
};
|
|
281579
281697
|
}
|
|
281580
281698
|
}
|
|
281699
|
+
let isDpId = true;
|
|
281700
|
+
const keys = Object.keys(dps);
|
|
281701
|
+
for (const key of keys) {
|
|
281702
|
+
if (!isNumeric(key)) {
|
|
281703
|
+
isDpId = false;
|
|
281704
|
+
break;
|
|
281705
|
+
}
|
|
281706
|
+
}
|
|
281707
|
+
if (!isDpId) {
|
|
281708
|
+
return {
|
|
281709
|
+
errorCode: import_TYUniCode11.TYUniPluginError.DEVICEKIT_DEVICE_NETWORK_ERROR.code,
|
|
281710
|
+
errorMsg: import_TYUniCode11.TYUniPluginError.DEVICEKIT_DEVICE_NETWORK_ERROR.des,
|
|
281711
|
+
ext: { errorCode: "1501", errorMsg: "dpId is not a number" },
|
|
281712
|
+
data: null
|
|
281713
|
+
};
|
|
281714
|
+
}
|
|
281581
281715
|
try {
|
|
281582
281716
|
const data = await apiRequestByAtop({
|
|
281583
281717
|
api: "tuya.m.clock.dps.update",
|
|
@@ -282031,12 +282165,17 @@ async function getRemoteRebootTimers(params) {
|
|
|
282031
282165
|
const data = crypto_default.Encrypt23(message, device.localKey);
|
|
282032
282166
|
console.log("------publish data", data);
|
|
282033
282167
|
const topic = `smart/mb/out/${deviceId}`;
|
|
282034
|
-
initMqttClient_default._client.publish(
|
|
282035
|
-
|
|
282036
|
-
|
|
282037
|
-
|
|
282038
|
-
|
|
282039
|
-
|
|
282168
|
+
initMqttClient_default._client.publish(
|
|
282169
|
+
topic,
|
|
282170
|
+
data,
|
|
282171
|
+
{
|
|
282172
|
+
qos: 1,
|
|
282173
|
+
retain: true
|
|
282174
|
+
},
|
|
282175
|
+
(error, pocket) => {
|
|
282176
|
+
console.log("------publish", error, pocket);
|
|
282177
|
+
}
|
|
282178
|
+
);
|
|
282040
282179
|
} catch (e2) {
|
|
282041
282180
|
console.log("============fail", e2);
|
|
282042
282181
|
}
|
|
@@ -282161,7 +282300,7 @@ async function publishThingModelMessage(params) {
|
|
|
282161
282300
|
"0": `tylink/${devId}/thing/property/set`,
|
|
282162
282301
|
"1": `tylink/${devId}/thing/action/execute`
|
|
282163
282302
|
};
|
|
282164
|
-
initMqttClient_default._client.publish(topics[type], JSON.stringify(payload));
|
|
282303
|
+
initMqttClient_default._client.publish(topics[type], JSON.stringify({ data: payload, time: Number(`${Date.now()}`.substring(0, 10)) }));
|
|
282165
282304
|
return {
|
|
282166
282305
|
data: true,
|
|
282167
282306
|
errorCode: 0,
|
|
@@ -282500,6 +282639,17 @@ crypto-js/mode-ctr-gladman.js:
|
|
|
282500
282639
|
* Jan Hruby jhruby.web@gmail.com
|
|
282501
282640
|
*)
|
|
282502
282641
|
|
|
282642
|
+
js-crc/src/crc.js:
|
|
282643
|
+
(**
|
|
282644
|
+
* [js-crc]{@link https://github.com/emn178/js-crc}
|
|
282645
|
+
*
|
|
282646
|
+
* @namespace crc
|
|
282647
|
+
* @version 0.2.0
|
|
282648
|
+
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
282649
|
+
* @copyright Chen, Yi-Cyuan 2015-2017
|
|
282650
|
+
* @license MIT
|
|
282651
|
+
*)
|
|
282652
|
+
|
|
282503
282653
|
typescript/lib/typescript.js:
|
|
282504
282654
|
(*! *****************************************************************************
|
|
282505
282655
|
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-
|
|
3
|
+
"version": "1.7.3-beta-3",
|
|
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",
|