matterbridge 3.4.7-dev-20260112-bd9e311 → 3.4.7
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/CHANGELOG.md +4 -0
- package/README-MACOS-PLIST.md +2 -4
- package/dist/broadcastServer.d.ts +115 -0
- package/dist/broadcastServer.d.ts.map +1 -0
- package/dist/broadcastServer.js +117 -0
- package/dist/broadcastServer.js.map +1 -0
- package/dist/broadcastServerTypes.d.ts +43 -0
- package/dist/broadcastServerTypes.d.ts.map +1 -0
- package/dist/broadcastServerTypes.js +24 -0
- package/dist/broadcastServerTypes.js.map +1 -0
- package/dist/cli.d.ts +24 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +97 -1
- package/dist/cli.js.map +1 -0
- package/dist/cliEmitter.d.ts +36 -0
- package/dist/cliEmitter.d.ts.map +1 -0
- package/dist/cliEmitter.js +37 -0
- package/dist/cliEmitter.js.map +1 -0
- package/dist/cliHistory.d.ts +42 -0
- package/dist/cliHistory.d.ts.map +1 -0
- package/dist/cliHistory.js +38 -0
- package/dist/cliHistory.js.map +1 -0
- package/dist/clusters/export.d.ts +1 -0
- package/dist/clusters/export.d.ts.map +1 -0
- package/dist/clusters/export.js +2 -0
- package/dist/clusters/export.js.map +1 -0
- package/dist/deviceManager.d.ts +108 -0
- package/dist/deviceManager.d.ts.map +1 -0
- package/dist/deviceManager.js +113 -1
- package/dist/deviceManager.js.map +1 -0
- package/dist/devices/airConditioner.d.ts +75 -0
- package/dist/devices/airConditioner.d.ts.map +1 -0
- package/dist/devices/airConditioner.js +57 -0
- package/dist/devices/airConditioner.js.map +1 -0
- package/dist/devices/batteryStorage.d.ts +43 -0
- package/dist/devices/batteryStorage.d.ts.map +1 -0
- package/dist/devices/batteryStorage.js +48 -1
- package/dist/devices/batteryStorage.js.map +1 -0
- package/dist/devices/cooktop.d.ts +55 -0
- package/dist/devices/cooktop.d.ts.map +1 -0
- package/dist/devices/cooktop.js +56 -0
- package/dist/devices/cooktop.js.map +1 -0
- package/dist/devices/dishwasher.d.ts +55 -0
- package/dist/devices/dishwasher.d.ts.map +1 -0
- package/dist/devices/dishwasher.js +57 -0
- package/dist/devices/dishwasher.js.map +1 -0
- package/dist/devices/evse.d.ts +57 -0
- package/dist/devices/evse.d.ts.map +1 -0
- package/dist/devices/evse.js +74 -10
- package/dist/devices/evse.js.map +1 -0
- package/dist/devices/export.d.ts +1 -0
- package/dist/devices/export.d.ts.map +1 -0
- package/dist/devices/export.js +5 -0
- package/dist/devices/export.js.map +1 -0
- package/dist/devices/extractorHood.d.ts +41 -0
- package/dist/devices/extractorHood.d.ts.map +1 -0
- package/dist/devices/extractorHood.js +43 -0
- package/dist/devices/extractorHood.js.map +1 -0
- package/dist/devices/heatPump.d.ts +43 -0
- package/dist/devices/heatPump.d.ts.map +1 -0
- package/dist/devices/heatPump.js +50 -2
- package/dist/devices/heatPump.js.map +1 -0
- package/dist/devices/laundryDryer.d.ts +58 -0
- package/dist/devices/laundryDryer.d.ts.map +1 -0
- package/dist/devices/laundryDryer.js +62 -3
- package/dist/devices/laundryDryer.js.map +1 -0
- package/dist/devices/laundryWasher.d.ts +64 -0
- package/dist/devices/laundryWasher.d.ts.map +1 -0
- package/dist/devices/laundryWasher.js +70 -4
- package/dist/devices/laundryWasher.js.map +1 -0
- package/dist/devices/microwaveOven.d.ts +77 -1
- package/dist/devices/microwaveOven.d.ts.map +1 -0
- package/dist/devices/microwaveOven.js +88 -5
- package/dist/devices/microwaveOven.js.map +1 -0
- package/dist/devices/oven.d.ts +82 -0
- package/dist/devices/oven.d.ts.map +1 -0
- package/dist/devices/oven.js +85 -0
- package/dist/devices/oven.js.map +1 -0
- package/dist/devices/refrigerator.d.ts +100 -0
- package/dist/devices/refrigerator.d.ts.map +1 -0
- package/dist/devices/refrigerator.js +102 -0
- package/dist/devices/refrigerator.js.map +1 -0
- package/dist/devices/roboticVacuumCleaner.d.ts +83 -0
- package/dist/devices/roboticVacuumCleaner.d.ts.map +1 -0
- package/dist/devices/roboticVacuumCleaner.js +100 -9
- package/dist/devices/roboticVacuumCleaner.js.map +1 -0
- package/dist/devices/solarPower.d.ts +36 -0
- package/dist/devices/solarPower.d.ts.map +1 -0
- package/dist/devices/solarPower.js +38 -0
- package/dist/devices/solarPower.js.map +1 -0
- package/dist/devices/speaker.d.ts +79 -0
- package/dist/devices/speaker.d.ts.map +1 -0
- package/dist/devices/speaker.js +84 -0
- package/dist/devices/speaker.js.map +1 -0
- package/dist/devices/temperatureControl.d.ts +21 -0
- package/dist/devices/temperatureControl.d.ts.map +1 -0
- package/dist/devices/temperatureControl.js +24 -3
- package/dist/devices/temperatureControl.js.map +1 -0
- package/dist/devices/waterHeater.d.ts +74 -0
- package/dist/devices/waterHeater.d.ts.map +1 -0
- package/dist/devices/waterHeater.js +82 -2
- package/dist/devices/waterHeater.js.map +1 -0
- package/dist/dgram/coap.d.ts +171 -0
- package/dist/dgram/coap.d.ts.map +1 -0
- package/dist/dgram/coap.js +126 -13
- package/dist/dgram/coap.js.map +1 -0
- package/dist/dgram/dgram.d.ts +99 -0
- package/dist/dgram/dgram.d.ts.map +1 -0
- package/dist/dgram/dgram.js +114 -2
- package/dist/dgram/dgram.js.map +1 -0
- package/dist/dgram/mb_coap.d.ts +23 -0
- package/dist/dgram/mb_coap.d.ts.map +1 -0
- package/dist/dgram/mb_coap.js +41 -3
- package/dist/dgram/mb_coap.js.map +1 -0
- package/dist/dgram/mb_mdns.d.ts +23 -0
- package/dist/dgram/mb_mdns.d.ts.map +1 -0
- package/dist/dgram/mb_mdns.js +80 -24
- package/dist/dgram/mb_mdns.js.map +1 -0
- package/dist/dgram/mdns.d.ts +187 -4
- package/dist/dgram/mdns.d.ts.map +1 -0
- package/dist/dgram/mdns.js +371 -139
- package/dist/dgram/mdns.js.map +1 -0
- package/dist/dgram/multicast.d.ts +49 -0
- package/dist/dgram/multicast.d.ts.map +1 -0
- package/dist/dgram/multicast.js +62 -1
- package/dist/dgram/multicast.js.map +1 -0
- package/dist/dgram/unicast.d.ts +53 -0
- package/dist/dgram/unicast.d.ts.map +1 -0
- package/dist/dgram/unicast.js +60 -0
- package/dist/dgram/unicast.js.map +1 -0
- package/dist/frontend.d.ts +187 -0
- package/dist/frontend.d.ts.map +1 -0
- package/dist/frontend.js +485 -38
- package/dist/frontend.js.map +1 -0
- package/dist/frontendTypes.d.ts +57 -0
- package/dist/frontendTypes.d.ts.map +1 -0
- package/dist/frontendTypes.js +45 -0
- package/dist/frontendTypes.js.map +1 -0
- package/dist/helpers.d.ts +43 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +53 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/jestutils/export.d.ts +1 -0
- package/dist/jestutils/export.d.ts.map +1 -0
- package/dist/jestutils/export.js +1 -0
- package/dist/jestutils/export.js.map +1 -0
- package/dist/jestutils/jestHelpers.d.ts +255 -0
- package/dist/jestutils/jestHelpers.d.ts.map +1 -0
- package/dist/jestutils/jestHelpers.js +371 -14
- package/dist/jestutils/jestHelpers.js.map +1 -0
- package/dist/logger/export.d.ts +1 -0
- package/dist/logger/export.d.ts.map +1 -0
- package/dist/logger/export.js +1 -0
- package/dist/logger/export.js.map +1 -0
- package/dist/matter/behaviors.d.ts +1 -0
- package/dist/matter/behaviors.d.ts.map +1 -0
- package/dist/matter/behaviors.js +2 -0
- package/dist/matter/behaviors.js.map +1 -0
- package/dist/matter/clusters.d.ts +1 -0
- package/dist/matter/clusters.d.ts.map +1 -0
- package/dist/matter/clusters.js +2 -0
- package/dist/matter/clusters.js.map +1 -0
- package/dist/matter/devices.d.ts +1 -0
- package/dist/matter/devices.d.ts.map +1 -0
- package/dist/matter/devices.js +2 -0
- package/dist/matter/devices.js.map +1 -0
- package/dist/matter/endpoints.d.ts +1 -0
- package/dist/matter/endpoints.d.ts.map +1 -0
- package/dist/matter/endpoints.js +2 -0
- package/dist/matter/endpoints.js.map +1 -0
- package/dist/matter/export.d.ts +1 -0
- package/dist/matter/export.d.ts.map +1 -0
- package/dist/matter/export.js +3 -0
- package/dist/matter/export.js.map +1 -0
- package/dist/matter/types.d.ts +1 -0
- package/dist/matter/types.d.ts.map +1 -0
- package/dist/matter/types.js +3 -0
- package/dist/matter/types.js.map +1 -0
- package/dist/matterNode.d.ts +258 -0
- package/dist/matterNode.d.ts.map +1 -0
- package/dist/matterNode.js +369 -8
- package/dist/matterNode.js.map +1 -0
- package/dist/matterbridge.d.ts +353 -0
- package/dist/matterbridge.d.ts.map +1 -0
- package/dist/matterbridge.js +824 -46
- package/dist/matterbridge.js.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts +36 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.js +38 -0
- package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
- package/dist/matterbridgeBehaviors.d.ts +24 -0
- package/dist/matterbridgeBehaviors.d.ts.map +1 -0
- package/dist/matterbridgeBehaviors.js +68 -5
- package/dist/matterbridgeBehaviors.js.map +1 -0
- package/dist/matterbridgeDeviceTypes.d.ts +603 -0
- package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
- package/dist/matterbridgeDeviceTypes.js +635 -14
- package/dist/matterbridgeDeviceTypes.js.map +1 -0
- package/dist/matterbridgeDynamicPlatform.d.ts +36 -0
- package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
- package/dist/matterbridgeDynamicPlatform.js +38 -0
- package/dist/matterbridgeDynamicPlatform.js.map +1 -0
- package/dist/matterbridgeEndpoint.d.ts +1332 -0
- package/dist/matterbridgeEndpoint.d.ts.map +1 -0
- package/dist/matterbridgeEndpoint.js +1457 -53
- package/dist/matterbridgeEndpoint.js.map +1 -0
- package/dist/matterbridgeEndpointHelpers.d.ts +425 -0
- package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
- package/dist/matterbridgeEndpointHelpers.js +483 -20
- package/dist/matterbridgeEndpointHelpers.js.map +1 -0
- package/dist/matterbridgeEndpointTypes.d.ts +70 -0
- package/dist/matterbridgeEndpointTypes.d.ts.map +1 -0
- package/dist/matterbridgeEndpointTypes.js +25 -0
- package/dist/matterbridgeEndpointTypes.js.map +1 -0
- package/dist/matterbridgePlatform.d.ts +425 -0
- package/dist/matterbridgePlatform.d.ts.map +1 -0
- package/dist/matterbridgePlatform.js +451 -1
- package/dist/matterbridgePlatform.js.map +1 -0
- package/dist/matterbridgeTypes.d.ts +46 -0
- package/dist/matterbridgeTypes.d.ts.map +1 -0
- package/dist/matterbridgeTypes.js +26 -0
- package/dist/matterbridgeTypes.js.map +1 -0
- package/dist/pluginManager.d.ts +305 -0
- package/dist/pluginManager.d.ts.map +1 -0
- package/dist/pluginManager.js +341 -5
- package/dist/pluginManager.js.map +1 -0
- package/dist/shelly.d.ts +157 -0
- package/dist/shelly.d.ts.map +1 -0
- package/dist/shelly.js +178 -7
- package/dist/shelly.js.map +1 -0
- package/dist/storage/export.d.ts +1 -0
- package/dist/storage/export.d.ts.map +1 -0
- package/dist/storage/export.js +1 -0
- package/dist/storage/export.js.map +1 -0
- package/dist/update.d.ts +75 -0
- package/dist/update.d.ts.map +1 -0
- package/dist/update.js +93 -1
- package/dist/update.js.map +1 -0
- package/dist/utils/colorUtils.d.ts +77 -0
- package/dist/utils/colorUtils.d.ts.map +1 -0
- package/dist/utils/colorUtils.js +97 -2
- package/dist/utils/colorUtils.js.map +1 -0
- package/dist/utils/commandLine.d.ts +60 -0
- package/dist/utils/commandLine.d.ts.map +1 -0
- package/dist/utils/commandLine.js +60 -0
- package/dist/utils/commandLine.js.map +1 -0
- package/dist/utils/copyDirectory.d.ts +33 -0
- package/dist/utils/copyDirectory.d.ts.map +1 -0
- package/dist/utils/copyDirectory.js +37 -0
- package/dist/utils/copyDirectory.js.map +1 -0
- package/dist/utils/createDirectory.d.ts +32 -0
- package/dist/utils/createDirectory.d.ts.map +1 -0
- package/dist/utils/createDirectory.js +33 -0
- package/dist/utils/createDirectory.js.map +1 -0
- package/dist/utils/createZip.d.ts +38 -0
- package/dist/utils/createZip.d.ts.map +1 -0
- package/dist/utils/createZip.js +47 -2
- package/dist/utils/createZip.js.map +1 -0
- package/dist/utils/deepCopy.d.ts +31 -0
- package/dist/utils/deepCopy.d.ts.map +1 -0
- package/dist/utils/deepCopy.js +39 -0
- package/dist/utils/deepCopy.js.map +1 -0
- package/dist/utils/deepEqual.d.ts +53 -0
- package/dist/utils/deepEqual.d.ts.map +1 -0
- package/dist/utils/deepEqual.js +72 -1
- package/dist/utils/deepEqual.js.map +1 -0
- package/dist/utils/error.d.ts +42 -0
- package/dist/utils/error.d.ts.map +1 -0
- package/dist/utils/error.js +42 -0
- package/dist/utils/error.js.map +1 -0
- package/dist/utils/export.d.ts +1 -0
- package/dist/utils/export.d.ts.map +1 -0
- package/dist/utils/export.js +1 -0
- package/dist/utils/export.js.map +1 -0
- package/dist/utils/format.d.ts +49 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +49 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/hex.d.ts +85 -0
- package/dist/utils/hex.d.ts.map +1 -0
- package/dist/utils/hex.js +124 -0
- package/dist/utils/hex.js.map +1 -0
- package/dist/utils/inspector.d.ts +63 -0
- package/dist/utils/inspector.d.ts.map +1 -0
- package/dist/utils/inspector.js +69 -1
- package/dist/utils/inspector.js.map +1 -0
- package/dist/utils/isValid.d.ts +93 -0
- package/dist/utils/isValid.d.ts.map +1 -0
- package/dist/utils/isValid.js +93 -0
- package/dist/utils/isValid.js.map +1 -0
- package/dist/utils/network.d.ts +116 -0
- package/dist/utils/network.d.ts.map +1 -0
- package/dist/utils/network.js +126 -5
- package/dist/utils/network.js.map +1 -0
- package/dist/utils/spawn.d.ts +32 -0
- package/dist/utils/spawn.d.ts.map +1 -0
- package/dist/utils/spawn.js +71 -1
- package/dist/utils/spawn.js.map +1 -0
- package/dist/utils/tracker.d.ts +56 -0
- package/dist/utils/tracker.d.ts.map +1 -0
- package/dist/utils/tracker.js +64 -1
- package/dist/utils/tracker.js.map +1 -0
- package/dist/utils/wait.d.ts +51 -0
- package/dist/utils/wait.d.ts.map +1 -0
- package/dist/utils/wait.js +60 -8
- package/dist/utils/wait.js.map +1 -0
- package/dist/workerGlobalPrefix.d.ts +24 -0
- package/dist/workerGlobalPrefix.d.ts.map +1 -0
- package/dist/workerGlobalPrefix.js +37 -5
- package/dist/workerGlobalPrefix.js.map +1 -0
- package/dist/workerTypes.d.ts +25 -0
- package/dist/workerTypes.d.ts.map +1 -0
- package/dist/workerTypes.js +24 -0
- package/dist/workerTypes.js.map +1 -0
- package/dist/workers.d.ts +61 -0
- package/dist/workers.d.ts.map +1 -0
- package/dist/workers.js +68 -4
- package/dist/workers.js.map +1 -0
- package/npm-shrinkwrap.json +115 -115
- package/package.json +2 -1
- package/packages/dgram/dist/coap.d.ts +171 -0
- package/packages/dgram/dist/coap.d.ts.map +1 -0
- package/packages/dgram/dist/coap.js +126 -13
- package/packages/dgram/dist/coap.js.map +1 -0
- package/packages/dgram/dist/dgram.d.ts +99 -0
- package/packages/dgram/dist/dgram.d.ts.map +1 -0
- package/packages/dgram/dist/dgram.js +115 -3
- package/packages/dgram/dist/dgram.js.map +1 -0
- package/packages/dgram/dist/export.d.ts +1 -0
- package/packages/dgram/dist/export.d.ts.map +1 -0
- package/packages/dgram/dist/export.js +1 -0
- package/packages/dgram/dist/export.js.map +1 -0
- package/packages/dgram/dist/mdns.d.ts +187 -4
- package/packages/dgram/dist/mdns.d.ts.map +1 -0
- package/packages/dgram/dist/mdns.js +371 -139
- package/packages/dgram/dist/mdns.js.map +1 -0
- package/packages/dgram/dist/multicast.d.ts +49 -0
- package/packages/dgram/dist/multicast.d.ts.map +1 -0
- package/packages/dgram/dist/multicast.js +62 -1
- package/packages/dgram/dist/multicast.js.map +1 -0
- package/packages/dgram/dist/unicast.d.ts +53 -0
- package/packages/dgram/dist/unicast.d.ts.map +1 -0
- package/packages/dgram/dist/unicast.js +60 -0
- package/packages/dgram/dist/unicast.js.map +1 -0
- package/packages/jest-utils/dist/export.d.ts +1 -0
- package/packages/jest-utils/dist/export.d.ts.map +1 -0
- package/packages/jest-utils/dist/export.js +1 -0
- package/packages/jest-utils/dist/export.js.map +1 -0
- package/packages/jest-utils/dist/jestHelpers.d.ts +56 -0
- package/packages/jest-utils/dist/jestHelpers.d.ts.map +1 -0
- package/packages/jest-utils/dist/jestHelpers.js +62 -1
- package/packages/jest-utils/dist/jestHelpers.js.map +1 -0
- package/packages/utils/dist/colorUtils.d.ts +77 -0
- package/packages/utils/dist/colorUtils.d.ts.map +1 -0
- package/packages/utils/dist/colorUtils.js +97 -2
- package/packages/utils/dist/colorUtils.js.map +1 -0
- package/packages/utils/dist/commandLine.d.ts +60 -0
- package/packages/utils/dist/commandLine.d.ts.map +1 -0
- package/packages/utils/dist/commandLine.js +60 -0
- package/packages/utils/dist/commandLine.js.map +1 -0
- package/packages/utils/dist/copyDirectory.d.ts +33 -0
- package/packages/utils/dist/copyDirectory.d.ts.map +1 -0
- package/packages/utils/dist/copyDirectory.js +37 -0
- package/packages/utils/dist/copyDirectory.js.map +1 -0
- package/packages/utils/dist/createDirectory.d.ts +32 -0
- package/packages/utils/dist/createDirectory.d.ts.map +1 -0
- package/packages/utils/dist/createDirectory.js +33 -0
- package/packages/utils/dist/createDirectory.js.map +1 -0
- package/packages/utils/dist/createZip.d.ts +38 -0
- package/packages/utils/dist/createZip.d.ts.map +1 -0
- package/packages/utils/dist/createZip.js +47 -2
- package/packages/utils/dist/createZip.js.map +1 -0
- package/packages/utils/dist/deepCopy.d.ts +31 -0
- package/packages/utils/dist/deepCopy.d.ts.map +1 -0
- package/packages/utils/dist/deepCopy.js +39 -0
- package/packages/utils/dist/deepCopy.js.map +1 -0
- package/packages/utils/dist/deepEqual.d.ts +53 -0
- package/packages/utils/dist/deepEqual.d.ts.map +1 -0
- package/packages/utils/dist/deepEqual.js +73 -1
- package/packages/utils/dist/deepEqual.js.map +1 -0
- package/packages/utils/dist/error.d.ts +42 -0
- package/packages/utils/dist/error.d.ts.map +1 -0
- package/packages/utils/dist/error.js +42 -0
- package/packages/utils/dist/error.js.map +1 -0
- package/packages/utils/dist/export.d.ts +1 -0
- package/packages/utils/dist/export.d.ts.map +1 -0
- package/packages/utils/dist/export.js +1 -0
- package/packages/utils/dist/export.js.map +1 -0
- package/packages/utils/dist/format.d.ts +49 -0
- package/packages/utils/dist/format.d.ts.map +1 -0
- package/packages/utils/dist/format.js +49 -0
- package/packages/utils/dist/format.js.map +1 -0
- package/packages/utils/dist/githubVersion.d.ts +32 -0
- package/packages/utils/dist/githubVersion.d.ts.map +1 -0
- package/packages/utils/dist/githubVersion.js +34 -1
- package/packages/utils/dist/githubVersion.js.map +1 -0
- package/packages/utils/dist/hex.d.ts +85 -0
- package/packages/utils/dist/hex.d.ts.map +1 -0
- package/packages/utils/dist/hex.js +124 -0
- package/packages/utils/dist/hex.js.map +1 -0
- package/packages/utils/dist/inspector.d.ts +63 -0
- package/packages/utils/dist/inspector.d.ts.map +1 -0
- package/packages/utils/dist/inspector.js +69 -1
- package/packages/utils/dist/inspector.js.map +1 -0
- package/packages/utils/dist/isValid.d.ts +93 -0
- package/packages/utils/dist/isValid.d.ts.map +1 -0
- package/packages/utils/dist/isValid.js +93 -0
- package/packages/utils/dist/isValid.js.map +1 -0
- package/packages/utils/dist/network.d.ts +93 -0
- package/packages/utils/dist/network.d.ts.map +1 -0
- package/packages/utils/dist/network.js +99 -3
- package/packages/utils/dist/network.js.map +1 -0
- package/packages/utils/dist/npmRoot.d.ts +28 -0
- package/packages/utils/dist/npmRoot.d.ts.map +1 -0
- package/packages/utils/dist/npmRoot.js +28 -0
- package/packages/utils/dist/npmRoot.js.map +1 -0
- package/packages/utils/dist/npmVersion.d.ts +32 -0
- package/packages/utils/dist/npmVersion.d.ts.map +1 -0
- package/packages/utils/dist/npmVersion.js +34 -1
- package/packages/utils/dist/npmVersion.js.map +1 -0
- package/packages/utils/dist/tracker.d.ts +56 -0
- package/packages/utils/dist/tracker.d.ts.map +1 -0
- package/packages/utils/dist/tracker.js +64 -1
- package/packages/utils/dist/tracker.js.map +1 -0
- package/packages/utils/dist/wait.d.ts +51 -0
- package/packages/utils/dist/wait.d.ts.map +1 -0
- package/packages/utils/dist/wait.js +60 -8
- package/packages/utils/dist/wait.js.map +1 -0
- package/packages/vitest-utils/dist/export.d.ts +1 -0
- package/packages/vitest-utils/dist/export.d.ts.map +1 -0
- package/packages/vitest-utils/dist/export.js +1 -0
- package/packages/vitest-utils/dist/export.js.map +1 -0
- package/packages/vitest-utils/dist/vitestHelpers.d.ts +37 -0
- package/packages/vitest-utils/dist/vitestHelpers.d.ts.map +1 -0
- package/packages/vitest-utils/dist/vitestHelpers.js +43 -1
- package/packages/vitest-utils/dist/vitestHelpers.js.map +1 -0
- package/bmc-button.svg +0 -22
- package/packages/dgram/bmc-button.svg +0 -22
- package/packages/dgram/matterbridge.svg +0 -50
- package/packages/jest-utils/bmc-button.svg +0 -22
- package/packages/jest-utils/matterbridge.svg +0 -50
- package/packages/utils/bmc-button.svg +0 -22
- package/packages/utils/matterbridge.svg +0 -50
- package/packages/vitest-utils/bmc-button.svg +0 -22
- package/packages/vitest-utils/matterbridge.svg +0 -50
|
@@ -1,8 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the error functions.
|
|
3
|
+
*
|
|
4
|
+
* @file error.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @created 2025-07-17
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
* @license Apache-2.0
|
|
9
|
+
*
|
|
10
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
11
|
+
*
|
|
12
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License.
|
|
14
|
+
* You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
* limitations under the License.
|
|
23
|
+
*/
|
|
1
24
|
import { inspect } from 'node:util';
|
|
2
25
|
import { RESET } from 'node-ansi-logger';
|
|
26
|
+
/**
|
|
27
|
+
* Logs an error message using the provided AnsiLogger instance.
|
|
28
|
+
*
|
|
29
|
+
* @param {AnsiLogger} log - The AnsiLogger instance to use for logging.
|
|
30
|
+
* @param {string} message - The error message to log.
|
|
31
|
+
* @param {unknown} error - The error object or value to log. If it's an Error instance,
|
|
32
|
+
* its message and stack trace will be included in the log.
|
|
33
|
+
*/
|
|
3
34
|
export function logError(log, message, error) {
|
|
4
35
|
log.error(`${message}: ${error instanceof Error ? error.message + ' \nStack: \n' + error.stack : error}`);
|
|
5
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Logs an error message using the provided AnsiLogger instance with detailed inspection.
|
|
39
|
+
* Uses util.inspect to get a detailed view of the error with a stack depth of 10 levels.
|
|
40
|
+
* If the error is an Error instance, it also includes the error message.
|
|
41
|
+
*
|
|
42
|
+
* @param {AnsiLogger} log - The AnsiLogger instance to use for logging.
|
|
43
|
+
* @param {string} message - The error message to log.
|
|
44
|
+
* @param {unknown} error - The error object or value to log. Will be inspected with depth 10.
|
|
45
|
+
* @returns {string} - The full logged message.
|
|
46
|
+
*/
|
|
6
47
|
export function inspectError(log, message, error) {
|
|
7
48
|
const errorMessage = error instanceof Error ? `${error.message} \n` : '';
|
|
8
49
|
const inspectedError = inspect(error, { depth: 10, colors: true, showHidden: false });
|
|
@@ -10,3 +51,4 @@ export function inspectError(log, message, error) {
|
|
|
10
51
|
log.error(fullMessage);
|
|
11
52
|
return fullMessage;
|
|
12
53
|
}
|
|
54
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,KAAK,EAAmB,MAAM,kBAAkB,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAe,EAAE,OAAe,EAAE,KAAc;IACvE,GAAG,CAAC,KAAK,CAAC,GAAG,OAAO,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;AAC5G,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,YAAY,CAAC,GAAe,EAAE,OAAe,EAAE,KAAc;IAC3E,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IACzE,MAAM,cAAc,GAAG,OAAO,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;IACtF,MAAM,WAAW,GAAG,GAAG,OAAO,KAAK,YAAY,GAAG,KAAK,GAAG,cAAc,EAAE,CAAC;IAC3E,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACvB,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../src/export.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../src/export.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
|
|
@@ -1,4 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description This file contains the format functions.
|
|
3
|
+
* @file format.ts
|
|
4
|
+
* @author Luca Liguori
|
|
5
|
+
* @created 2025-10-20
|
|
6
|
+
* @version 1.0.0
|
|
7
|
+
* @license Apache-2.0
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Format a timestamp into a human-readable string.
|
|
25
|
+
*
|
|
26
|
+
* @param {number} timestamp - The timestamp in milliseconds since the Unix epoch.
|
|
27
|
+
* @returns {string} - The formatted timestamp.
|
|
28
|
+
*/
|
|
1
29
|
export declare function formatTimeStamp(timestamp: number): string;
|
|
30
|
+
/**
|
|
31
|
+
* Format a percentage into a human-readable string.
|
|
32
|
+
*
|
|
33
|
+
* @param {number} percent - The percentage value.
|
|
34
|
+
* @param {number} digits - The number of decimal places.
|
|
35
|
+
* @returns {string} - The formatted percentage.
|
|
36
|
+
*/
|
|
2
37
|
export declare function formatPercent(percent: number, digits?: number): string;
|
|
38
|
+
/**
|
|
39
|
+
* Format bytes into a human-readable string.
|
|
40
|
+
*
|
|
41
|
+
* @param {number} bytes - The number of bytes.
|
|
42
|
+
* @param {number} digits - The number of decimal places.
|
|
43
|
+
* @returns {string} - The formatted byte string.
|
|
44
|
+
*/
|
|
3
45
|
export declare function formatBytes(bytes: number, digits?: number): string;
|
|
46
|
+
/**
|
|
47
|
+
* Function to format system uptime with only the most significant unit
|
|
48
|
+
*
|
|
49
|
+
* @param {number} seconds - The number of seconds to format
|
|
50
|
+
* @returns {string} The formatted uptime string
|
|
51
|
+
*/
|
|
4
52
|
export declare function formatUptime(seconds: number): string;
|
|
53
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,GAAG,MAAM,CAEzE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,GAAG,MAAM,CAMrE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAcpD"}
|
|
@@ -1,9 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description This file contains the format functions.
|
|
3
|
+
* @file format.ts
|
|
4
|
+
* @author Luca Liguori
|
|
5
|
+
* @created 2025-10-20
|
|
6
|
+
* @version 1.0.0
|
|
7
|
+
* @license Apache-2.0
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Format a timestamp into a human-readable string.
|
|
25
|
+
*
|
|
26
|
+
* @param {number} timestamp - The timestamp in milliseconds since the Unix epoch.
|
|
27
|
+
* @returns {string} - The formatted timestamp.
|
|
28
|
+
*/
|
|
1
29
|
export function formatTimeStamp(timestamp) {
|
|
2
30
|
return `${new Date(timestamp).toLocaleString()}`;
|
|
3
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Format a percentage into a human-readable string.
|
|
34
|
+
*
|
|
35
|
+
* @param {number} percent - The percentage value.
|
|
36
|
+
* @param {number} digits - The number of decimal places.
|
|
37
|
+
* @returns {string} - The formatted percentage.
|
|
38
|
+
*/
|
|
4
39
|
export function formatPercent(percent, digits = 2) {
|
|
5
40
|
return `${percent.toFixed(digits)} %`;
|
|
6
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Format bytes into a human-readable string.
|
|
44
|
+
*
|
|
45
|
+
* @param {number} bytes - The number of bytes.
|
|
46
|
+
* @param {number} digits - The number of decimal places.
|
|
47
|
+
* @returns {string} - The formatted byte string.
|
|
48
|
+
*/
|
|
7
49
|
export function formatBytes(bytes, digits = 2) {
|
|
8
50
|
if (bytes === 0)
|
|
9
51
|
return `${bytes.toFixed(digits)} B`;
|
|
@@ -12,6 +54,12 @@ export function formatBytes(bytes, digits = 2) {
|
|
|
12
54
|
const value = bytes / Math.pow(1024, idx);
|
|
13
55
|
return `${value.toFixed(digits)} ${units[idx]}`;
|
|
14
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Function to format system uptime with only the most significant unit
|
|
59
|
+
*
|
|
60
|
+
* @param {number} seconds - The number of seconds to format
|
|
61
|
+
* @returns {string} The formatted uptime string
|
|
62
|
+
*/
|
|
15
63
|
export function formatUptime(seconds) {
|
|
16
64
|
if (seconds >= 86400) {
|
|
17
65
|
const days = Math.floor(seconds / 86400);
|
|
@@ -27,3 +75,4 @@ export function formatUptime(seconds) {
|
|
|
27
75
|
}
|
|
28
76
|
return `${seconds} second${seconds !== 1 ? 's' : ''}`;
|
|
29
77
|
}
|
|
78
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;GAKG;AACH,MAAM,UAAU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AAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACpB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;QACzC,OAAO,GAAG,KAAK,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAClD,CAAC;IACD,IAAI,OAAO,IAAI,EAAE,EAAE,CAAC;QAClB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;QACzC,OAAO,GAAG,OAAO,UAAU,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACxD,CAAC;IACD,OAAO,GAAG,OAAO,UAAU,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AACxD,CAAC"}
|
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description This file contains the getGitHubUpdate function.
|
|
3
|
+
* @file githubVersion.ts
|
|
4
|
+
* @author Luca Liguori
|
|
5
|
+
* @created 2024-02-17
|
|
6
|
+
* @version 1.0.0
|
|
7
|
+
* @license Apache-2.0
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2024, 2025, 2026 Luca Liguori.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*/
|
|
1
23
|
export type UpdateJson = {
|
|
2
24
|
latest: string;
|
|
3
25
|
latestDate: string;
|
|
@@ -8,4 +30,14 @@ export type UpdateJson = {
|
|
|
8
30
|
devMessage: string;
|
|
9
31
|
devMessageSeverity: 'info' | 'warning' | 'error' | 'success';
|
|
10
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Retrieves a file from the public directory of the Matterbridge GitHub repository.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} branch - The branch from which to fetch the file.
|
|
37
|
+
* @param {string} file - The file path to fetch.
|
|
38
|
+
* @param {number} [timeout] - The timeout duration in milliseconds (default is 10000ms).
|
|
39
|
+
* @returns {Promise<Record<string, boolean | string | number>>} A promise that resolves to the parsed JSON object from the file.
|
|
40
|
+
* @throws {Error} If the request fails or the JSON parsing fails.
|
|
41
|
+
*/
|
|
11
42
|
export declare function getGitHubUpdate(branch: 'main' | 'dev', file: string, timeout?: number): Promise<UpdateJson>;
|
|
43
|
+
//# sourceMappingURL=githubVersion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"githubVersion.d.ts","sourceRoot":"","sources":["../src/githubVersion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,qBAAqB,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IAChE,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;CAC9D,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,MAAc,GAAG,OAAO,CAAC,UAAU,CAAC,CAyCxH"}
|
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description This file contains the getGitHubUpdate function.
|
|
3
|
+
* @file githubVersion.ts
|
|
4
|
+
* @author Luca Liguori
|
|
5
|
+
* @created 2024-02-17
|
|
6
|
+
* @version 1.0.0
|
|
7
|
+
* @license Apache-2.0
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2024, 2025, 2026 Luca Liguori.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Retrieves a file from the public directory of the Matterbridge GitHub repository.
|
|
25
|
+
*
|
|
26
|
+
* @param {string} branch - The branch from which to fetch the file.
|
|
27
|
+
* @param {string} file - The file path to fetch.
|
|
28
|
+
* @param {number} [timeout] - The timeout duration in milliseconds (default is 10000ms).
|
|
29
|
+
* @returns {Promise<Record<string, boolean | string | number>>} A promise that resolves to the parsed JSON object from the file.
|
|
30
|
+
* @throws {Error} If the request fails or the JSON parsing fails.
|
|
31
|
+
*/
|
|
1
32
|
export async function getGitHubUpdate(branch, file, timeout = 10000) {
|
|
2
33
|
const https = await import('node:https');
|
|
3
34
|
return new Promise((resolve, reject) => {
|
|
@@ -11,7 +42,7 @@ export async function getGitHubUpdate(branch, file, timeout = 10000) {
|
|
|
11
42
|
let data = '';
|
|
12
43
|
if (res.statusCode !== 200) {
|
|
13
44
|
clearTimeout(timeoutId);
|
|
14
|
-
res.resume();
|
|
45
|
+
res.resume(); // Discard response data to close the socket properly
|
|
15
46
|
reject(new Error(`Failed to fetch data. Status code: ${res.statusCode}`));
|
|
16
47
|
return;
|
|
17
48
|
}
|
|
@@ -29,9 +60,11 @@ export async function getGitHubUpdate(branch, file, timeout = 10000) {
|
|
|
29
60
|
}
|
|
30
61
|
});
|
|
31
62
|
});
|
|
63
|
+
// istanbul ignore next cause it's just a precaution for network errors
|
|
32
64
|
req.on('error', (error) => {
|
|
33
65
|
clearTimeout(timeoutId);
|
|
34
66
|
reject(new Error(`Request failed: ${error instanceof Error ? error.message : error}`));
|
|
35
67
|
});
|
|
36
68
|
});
|
|
37
69
|
}
|
|
70
|
+
//# sourceMappingURL=githubVersion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"githubVersion.js","sourceRoot":"","sources":["../src/githubVersion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAaH;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,MAAsB,EAAE,IAAY,EAAE,UAAkB,KAAK;IACjG,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC;IACzC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,GAAG,GAAG,2BAA2B,MAAM,IAAI,IAAI,EAAE,CAAC;QACxD,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;YAChC,UAAU,CAAC,KAAK,EAAE,CAAC;YACnB,MAAM,CAAC,IAAI,KAAK,CAAC,2BAA2B,OAAO,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC;QACzE,CAAC,EAAE,OAAO,CAAC,CAAC;QA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,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACzF,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,4 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the hex functions.
|
|
3
|
+
*
|
|
4
|
+
* @file hex.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @created 2025-05-06
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
* @license Apache-2.0
|
|
9
|
+
*
|
|
10
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
11
|
+
*
|
|
12
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License.
|
|
14
|
+
* You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
* limitations under the License.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Converts an ArrayBuffer or Uint8Array to a hexadecimal string.
|
|
26
|
+
*
|
|
27
|
+
* Accepts any {ArrayBufferLike} input: a raw ArrayBuffer (binary data storage) or
|
|
28
|
+
* a Uint8Array (TypedArray view over an ArrayBuffer). While an ArrayBuffer holds
|
|
29
|
+
* the raw memory, a Uint8Array is a typed view into that memory, letting you access
|
|
30
|
+
* its bytes directly. This function normalizes both by creating a Uint8Array view
|
|
31
|
+
* before conversion.
|
|
32
|
+
*
|
|
33
|
+
* @param {ArrayBufferLike} buffer - The buffer or typed-array view to convert.
|
|
34
|
+
* @returns {string} A lowercase hex string representation of the buffer's bytes.
|
|
35
|
+
*
|
|
36
|
+
* @throws {TypeError} If the input is not an ArrayBuffer or ArrayBufferView.
|
|
37
|
+
*/
|
|
1
38
|
export declare function bufferToHex(buffer: ArrayBufferLike): string;
|
|
39
|
+
/**
|
|
40
|
+
* Converts a hexadecimal string to a Uint8Array.
|
|
41
|
+
*
|
|
42
|
+
* @param {string} hex - The hex string to convert. Can include uppercase or lowercase characters.
|
|
43
|
+
* @returns {Uint8Array} A Uint8Array representing the corresponding binary data.
|
|
44
|
+
*
|
|
45
|
+
* @throws {TypeError} If the input is not a string.
|
|
46
|
+
* @throws {Error} If the input length is odd or contains non-hex characters.
|
|
47
|
+
*/
|
|
2
48
|
export declare function hexToBuffer(hex: string): Uint8Array;
|
|
49
|
+
/**
|
|
50
|
+
* Converts a PEM (Privacy-Enhanced Mail) formatted string to a Uint8Array.
|
|
51
|
+
*
|
|
52
|
+
* PEM format is a base64-encoded format commonly used for cryptographic keys and certificates,
|
|
53
|
+
* wrapped with header and footer lines like "-----BEGIN CERTIFICATE-----" and "-----END CERTIFICATE-----".
|
|
54
|
+
* This function extracts the base64 content and converts it to binary data using Node.js Buffer API.
|
|
55
|
+
*
|
|
56
|
+
* @param {string} pem - The PEM formatted string to convert.
|
|
57
|
+
* @param {boolean} validate - Whether to validate the PEM content using Node.js crypto module. Default is false.
|
|
58
|
+
* @returns {Uint8Array} A Uint8Array representing the decoded binary data.
|
|
59
|
+
*
|
|
60
|
+
* @throws {TypeError} If the input is not a string.
|
|
61
|
+
* @throws {Error} If the PEM format is invalid, contains invalid base64 characters, or validation fails.
|
|
62
|
+
*/
|
|
3
63
|
export declare function pemToBuffer(pem: string, validate?: boolean): Uint8Array;
|
|
64
|
+
/**
|
|
65
|
+
* Extracts the raw 32-byte private key scalar from an EC private key PEM.
|
|
66
|
+
*
|
|
67
|
+
* This function parses an EC private key in PEM format and extracts the raw
|
|
68
|
+
* 32-byte private scalar (the "d" value) used in elliptic curve cryptography.
|
|
69
|
+
* This is the actual secret key material.
|
|
70
|
+
*
|
|
71
|
+
* @param {string} pemPrivateKey - The EC private key in PEM format
|
|
72
|
+
* @returns {Uint8Array} The raw 32-byte private key scalar
|
|
73
|
+
* @throws {Error} If the input is not a valid EC private key PEM
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const pemKey = `-----BEGIN EC PRIVATE KEY-----
|
|
78
|
+
* MHcCAQEEIFBxqFkUxMoN2JkUXLFeiZnLNUpftjLi0sKMbZ6uajHXoAoGCCqGSM49
|
|
79
|
+
* AwEHoUQDQgAEcJ3eH/rG3zf9WmqMjh5eBSkeXz3Cb4Fig1rTosfHmgyjx/WnLPEe
|
|
80
|
+
* BF4SHvLo0G2COJEHa/VDE5EiKWO9ZR6AOQ==
|
|
81
|
+
* -----END EC PRIVATE KEY-----`;
|
|
82
|
+
*
|
|
83
|
+
* const rawKey = extractPrivateKeyRaw(pemKey);
|
|
84
|
+
* console.log(rawKey.length); // 32
|
|
85
|
+
* console.log(bufferToHex(rawKey)); // hex representation of the private scalar
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
4
88
|
export declare function extractPrivateKeyRaw(pemPrivateKey: string): Uint8Array;
|
|
89
|
+
//# sourceMappingURL=hex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../src/hex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAa3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAgCnD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,GAAE,OAAe,GAAG,UAAU,CAoG9E;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,UAAU,CAgCtE"}
|
|
@@ -1,39 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the hex functions.
|
|
3
|
+
*
|
|
4
|
+
* @file hex.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @created 2025-05-06
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
* @license Apache-2.0
|
|
9
|
+
*
|
|
10
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
11
|
+
*
|
|
12
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License.
|
|
14
|
+
* You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
* limitations under the License.
|
|
23
|
+
*/
|
|
1
24
|
import { createPublicKey, createPrivateKey, X509Certificate } from 'node:crypto';
|
|
25
|
+
/**
|
|
26
|
+
* Converts an ArrayBuffer or Uint8Array to a hexadecimal string.
|
|
27
|
+
*
|
|
28
|
+
* Accepts any {ArrayBufferLike} input: a raw ArrayBuffer (binary data storage) or
|
|
29
|
+
* a Uint8Array (TypedArray view over an ArrayBuffer). While an ArrayBuffer holds
|
|
30
|
+
* the raw memory, a Uint8Array is a typed view into that memory, letting you access
|
|
31
|
+
* its bytes directly. This function normalizes both by creating a Uint8Array view
|
|
32
|
+
* before conversion.
|
|
33
|
+
*
|
|
34
|
+
* @param {ArrayBufferLike} buffer - The buffer or typed-array view to convert.
|
|
35
|
+
* @returns {string} A lowercase hex string representation of the buffer's bytes.
|
|
36
|
+
*
|
|
37
|
+
* @throws {TypeError} If the input is not an ArrayBuffer or ArrayBufferView.
|
|
38
|
+
*/
|
|
2
39
|
export function bufferToHex(buffer) {
|
|
40
|
+
// Check if the input is an ArrayBuffer or ArrayBufferView
|
|
3
41
|
if (!(buffer instanceof ArrayBuffer || ArrayBuffer.isView(buffer))) {
|
|
4
42
|
throw new TypeError('Expected input to be an ArrayBuffer or ArrayBufferView');
|
|
5
43
|
}
|
|
44
|
+
// Create a Uint8Array view over the buffer
|
|
6
45
|
const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
46
|
+
// Convert each byte to 2-digit hex
|
|
7
47
|
return Array.from(bytes)
|
|
8
48
|
.map((byte) => byte.toString(16).padStart(2, '0'))
|
|
9
49
|
.join('');
|
|
10
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Converts a hexadecimal string to a Uint8Array.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} hex - The hex string to convert. Can include uppercase or lowercase characters.
|
|
55
|
+
* @returns {Uint8Array} A Uint8Array representing the corresponding binary data.
|
|
56
|
+
*
|
|
57
|
+
* @throws {TypeError} If the input is not a string.
|
|
58
|
+
* @throws {Error} If the input length is odd or contains non-hex characters.
|
|
59
|
+
*/
|
|
11
60
|
export function hexToBuffer(hex) {
|
|
61
|
+
// Ensure the input is a string
|
|
12
62
|
if (typeof hex !== 'string') {
|
|
13
63
|
throw new TypeError('Expected a string for hex input');
|
|
14
64
|
}
|
|
65
|
+
// Trim any whitespace from the input string
|
|
15
66
|
const cleaned = hex.trim();
|
|
67
|
+
// Check if the length of the hex string is even
|
|
16
68
|
if (cleaned.length % 2 !== 0) {
|
|
17
69
|
throw new Error('Invalid hex string length, must be even');
|
|
18
70
|
}
|
|
71
|
+
// Validate that the string contains only valid hex characters
|
|
19
72
|
if (!/^[0-9a-fA-F]*$/.test(cleaned)) {
|
|
20
73
|
throw new Error('Invalid hex string, contains non-hex characters');
|
|
21
74
|
}
|
|
75
|
+
// Calculate the length of the resulting Uint8Array
|
|
22
76
|
const length = cleaned.length / 2;
|
|
77
|
+
// Create a Uint8Array to hold the binary data
|
|
23
78
|
const result = new Uint8Array(length);
|
|
79
|
+
// Convert each pair of hex characters into a byte
|
|
24
80
|
for (let i = 0; i < length; i++) {
|
|
25
81
|
result[i] = parseInt(cleaned.substr(i * 2, 2), 16);
|
|
26
82
|
}
|
|
83
|
+
// Return the resulting Uint8Array
|
|
27
84
|
return result;
|
|
28
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Converts a PEM (Privacy-Enhanced Mail) formatted string to a Uint8Array.
|
|
88
|
+
*
|
|
89
|
+
* PEM format is a base64-encoded format commonly used for cryptographic keys and certificates,
|
|
90
|
+
* wrapped with header and footer lines like "-----BEGIN CERTIFICATE-----" and "-----END CERTIFICATE-----".
|
|
91
|
+
* This function extracts the base64 content and converts it to binary data using Node.js Buffer API.
|
|
92
|
+
*
|
|
93
|
+
* @param {string} pem - The PEM formatted string to convert.
|
|
94
|
+
* @param {boolean} validate - Whether to validate the PEM content using Node.js crypto module. Default is false.
|
|
95
|
+
* @returns {Uint8Array} A Uint8Array representing the decoded binary data.
|
|
96
|
+
*
|
|
97
|
+
* @throws {TypeError} If the input is not a string.
|
|
98
|
+
* @throws {Error} If the PEM format is invalid, contains invalid base64 characters, or validation fails.
|
|
99
|
+
*/
|
|
29
100
|
export function pemToBuffer(pem, validate = false) {
|
|
101
|
+
// Ensure the input is a string
|
|
30
102
|
if (typeof pem !== 'string') {
|
|
31
103
|
throw new TypeError('Expected a string for PEM input');
|
|
32
104
|
}
|
|
105
|
+
// Trim whitespace from the input
|
|
33
106
|
const cleaned = pem.trim();
|
|
107
|
+
// Check if the string appears to be in PEM format
|
|
34
108
|
if (!cleaned.includes('-----BEGIN') || !cleaned.includes('-----END')) {
|
|
35
109
|
throw new Error('Invalid PEM format: missing BEGIN/END markers');
|
|
36
110
|
}
|
|
111
|
+
// Extract the base64 content between the header and footer
|
|
37
112
|
const lines = cleaned.split('\n');
|
|
38
113
|
const base64Lines = [];
|
|
39
114
|
let inContent = false;
|
|
@@ -54,65 +129,114 @@ export function pemToBuffer(pem, validate = false) {
|
|
|
54
129
|
if (base64Lines.length === 0) {
|
|
55
130
|
throw new Error('Invalid PEM format: no content found between BEGIN/END markers');
|
|
56
131
|
}
|
|
132
|
+
// Join all base64 lines together
|
|
57
133
|
const base64String = base64Lines.join('');
|
|
134
|
+
// Validate base64 string format
|
|
58
135
|
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(base64String)) {
|
|
59
136
|
throw new Error('Invalid PEM format: contains invalid base64 characters');
|
|
60
137
|
}
|
|
61
138
|
try {
|
|
139
|
+
// Use Node.js Buffer API instead of legacy atob()
|
|
62
140
|
const buffer = Buffer.from(base64String, 'base64');
|
|
141
|
+
// Convert Buffer to Uint8Array
|
|
63
142
|
const result = new Uint8Array(buffer);
|
|
143
|
+
// Validate PEM content using Node.js crypto module if requested
|
|
64
144
|
if (validate) {
|
|
65
145
|
try {
|
|
146
|
+
// Determine PEM type from the header and validate accordingly
|
|
66
147
|
const pemType = cleaned.match(/-----BEGIN\s+([^-]+)-----/)?.[1]?.trim();
|
|
67
148
|
if (pemType?.includes('CERTIFICATE')) {
|
|
149
|
+
// Use X509Certificate for robust certificate validation
|
|
68
150
|
const cert = new X509Certificate(pem);
|
|
151
|
+
// Check validity period
|
|
69
152
|
if (cert.validFrom && cert.validTo) {
|
|
70
153
|
const now = Date.now();
|
|
71
154
|
const from = Date.parse(cert.validFrom);
|
|
72
155
|
const to = Date.parse(cert.validTo);
|
|
156
|
+
// istanbul ignore next if
|
|
73
157
|
if (now < from || now > to) {
|
|
74
158
|
throw new Error('Certificate is not currently valid');
|
|
75
159
|
}
|
|
76
160
|
}
|
|
161
|
+
// Check subject/issuer fields
|
|
162
|
+
// istanbul ignore next if
|
|
77
163
|
if (!cert.subject || !cert.issuer) {
|
|
78
164
|
throw new Error('Certificate missing subject or issuer');
|
|
79
165
|
}
|
|
166
|
+
// Optionally check signature (not possible without CA chain)
|
|
80
167
|
}
|
|
81
168
|
else if (pemType?.includes('PRIVATE KEY')) {
|
|
169
|
+
// For private keys, try to create a private key
|
|
82
170
|
createPrivateKey({ key: pem, format: 'pem' });
|
|
83
171
|
}
|
|
84
172
|
else if (pemType?.includes('PUBLIC KEY')) {
|
|
173
|
+
// For public keys, try to create a public key
|
|
85
174
|
createPublicKey({ key: pem, format: 'pem' });
|
|
86
175
|
}
|
|
176
|
+
// If no specific type is detected, skip validation
|
|
87
177
|
}
|
|
88
178
|
catch (validationError) {
|
|
179
|
+
// istanbul ignore next
|
|
89
180
|
throw new Error(`PEM validation failed: ${validationError instanceof Error ? validationError.message : String(validationError)}`);
|
|
90
181
|
}
|
|
91
182
|
}
|
|
92
183
|
return result;
|
|
93
184
|
}
|
|
94
185
|
catch (error) {
|
|
186
|
+
// istanbul ignore next
|
|
95
187
|
throw new Error(`Failed to decode base64 content: ${error instanceof Error ? error.message : String(error)}`);
|
|
96
188
|
}
|
|
97
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* Extracts the raw 32-byte private key scalar from an EC private key PEM.
|
|
192
|
+
*
|
|
193
|
+
* This function parses an EC private key in PEM format and extracts the raw
|
|
194
|
+
* 32-byte private scalar (the "d" value) used in elliptic curve cryptography.
|
|
195
|
+
* This is the actual secret key material.
|
|
196
|
+
*
|
|
197
|
+
* @param {string} pemPrivateKey - The EC private key in PEM format
|
|
198
|
+
* @returns {Uint8Array} The raw 32-byte private key scalar
|
|
199
|
+
* @throws {Error} If the input is not a valid EC private key PEM
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```typescript
|
|
203
|
+
* const pemKey = `-----BEGIN EC PRIVATE KEY-----
|
|
204
|
+
* MHcCAQEEIFBxqFkUxMoN2JkUXLFeiZnLNUpftjLi0sKMbZ6uajHXoAoGCCqGSM49
|
|
205
|
+
* AwEHoUQDQgAEcJ3eH/rG3zf9WmqMjh5eBSkeXz3Cb4Fig1rTosfHmgyjx/WnLPEe
|
|
206
|
+
* BF4SHvLo0G2COJEHa/VDE5EiKWO9ZR6AOQ==
|
|
207
|
+
* -----END EC PRIVATE KEY-----`;
|
|
208
|
+
*
|
|
209
|
+
* const rawKey = extractPrivateKeyRaw(pemKey);
|
|
210
|
+
* console.log(rawKey.length); // 32
|
|
211
|
+
* console.log(bufferToHex(rawKey)); // hex representation of the private scalar
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
98
214
|
export function extractPrivateKeyRaw(pemPrivateKey) {
|
|
99
215
|
if (typeof pemPrivateKey !== 'string') {
|
|
100
216
|
throw new TypeError('Expected a string for PEM private key input');
|
|
101
217
|
}
|
|
218
|
+
// Extract the private key block
|
|
102
219
|
const keyBlock = /-----BEGIN (?:EC )?PRIVATE KEY-----[^-]+-----END (?:EC )?PRIVATE KEY-----/s.exec(pemPrivateKey);
|
|
103
220
|
if (!keyBlock) {
|
|
104
221
|
throw new Error('No EC PRIVATE KEY block found in the supplied PEM');
|
|
105
222
|
}
|
|
106
223
|
try {
|
|
224
|
+
// Create a private key object
|
|
107
225
|
const privateKey = createPrivateKey(keyBlock[0]);
|
|
226
|
+
// Export as PKCS#8 DER format
|
|
108
227
|
const pkcs8Der = privateKey.export({ format: 'der', type: 'pkcs8' });
|
|
228
|
+
// For P-256 curves, the private scalar is the last 32 bytes of the PKCS#8 DER
|
|
229
|
+
// istanbul ignore next
|
|
109
230
|
if (pkcs8Der.length < 32) {
|
|
110
231
|
throw new Error('Invalid private key: DER data too short');
|
|
111
232
|
}
|
|
233
|
+
// Extract the last 32 bytes which contain the raw private scalar
|
|
112
234
|
const rawPrivateKey = pkcs8Der.subarray(pkcs8Der.length - 32);
|
|
113
235
|
return new Uint8Array(rawPrivateKey);
|
|
114
236
|
}
|
|
115
237
|
catch (error) {
|
|
238
|
+
// istanbul ignore next
|
|
116
239
|
throw new Error(`Failed to extract private key: ${error instanceof Error ? error.message : String(error)}`);
|
|
117
240
|
}
|
|
118
241
|
}
|
|
242
|
+
//# sourceMappingURL=hex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+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