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

codetheweb / tuyapi / 268
92%
master: 58%

Build:
Build:
LAST BUILD BRANCH: renovate/xo-1.x
DEFAULT BRANCH: master
Ran 26 Feb 2019 11:56PM UTC
Jobs 3
Files 3
Run time 1min
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

pending completion
268

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 %.

55 of 55 new or added lines in 2 files covered. (100.0%)

213 of 243 relevant lines covered (87.65%)

23.37 hits per line

Jobs
ID Job ID Ran Files Coverage
1 268.1 26 Feb 2019 11:57PM UTC 0
87.88
Travis Job 268.1
2 268.2 26 Feb 2019 11:56PM UTC 0
87.88
Travis Job 268.2
3 268.3 26 Feb 2019 11:57PM UTC 0
87.88
Travis Job 268.3
Source Files on build 268
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #268
  • 31a0cabf on github
  • Prev Build on development (#267)
  • Next Build on development (#277)
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