zwave-js 14.3.0 → 14.3.2
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/build/cjs/Utils.d.ts +1 -1
- package/build/cjs/Utils.js +6 -2
- package/build/cjs/Utils.js.map +2 -2
- package/build/cjs/index_safe.js.map +2 -2
- package/build/cjs/lib/_version.d.ts +1 -1
- package/build/cjs/lib/_version.js +1 -1
- package/build/cjs/lib/_version.js.map +1 -1
- package/build/cjs/lib/controller/FirmwareUpdateService.js +3 -6
- package/build/cjs/lib/controller/FirmwareUpdateService.js.map +3 -3
- package/build/cjs/lib/driver/Driver.js +1 -2
- package/build/cjs/lib/driver/Driver.js.map +2 -2
- package/build/cjs/lib/node/Node.d.ts +2 -1
- package/build/cjs/lib/node/Node.js +22 -9
- package/build/cjs/lib/node/Node.js.map +2 -2
- package/build/cjs/lib/node/mixins/70_FirmwareUpdate.js +3 -4
- package/build/cjs/lib/node/mixins/70_FirmwareUpdate.js.map +2 -2
- package/build/cjs/lib/telemetry/statistics.js +4 -4
- package/build/cjs/lib/telemetry/statistics.js.map +2 -2
- package/build/esm/Utils.d.ts +1 -1
- package/build/esm/Utils.d.ts.map +1 -1
- package/build/esm/Utils.js +1 -1
- package/build/esm/Utils.js.map +1 -1
- package/build/esm/index_safe.d.ts.map +1 -1
- package/build/esm/index_safe.js +1 -0
- package/build/esm/index_safe.js.map +1 -1
- package/build/esm/lib/_version.d.ts +1 -1
- package/build/esm/lib/_version.js +1 -1
- package/build/esm/lib/controller/FirmwareUpdateService.d.ts.map +1 -1
- package/build/esm/lib/controller/FirmwareUpdateService.js +5 -11
- package/build/esm/lib/controller/FirmwareUpdateService.js.map +1 -1
- package/build/esm/lib/driver/Driver.d.ts.map +1 -1
- package/build/esm/lib/driver/Driver.js +2 -3
- package/build/esm/lib/driver/Driver.js.map +1 -1
- package/build/esm/lib/node/Node.d.ts +2 -1
- package/build/esm/lib/node/Node.d.ts.map +1 -1
- package/build/esm/lib/node/Node.js +27 -9
- package/build/esm/lib/node/Node.js.map +1 -1
- package/build/esm/lib/node/mixins/70_FirmwareUpdate.d.ts.map +1 -1
- package/build/esm/lib/node/mixins/70_FirmwareUpdate.js +1 -2
- package/build/esm/lib/node/mixins/70_FirmwareUpdate.js.map +1 -1
- package/build/esm/lib/telemetry/statistics.d.ts.map +1 -1
- package/build/esm/lib/telemetry/statistics.js +7 -9
- package/build/esm/lib/telemetry/statistics.js.map +1 -1
- package/package.json +10 -10
package/build/cjs/Utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ProtocolDataRate, ProtocolType, ProtocolVersion, Protocols, QRCodeVersion, RouteProtocolDataRate, extractFirmware, guessFirmwareFileFormat, parseQRCodeString, rssiToString, } from "@zwave-js/core";
|
|
1
|
+
export { ProtocolDataRate, ProtocolType, ProtocolVersion, Protocols, QRCodeVersion, RouteProtocolDataRate, extractFirmware, extractFirmwareAsync, guessFirmwareFileFormat, parseQRCodeString, rssiToString, tryUnzipFirmwareFile, } from "@zwave-js/core";
|
|
2
2
|
export type { Firmware, FirmwareFileFormat, QRProvisioningInformation, protocolDataRateToString, } from "@zwave-js/core";
|
|
3
3
|
export { buffer2hex, formatId, getEnumMemberName, num2hex, } from "@zwave-js/shared/safe";
|
|
4
4
|
export { createDefaultBehaviors as createDefaultMockControllerBehaviors } from "./lib/controller/MockControllerBehaviors.js";
|
package/build/cjs/Utils.js
CHANGED
|
@@ -29,6 +29,7 @@ __export(Utils_exports, {
|
|
|
29
29
|
createDefaultMockNodeBehaviors: () => import_MockNodeBehaviors.createDefaultBehaviors,
|
|
30
30
|
driverPresets: () => import_ZWaveOptions.driverPresets,
|
|
31
31
|
extractFirmware: () => import_core.extractFirmware,
|
|
32
|
+
extractFirmwareAsync: () => import_core.extractFirmwareAsync,
|
|
32
33
|
formatId: () => import_safe.formatId,
|
|
33
34
|
formatLifelineHealthCheckRound: () => import_HealthCheck.formatLifelineHealthCheckRound,
|
|
34
35
|
formatLifelineHealthCheckSummary: () => import_HealthCheck.formatLifelineHealthCheckSummary,
|
|
@@ -39,7 +40,8 @@ __export(Utils_exports, {
|
|
|
39
40
|
healthCheckRatingToWord: () => import_HealthCheck.healthCheckRatingToWord,
|
|
40
41
|
num2hex: () => import_safe.num2hex,
|
|
41
42
|
parseQRCodeString: () => import_core.parseQRCodeString,
|
|
42
|
-
rssiToString: () => import_core.rssiToString
|
|
43
|
+
rssiToString: () => import_core.rssiToString,
|
|
44
|
+
tryUnzipFirmwareFile: () => import_core.tryUnzipFirmwareFile
|
|
43
45
|
});
|
|
44
46
|
module.exports = __toCommonJS(Utils_exports);
|
|
45
47
|
var import_core = require("@zwave-js/core");
|
|
@@ -61,6 +63,7 @@ var import_MockNodeBehaviors = require("./lib/node/MockNodeBehaviors.js");
|
|
|
61
63
|
createDefaultMockNodeBehaviors,
|
|
62
64
|
driverPresets,
|
|
63
65
|
extractFirmware,
|
|
66
|
+
extractFirmwareAsync,
|
|
64
67
|
formatId,
|
|
65
68
|
formatLifelineHealthCheckRound,
|
|
66
69
|
formatLifelineHealthCheckSummary,
|
|
@@ -71,6 +74,7 @@ var import_MockNodeBehaviors = require("./lib/node/MockNodeBehaviors.js");
|
|
|
71
74
|
healthCheckRatingToWord,
|
|
72
75
|
num2hex,
|
|
73
76
|
parseQRCodeString,
|
|
74
|
-
rssiToString
|
|
77
|
+
rssiToString,
|
|
78
|
+
tryUnzipFirmwareFile
|
|
75
79
|
});
|
|
76
80
|
//# sourceMappingURL=Utils.js.map
|
package/build/cjs/Utils.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Utils.ts"],
|
|
4
|
-
"sourcesContent": ["export {\n\tProtocolDataRate,\n\tProtocolType,\n\tProtocolVersion,\n\tProtocols,\n\tQRCodeVersion,\n\tRouteProtocolDataRate,\n\textractFirmware,\n\tguessFirmwareFileFormat,\n\tparseQRCodeString,\n\trssiToString,\n} from \"@zwave-js/core\";\nexport type {\n\tFirmware,\n\tFirmwareFileFormat,\n\tQRProvisioningInformation,\n\tprotocolDataRateToString,\n} from \"@zwave-js/core\";\nexport {\n\tbuffer2hex,\n\tformatId,\n\tgetEnumMemberName,\n\tnum2hex,\n} from \"@zwave-js/shared/safe\";\nexport { createDefaultBehaviors as createDefaultMockControllerBehaviors } from \"./lib/controller/MockControllerBehaviors.js\";\nexport { driverPresets } from \"./lib/driver/ZWaveOptions.js\";\nexport {\n\tformatLifelineHealthCheckRound,\n\tformatLifelineHealthCheckSummary,\n\tformatRouteHealthCheckRound,\n\tformatRouteHealthCheckSummary,\n\thealthCheckRatingToWord,\n} from \"./lib/node/HealthCheck.js\";\nexport { createDefaultBehaviors as createDefaultMockNodeBehaviors } from \"./lib/node/MockNodeBehaviors.js\";\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA
|
|
4
|
+
"sourcesContent": ["export {\n\tProtocolDataRate,\n\tProtocolType,\n\tProtocolVersion,\n\tProtocols,\n\tQRCodeVersion,\n\tRouteProtocolDataRate,\n\textractFirmware,\n\textractFirmwareAsync,\n\tguessFirmwareFileFormat,\n\tparseQRCodeString,\n\trssiToString,\n\ttryUnzipFirmwareFile,\n} from \"@zwave-js/core\";\nexport type {\n\tFirmware,\n\tFirmwareFileFormat,\n\tQRProvisioningInformation,\n\tprotocolDataRateToString,\n} from \"@zwave-js/core\";\nexport {\n\tbuffer2hex,\n\tformatId,\n\tgetEnumMemberName,\n\tnum2hex,\n} from \"@zwave-js/shared/safe\";\nexport { createDefaultBehaviors as createDefaultMockControllerBehaviors } from \"./lib/controller/MockControllerBehaviors.js\";\nexport { driverPresets } from \"./lib/driver/ZWaveOptions.js\";\nexport {\n\tformatLifelineHealthCheckRound,\n\tformatLifelineHealthCheckSummary,\n\tformatRouteHealthCheckRound,\n\tformatRouteHealthCheckSummary,\n\thealthCheckRatingToWord,\n} from \"./lib/node/HealthCheck.js\";\nexport { createDefaultBehaviors as createDefaultMockNodeBehaviors } from \"./lib/node/MockNodeBehaviors.js\";\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAaO;AAOP,kBAKO;AACP,qCAA+E;AAC/E,0BAA8B;AAC9B,yBAMO;AACP,+BAAyE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index_safe.ts"],
|
|
4
|
-
"sourcesContent": ["/* @forbiddenImports external */\n\nexport * from \"./Controller_safe.js\";\n// export * from \"./Driver\";\nexport * from \"./Error.js\";\nexport * from \"./Node_safe.js\";\nexport * from \"./Utils_safe.js\";\nexport * from \"./Values.js\";\nexport * from \"./Zniffer_safe.js\";\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;AAAA;;
|
|
4
|
+
"sourcesContent": ["/* @forbiddenImports external */\n\n// eslint-disable-next-line @zwave-js/no-forbidden-imports -- FIXME: This is actually wrong, but I need to get the release done\nexport * from \"./Controller_safe.js\";\n// export * from \"./Driver\";\nexport * from \"./Error.js\";\nexport * from \"./Node_safe.js\";\nexport * from \"./Utils_safe.js\";\nexport * from \"./Values.js\";\nexport * from \"./Zniffer_safe.js\";\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;;AAGA,+BAAc,iCAHd;AAKA,+BAAc,uBALd;AAMA,+BAAc,2BANd;AAOA,+BAAc,4BAPd;AAQA,+BAAc,wBARd;AASA,+BAAc,8BATd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -22,7 +22,7 @@ __export(version_exports, {
|
|
|
22
22
|
PACKAGE_VERSION: () => PACKAGE_VERSION
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(version_exports);
|
|
25
|
-
const PACKAGE_VERSION = "14.3.
|
|
25
|
+
const PACKAGE_VERSION = "14.3.2";
|
|
26
26
|
const PACKAGE_NAME = "zwave-js";
|
|
27
27
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
28
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/_version.ts"],
|
|
4
|
-
"sourcesContent": ["// This file is auto-generated by the codegen maintenance script\nexport const PACKAGE_VERSION = \"14.3.
|
|
4
|
+
"sourcesContent": ["// This file is auto-generated by the codegen maintenance script\nexport const PACKAGE_VERSION = \"14.3.2\";\nexport const PACKAGE_NAME = \"zwave-js\";\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;;;;;;AACO,MAAM,kBAAkB;AACxB,MAAM,eAAe;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -34,7 +34,6 @@ __export(FirmwareUpdateService_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(FirmwareUpdateService_exports);
|
|
35
35
|
var import_core = require("@zwave-js/core");
|
|
36
36
|
var import_shared = require("@zwave-js/shared");
|
|
37
|
-
var import_node_crypto = __toESM(require("node:crypto"), 1);
|
|
38
37
|
function serviceURL() {
|
|
39
38
|
return process.env.ZWAVEJS_FW_SERVICE_URL || "https://firmware.zwave-js.io";
|
|
40
39
|
}
|
|
@@ -60,7 +59,7 @@ function cleanCache() {
|
|
|
60
59
|
}
|
|
61
60
|
}
|
|
62
61
|
async function cachedGot(config) {
|
|
63
|
-
const hash =
|
|
62
|
+
const hash = import_shared.Bytes.view(await (0, import_core.digest)("sha-256", import_shared.Bytes.from(JSON.stringify(config.json)))).toString("hex");
|
|
64
63
|
const cacheKey = `${config.method}:${config.url.toString()}:${hash}`;
|
|
65
64
|
if (requestCache.has(cacheKey)) {
|
|
66
65
|
const cached = requestCache.get(cacheKey);
|
|
@@ -200,10 +199,8 @@ async function downloadFirmwareUpdate(file) {
|
|
|
200
199
|
filename = requestedPathname;
|
|
201
200
|
}
|
|
202
201
|
const format = (0, import_core.guessFirmwareFileFormat)(filename, rawData);
|
|
203
|
-
const firmware = (0, import_core.
|
|
204
|
-
const
|
|
205
|
-
hasher.update(firmware.data);
|
|
206
|
-
const actualHash = hasher.digest("hex");
|
|
202
|
+
const firmware = await (0, import_core.extractFirmwareAsync)(rawData, format);
|
|
203
|
+
const actualHash = import_shared.Bytes.view(await (0, import_core.digest)("sha-256", firmware.data)).toString("hex");
|
|
207
204
|
if (actualHash !== expectedHash) {
|
|
208
205
|
throw new import_core.ZWaveError(`Integrity check failed. Expected hash ${expectedHash}, got ${actualHash}`, import_core.ZWaveErrorCodes.FWUpdateService_IntegrityCheckFailed);
|
|
209
206
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/controller/FirmwareUpdateService.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\ttype Firmware,\n\tRFRegion,\n\tZWaveError,\n\tZWaveErrorCodes,\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;AAAA,
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["import {\n\ttype Firmware,\n\tRFRegion,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tdigest,\n\textractFirmwareAsync,\n\tguessFirmwareFileFormat,\n} from \"@zwave-js/core\";\nimport { Bytes, formatId } from \"@zwave-js/shared\";\nimport type { Headers, OptionsOfTextResponseBody } from \"got\";\nimport type PQueue from \"p-queue\";\nimport type {\n\tFirmwareUpdateDeviceID,\n\tFirmwareUpdateFileInfo,\n\tFirmwareUpdateInfo,\n\tFirmwareUpdateServiceResponse,\n} from \"./_Types.js\";\n\nfunction serviceURL(): string {\n\treturn process.env.ZWAVEJS_FW_SERVICE_URL || \"https://firmware.zwave-js.io\";\n}\nconst DOWNLOAD_TIMEOUT = 60000;\n// const MAX_FIRMWARE_SIZE = 10 * 1024 * 1024; // 10MB should be enough for any conceivable Z-Wave chip\n\nconst MAX_CACHE_SECONDS = 60 * 60 * 24; // Cache for a day at max\nconst CLEAN_CACHE_INTERVAL_MS = 60 * 60 * 1000; // Remove stale entries from the cache every hour\n\nconst requestCache = new Map<string, CachedRequest<unknown>>();\ninterface CachedRequest<T> {\n\tresponse: T;\n\tstaleDate: number;\n}\n\n// Queue requests to the firmware update service. Only allow few parallel requests so we can make some use of the cache.\nlet requestQueue: PQueue | undefined;\n\nlet cleanCacheTimeout: NodeJS.Timeout | undefined;\nfunction cleanCache() {\n\tif (cleanCacheTimeout) {\n\t\tclearTimeout(cleanCacheTimeout);\n\t\tcleanCacheTimeout = undefined;\n\t}\n\n\tconst now = Date.now();\n\tfor (const [key, cached] of requestCache) {\n\t\tif (cached.staleDate < now) {\n\t\t\trequestCache.delete(key);\n\t\t}\n\t}\n\n\tif (requestCache.size > 0) {\n\t\tcleanCacheTimeout = setTimeout(\n\t\t\tcleanCache,\n\t\t\tCLEAN_CACHE_INTERVAL_MS,\n\t\t).unref();\n\t}\n}\n\nasync function cachedGot<T>(config: OptionsOfTextResponseBody): Promise<T> {\n\t// Replaces got's built-in cache functionality because it uses Keyv internally\n\t// which apparently has some issues: https://github.com/zwave-js/node-zwave-js/issues/5404\n\n\tconst hash = Bytes.view(\n\t\tawait digest(\n\t\t\t\"sha-256\",\n\t\t\tBytes.from(JSON.stringify(config.json)),\n\t\t),\n\t).toString(\"hex\");\n\tconst cacheKey = `${config.method}:${config.url!.toString()}:${hash}`;\n\n\t// Return cached requests if they are not stale yet\n\tif (requestCache.has(cacheKey)) {\n\t\tconst cached = requestCache.get(cacheKey)!;\n\t\tif (cached.staleDate > Date.now()) {\n\t\t\treturn cached.response as T;\n\t\t}\n\t}\n\n\tconst { got } = await import(\"got\");\n\tconst response = await got(config);\n\tconst responseJson = JSON.parse(response.body) as T;\n\n\t// Check if we can cache the response\n\tif (response.statusCode === 200 && response.headers[\"cache-control\"]) {\n\t\tconst cacheControl = response.headers[\"cache-control\"];\n\n\t\tlet maxAge: number | undefined;\n\t\tconst maxAgeMatch = cacheControl.match(/max-age=(\\d+)/);\n\t\tif (maxAgeMatch) {\n\t\t\tmaxAge = Math.max(0, parseInt(maxAgeMatch[1], 10));\n\t\t}\n\n\t\tif (maxAge) {\n\t\t\tlet currentAge: number;\n\t\t\tif (response.headers.age) {\n\t\t\t\tcurrentAge = parseInt(response.headers.age, 10);\n\t\t\t} else if (response.headers.date) {\n\t\t\t\tcurrentAge = (Date.now() - Date.parse(response.headers.date))\n\t\t\t\t\t/ 1000;\n\t\t\t} else {\n\t\t\t\tcurrentAge = 0;\n\t\t\t}\n\t\t\tcurrentAge = Math.max(0, currentAge);\n\n\t\t\tif (maxAge > currentAge) {\n\t\t\t\trequestCache.set(cacheKey, {\n\t\t\t\t\tresponse: responseJson,\n\t\t\t\t\tstaleDate: Date.now()\n\t\t\t\t\t\t+ Math.min(MAX_CACHE_SECONDS, maxAge - currentAge)\n\t\t\t\t\t\t\t* 1000,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t// Regularly clean the cache\n\tif (!cleanCacheTimeout) {\n\t\tcleanCacheTimeout = setTimeout(\n\t\t\tcleanCache,\n\t\t\tCLEAN_CACHE_INTERVAL_MS,\n\t\t).unref();\n\t}\n\n\treturn responseJson;\n}\n\nfunction hasExtension(pathname: string): boolean {\n\treturn /\\.[a-z0-9_]+$/i.test(pathname);\n}\n\nexport interface GetAvailableFirmwareUpdateOptions {\n\tuserAgent: string;\n\tapiKey?: string;\n\tincludePrereleases?: boolean;\n}\n\n/** Converts the RF region to a format the update service understands */\nfunction rfRegionToUpdateServiceRegion(\n\trfRegion?: RFRegion,\n): string | undefined {\n\tswitch (rfRegion) {\n\t\tcase RFRegion[\"Default (EU)\"]:\n\t\tcase RFRegion.Europe:\n\t\t\treturn \"europe\";\n\t\tcase RFRegion.USA:\n\t\tcase RFRegion[\"USA (Long Range)\"]:\n\t\t\treturn \"usa\";\n\t\tcase RFRegion[\"Australia/New Zealand\"]:\n\t\t\treturn \"australia/new zealand\";\n\t\tcase RFRegion[\"Hong Kong\"]:\n\t\t\treturn \"hong kong\";\n\t\tcase RFRegion.India:\n\t\t\treturn \"india\";\n\t\tcase RFRegion.Israel:\n\t\t\treturn \"israel\";\n\t\tcase RFRegion.Russia:\n\t\t\treturn \"russia\";\n\t\tcase RFRegion.China:\n\t\t\treturn \"china\";\n\t\tcase RFRegion.Japan:\n\t\t\treturn \"japan\";\n\t\tcase RFRegion.Korea:\n\t\t\treturn \"korea\";\n\t}\n}\n\n/**\n * Retrieves the available firmware updates for the node with the given fingerprint.\n * Returns the service response or `undefined` in case of an error.\n */\nexport async function getAvailableFirmwareUpdates(\n\tdeviceId: FirmwareUpdateDeviceID,\n\toptions: GetAvailableFirmwareUpdateOptions,\n): Promise<FirmwareUpdateInfo[]> {\n\tconst headers: Headers = {\n\t\t\"User-Agent\": options.userAgent,\n\t\t\"Content-Type\": \"application/json\",\n\t};\n\tif (options.apiKey) {\n\t\theaders[\"X-API-Key\"] = options.apiKey;\n\t}\n\n\tconst body: Record<string, string> = {\n\t\tmanufacturerId: formatId(deviceId.manufacturerId),\n\t\tproductType: formatId(deviceId.productType),\n\t\tproductId: formatId(deviceId.productId),\n\t\tfirmwareVersion: deviceId.firmwareVersion,\n\t};\n\tconst rfRegion = rfRegionToUpdateServiceRegion(deviceId.rfRegion);\n\tif (rfRegion) {\n\t\tbody.region = rfRegion;\n\t}\n\n\t// Prereleases and/or RF region-specific updates are only available in v3\n\tconst apiVersion = options.includePrereleases || !!rfRegion ? \"v3\" : \"v1\";\n\n\tconst config: OptionsOfTextResponseBody = {\n\t\tmethod: \"POST\",\n\t\turl: `${serviceURL()}/api/${apiVersion}/updates`,\n\t\tjson: body,\n\t\t// Consider re-enabling this instead of using cachedGot()\n\t\t// At the moment, the built-in caching has some issues though, so we stick\n\t\t// with our own implementation\n\t\t// cache: requestCache,\n\t\t// cacheOptions: {\n\t\t// \tshared: false,\n\t\t// },\n\t\theaders,\n\t};\n\n\tif (!requestQueue) {\n\t\t// I just love ESM\n\t\tconst PQueue = (await import(\"p-queue\")).default;\n\t\trequestQueue = new PQueue({ concurrency: 2 });\n\t}\n\t// Weird types...\n\tconst result = (\n\t\tawait requestQueue.add(() => cachedGot(config))\n\t) as FirmwareUpdateServiceResponse[];\n\n\t// Remember the device ID in the response, so we can use it later\n\t// to ensure the update is for the correct device\n\treturn result.map((update) => ({\n\t\tdevice: deviceId,\n\t\t...update,\n\t\tchannel: update.channel ?? \"stable\",\n\t}));\n}\n\nexport async function downloadFirmwareUpdate(\n\tfile: FirmwareUpdateFileInfo,\n): Promise<Firmware> {\n\tconst [hashAlgorithm, expectedHash] = file.integrity.split(\":\", 2);\n\n\tif (hashAlgorithm !== \"sha256\") {\n\t\tthrow new ZWaveError(\n\t\t\t`Unsupported hash algorithm ${hashAlgorithm} for integrity check`,\n\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t);\n\t}\n\t// TODO: Make request abort-able (requires AbortController, Node 14.17+ / Node 16)\n\n\t// Download the firmware file\n\tconst { got } = await import(\"got\");\n\tconst downloadResponse = await got.get(file.url, {\n\t\ttimeout: { request: DOWNLOAD_TIMEOUT },\n\t\tresponseType: \"buffer\",\n\t\t// TODO: figure out how to do maxContentLength: MAX_FIRMWARE_SIZE,\n\t});\n\n\tconst rawData = downloadResponse.body;\n\n\tconst requestedPathname = new URL(file.url).pathname;\n\t// The response may be redirected, so the filename information may be different\n\t// from the requested URL\n\tlet actualPathname: string | undefined;\n\ttry {\n\t\tactualPathname = new URL(downloadResponse.url).pathname;\n\t} catch {\n\t\t// ignore\n\t}\n\n\t// Infer the file type from the content-disposition header or the filename\n\tlet filename: string;\n\tif (\n\t\tdownloadResponse.headers[\"content-disposition\"]?.startsWith(\n\t\t\t\"attachment; filename=\",\n\t\t)\n\t) {\n\t\tfilename = downloadResponse.headers[\"content-disposition\"]\n\t\t\t.split(\"filename=\")[1]\n\t\t\t.replace(/^\"/, \"\")\n\t\t\t.replace(/[\";]$/, \"\");\n\t} else if (actualPathname && hasExtension(actualPathname)) {\n\t\tfilename = actualPathname;\n\t} else {\n\t\tfilename = requestedPathname;\n\t}\n\n\t// Extract the raw data\n\tconst format = guessFirmwareFileFormat(filename, rawData);\n\tconst firmware = await extractFirmwareAsync(rawData, format);\n\n\t// Ensure the hash matches\n\tconst actualHash = Bytes.view(\n\t\tawait digest(\"sha-256\", firmware.data),\n\t).toString(\"hex\");\n\n\tif (actualHash !== expectedHash) {\n\t\tthrow new ZWaveError(\n\t\t\t`Integrity check failed. Expected hash ${expectedHash}, got ${actualHash}`,\n\t\t\tZWaveErrorCodes.FWUpdateService_IntegrityCheckFailed,\n\t\t);\n\t}\n\n\treturn {\n\t\tdata: firmware.data,\n\t\t// Don't trust the guessed firmware target, use the one from the provided info\n\t\tfirmwareTarget: file.target,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;AAAA,kBAQO;AACP,oBAAgC;AAUhC,SAAS,aAAU;AAClB,SAAO,QAAQ,IAAI,0BAA0B;AAC9C;AACA,MAAM,mBAAmB;AAGzB,MAAM,oBAAoB,KAAK,KAAK;AACpC,MAAM,0BAA0B,KAAK,KAAK;AAE1C,MAAM,eAAe,oBAAI,IAAG;AAO5B,IAAI;AAEJ,IAAI;AACJ,SAAS,aAAU;AAClB,MAAI,mBAAmB;AACtB,iBAAa,iBAAiB;AAC9B,wBAAoB;EACrB;AAEA,QAAM,MAAM,KAAK,IAAG;AACpB,aAAW,CAAC,KAAK,MAAM,KAAK,cAAc;AACzC,QAAI,OAAO,YAAY,KAAK;AAC3B,mBAAa,OAAO,GAAG;IACxB;EACD;AAEA,MAAI,aAAa,OAAO,GAAG;AAC1B,wBAAoB,WACnB,YACA,uBAAuB,EACtB,MAAK;EACR;AACD;AAEA,eAAe,UAAa,QAAiC;AAI5D,QAAM,OAAO,oBAAM,K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
|
|
50
50
|
var import_async = require("alcalzone-shared/async");
|
|
51
51
|
var import_deferred_promise = require("alcalzone-shared/deferred-promise");
|
|
52
52
|
var import_typeguards = require("alcalzone-shared/typeguards");
|
|
53
|
-
var import_node_crypto = require("node:crypto");
|
|
54
53
|
var import_promises = __toESM(require("node:fs/promises"), 1);
|
|
55
54
|
var import_node_os = __toESM(require("node:os"), 1);
|
|
56
55
|
var import_node_path = __toESM(require("node:path"), 1);
|
|
@@ -1342,7 +1341,7 @@ class Driver extends import_shared.TypedEventEmitter {
|
|
|
1342
1341
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
1343
1342
|
async getUUID() {
|
|
1344
1343
|
if (!this._valueDB.has("uuid")) {
|
|
1345
|
-
this._valueDB.set("uuid", (0,
|
|
1344
|
+
this._valueDB.set("uuid", import_shared.Bytes.view((0, import_core.randomBytes)(32)).toString("hex"));
|
|
1346
1345
|
}
|
|
1347
1346
|
const ret = this._valueDB.get("uuid");
|
|
1348
1347
|
return ret;
|