• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

codetheweb / tuyapi / 268 / 3
92%
master: 58%

Build:
Build:
LAST BUILD BRANCH: renovate/xo-1.x
DEFAULT BRANCH: master
Ran 26 Feb 2019 11:57PM UTC
Files 3
Run time 0s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

26 Feb 2019 11:56PM UTC coverage: 87.879% (+3.5%) from 84.33%
268.3

push

travis-ci

codetheweb
Parser cipher updates (#160)

* Fixed a few parsing issues:
zero-padding is actually the return code from the device where 0 = success
Added _returnCode, _crc to MessageParser
(reordered to match order in memory)
(crc is not actually checked here, but it could be!)
More restrictive length checks, taking into account _returnCode and _crc
_commandByte is a uint32
Fill _leftOver with, well, leftovers
Reordered parse logic to match order in memory
(this also allows us to extract more data in case of a suffix mismatch)
suffix indexed relative to _payloadSize, relevant in the case of leftovers
(which happens when two messages are sent in one)

These changes were made with the best attempt to adhere to the existing coding style
I would personally make parse and encode both static functions
We could check the crc value for data integrity
If _leftOver is populated, better try decoding that too

A more drastic overhaul can be found:
https://github.com/kueblc/mocktuyacloud/blob/master/lib/lan-frame.js
But no attempt has been made to maintain the previous coding style
This adaptation was made to integrate seamlessly into the existing tuyapi project

* Reimplemented encrypt, decrypt, and md5 using built in crypto library
Removes dependency on third party node-forge library
Clarified md5 documentation

* Default encrypt options.base64 to true

* Fix lint no-negated-condition

* Cleaned up _encode implementation using one buffer to assemble payload and remove string representations of binary data

* Fixed test for encrypting with base64 option disabled
Had previously made a poor assumption about the meaning of the flag and hadn't realized utf8 is not binary safe

* Fixed cipher.encrypt base64 option, now correctly outputs a Buffer when base64 = false

* Throw appropriate errors when parsing fails
Replaced 16 with a constant HEADER_SIZE for better code readability
Cleverly account for return code or lack thereof by checking if ... (continued)

77 of 87 branches covered (88.51%)

Branch coverage included in aggregate %.

213 of 243 relevant lines covered (87.65%)

7.79 hits per line

Source Files on job 268.3
  • Tree
  • List 0
  • Changed 2
  • Source Changed 2
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 208
  • Travis Job 268.3
  • 31a0cabf on github
  • Prev Job for on development (#267.3)
  • Next Job for on development (#277.1)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc