Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
sensit-payload
Advanced tools
Sensit payload parser and serializer
npm install sensit-payload
const sensitPayload = require('sensit-payload');
Parse a Sensit payload and returning an object representing the values contained in the payload. The payload
argument is a 8 hexadecimals string or a 24 hexadecimals string if the config of the Sensit is sent.
The object representing the values contained in the payload will always containe the following properties:
error
{Number} - 0
if no error something else otherwise check sensitPayload.*_ERROR_CODE constantstype
{Number} - 2
for Sensit v2 payload, 3
for Sensit v3 payloadbutton
{Boolean} - true
when the button was pressed, false
otherwiseconfig
{Object} - null
if the payload does not contain the configmode
{String} - string representing the current mode, see exposed constantsmodeCode
{Number} - number representing the current mode, see exposed constantsbatteryLevel
{Number} - number of mV of the batterybattery
{Number} - percentage of the battery energy still leftThe next properties are present depending on the current mode, in case of a v2 payload when the button is pressed the record corresponding to the mode is not sent except for the temperature in the temperature mode.
temperature
{Number} - temperature in celsius degreeshumidity
{Number} - humidity in percentlight
{Number} - brightness in luxmagnet
{Boolean} - true
when magnet detected, false
otherwisevibration
{Boolean} - true
when vibration is ongoing, false
otherwisedoor
{Number} - a number representing door state, see exposed constantseventCounter
{Number} - number of times the event was catchedconst data = sensitPayload.parse("f6100065")
// { error: 0, type: 3, brightness: 1.05, button: false, modeCode: 2, mode: 'light', config: null }
The config is different depending on the current verion:
isStandByPeriodic
{Boolean} - true if StandBy is in periodic modeisTemperaturePeriodic
{Boolean} - true if Temperature is in periodic modeisDoorPeriodic
{Boolean} - true if Door is in periodic modeisMagnetPeriodic
{Boolean} - true if Magnet is in periodic modeisVibrationPeriodic
{Boolean} - true if Vibration is in periodic modeisLightPeriodic
{Boolean} - true if Light is in periodic modelightThreshold
{Number} - the brightness thresholdlightUpper
{Number} - upper brightness thresholdlightLower
{Number} - lower brightness thresholdtemperatureLower
{Number} - lower temperature thresholdtemperatureUpper
{Number} - upper temperature thresholdhumidityLower
{Number} - lower humidity thresholdhumidityUpper
{Number} - upper humidity thresholdlightLower
{Number} - lower light thresholdlightUpper
{Number} - upper light thresholdvibrationSensitivity
{Number} - code that indicates how sensitive is the vibration sensordoor
{Number} - code that indicates how sensitive is the door detectionperiod
{Number}limited
{Boolean}const data = sensitPayload.parse("895d205d00ff008f04027390")
data should contain:
{
error: 0,
type: 2,
button: false,
batteryLevel: 4150,
battery: 95,
modeCode: 1,
mode: 'temperature',
temperature: 19,
humidity: 46.5,
config: {
temperatureLower: -20,
temperatureUpper: 107,
humidityLower: 0,
humidityUpper: 0,
lightUpper: 10,
lightLower: 0,
vibrationSensitivity: 2,
door: 0,
period: 1,
limited: true
}
}
Serialize an object representating (config
argument above) Sensit config into a 16 hexadecimals string.
The payloadType
argument is either sensitPayload.PAYLOAD_TYPE_V2
or sensitPayload.PAYLOAD_TYPE_V3
, other value will throw an error.
const config = {
isStandByPeriodic: 0,
isTemperaturePeriodic: 0,
isLightPeriodic: 0,
isDoorPeriodic: 0,
isVibrationPeriodic: 0,
isMagnetPeriodic: 0,
temperatureLower: -20,
temperatureUpper: 107,
humidityLower: 0,
humidityUpper: 0,
lightThreshold: 0,
lightUpper: 10,
lightLower: 0,
vibrationSensitivity: 2,
vibrationClearTime: 0,
door: 0,
period: 1,
limited: 1
};
const payload = sensitPayload.serializeConfig(config, sensitPayload.PAYLOAD_TYPE_V3);
payload should be equal to 00ff008f04027390
Run test suite with:
npm install
npm test
npm install node-gyp -g
node-gyp rebuild
node sample.js
For more checkout https://build.sigfox.com/sensit-for-developers.
MIT
FAQs
Sensit Payload
The npm package sensit-payload receives a total of 2 weekly downloads. As such, sensit-payload popularity was classified as not popular.
We found that sensit-payload demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.