Commit 9ea40d7
authored
Slight refactoring, add proper CRC support (#183)
* Terse defaults (#162)
* Replaced manual argument default checking with ES6 style default arguments and destructuring assignments
Improves code clarity through easy to see defaults and reduced boilerplate
Tiny tweaks for terse code; less code, less reading, less maintenance :)
* Fixed namespace collision with timeout accidentally introduced in last commit
* Travis doesn't like how terse my code is ;P
* Removed check for IP address in _send which will never be reached, since we're checking .isConnected() first
* 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 the first 3 bytes are zero, which they often (always?) are for return code
Moving forward, we should decide whether this parser should serve both client and device emulation
* Removed unused _parsed flag
* Added tests for message-parser, bringing coverage to 100
Test decoding a plaintext payload, as is the case when a device reports an error
Test for several types of corrupt messages; short, way too short, prefix and suffix mismatch
Test handling of two packets coming through at the same time
(for the time being, we just don't catch the second message; this should change)
* Removed unused crc package from dependencies
* Move clone from prod dependencies to dev dependencies
* Moved parse and encode from static wrapped Class methods into static functions, skipping the middle man
This change touched a lot of lines due to indentation and a few renames but code was otherwise unmodified
More cleanup to come once we move on to breaking changes
(ie its possible to receive multiple packets in one buffer, should therefore change parse to return an array of parsed packets)
(this will require touching index.js and so is left for another revision)
We can also return more information about the packet than we currently are
(ie sequence index, return code)
We can also generate and check CRCs (to be ported from MockTuyaCloud)
* Pin dependency clone to 2.1.2 (#167)
This PR contains the following updates:
| Package | Type | Update | Change | References |
|---|---|---|---|---|
| clone | devDependencies | pin | `^2.1.2` -> `2.1.2` | [source](https://togithub.com/pvorb/node-clone) |
:pushpin: **Important**: Renovate will wait until you have merged this Pin PR before creating any *upgrade* PRs for the affected packages. Add the preset `:preserveSemverRanges` your config if you instead don't wish to pin dependencies.
---
### Renovate configuration
:date: **Schedule**: At any time (no schedule defined).
:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.
:recycle: **Rebasing**: Whenever PR is stale, or if you modify the PR title to begin with "`rebase!`".
:ghost: **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/config-help/issues) if that's undesired.
---
- [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box
---
This PR has been generated by [Renovate Bot](https://togithub.com/marketplace/renovate). View repository job log [here](https://renovatebot.com/dashboard#codetheweb/tuyapi).
* Update dependency ava to v1.3.0 (#170)
This PR contains the following updates:
| Package | Type | Update | Change | References |
|---|---|---|---|---|
| ava | devDependencies | minor | `1.2.1` -> `1.3.0` | [homepage](https://ava.li), [source](https://togithub.com/avajs/ava) |
---
### Release Notes
<details>
<summary>avajs/ava</summary>
### [`v1.3.0`](https://togithub.com/avajs/ava/releases/v1.3.0)
[Compare Source](https://togithub.com/avajs/ava/compare/v1.2.1...v1.3.0)
#### Bug fixes
- We've fixed a rather embarrasing bug with `t.throws()` and `t.throwsAsync()`. If you'd set a `code` expectation to a number we never actually _checked_ that the thrown error had such a code! Thanks to [@​qlonik](https://togithub.com/qlonik) for both spotting and fixing this. [`82daa5e`](https://togithub.com/avajs/ava/commit/82daa5e373ef0587693927acc63ce5590e8d8eb2)
- 1.2.0 contained a regression which meant that if you [faked](https://www.npmjs.com/package/lolex) `clearTimeout()`, you'd break AVA. That's now been fixed. [`40f331c`](https://togithub.com/avajs/ava/commit/40f331c27e70690e724f9ddc893fed0556058987)
- Snapshot files are now recognized as source files, so if you're using watch mode and you delete one, AVA won't rerun _all_ your test files. [`d066f6f`](https://togithub.com/avajs/ava/commit/d066f6fbc06ab2fa2d391ff373f5f09b2585b900)
#### New features
You can now use `require()` in `ava.config.js` files to load non-ES modules. [`334e15b`](https://togithub.com/avajs/ava/commit/334e15b4af06492c9aed2800a0764f245d6a908b)
#### All changes
[`v1.2.1...v1.3.0`](https://togithub.com/avajs/ava/compare/v1.2.1...v1.3.0)
#### Thanks
Thank you [@​itaisteinherz](https://togithub.com/itaisteinherz), [@​jdalton](https://togithub.com/jdalton), [@​kagawagao](https://togithub.com/kagawagao), [@​KompKK](https://togithub.com/KompKK), [@​SleeplessByte](https://togithub.com/SleeplessByte), [@​Chrisyee22](https://togithub.com/Chrisyee22) and [@​qlonik](https://togithub.com/qlonik) for helping us with this release. We couldn't have done this without you!
#### Get involved
We welcome new contributors. AVA is a friendly place to get started in open source. We have a [great article](https://medium.com/@​vadimdemedes/making-your-first-contribution-de6576ddb190#.umxr7id07) on getting started contributing and a comprehensive [contributing guide](https://togithub.com/avajs/ava/blob/master/contributing.md).
</details>
---
### Renovate configuration
:date: **Schedule**: At any time (no schedule defined).
:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.
:recycle: **Rebasing**: Whenever PR becomes conflicted, or if you modify the PR title to begin with "`rebase!`".
:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.
---
- [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box
---
This PR has been generated by [Renovate Bot](https://togithub.com/marketplace/renovate). View repository job log [here](https://renovatebot.com/dashboard#codetheweb/tuyapi).
* Update dependency ava to v1.3.1 (#171)
This PR contains the following updates:
| Package | Type | Update | Change | References |
|---|---|---|---|---|
| ava | devDependencies | patch | `1.3.0` -> `1.3.1` | [homepage](https://ava.li), [source](https://togithub.com/avajs/ava) |
---
### Release Notes
<details>
<summary>avajs/ava</summary>
### [`v1.3.1`](https://togithub.com/avajs/ava/releases/v1.3.1)
[Compare Source](https://togithub.com/avajs/ava/compare/v1.3.0...v1.3.1)
#### Bug fixes
- We've fixed a rather embarrasing bug with `t.throws()` and `t.throwsAsync()`. If you'd set a `code` expectation to a number we never actually _checked_ that the thrown error had such a code! Thanks to [@​qlonik](https://togithub.com/qlonik) for both spotting and fixing this. [`82daa5e`](https://togithub.com/avajs/ava/commit/82daa5e373ef0587693927acc63ce5590e8d8eb2)
- 1.2.0 contained a regression which meant that if you [faked](https://www.npmjs.com/package/lolex) `clearTimeout()`, you'd break AVA. That's now been fixed. [`40f331c`](https://togithub.com/avajs/ava/commit/40f331c27e70690e724f9ddc893fed0556058987)
- Snapshot files are now recognized as source files, so if you're using watch mode and you delete one, AVA won't rerun _all_ your test files. [`d066f6f`](https://togithub.com/avajs/ava/commit/d066f6fbc06ab2fa2d391ff373f5f09b2585b900)
#### New features
You can now use `require()` in `ava.config.js` files to load non-ES modules. [`334e15b`](https://togithub.com/avajs/ava/commit/334e15b4af06492c9aed2800a0764f245d6a908b)
#### All changes
[`v1.2.1...v1.3.1`](https://togithub.com/avajs/ava/compare/v1.2.1...v1.3.1)
#### Thanks
Thank you [@​itaisteinherz](https://togithub.com/itaisteinherz), [@​jdalton](https://togithub.com/jdalton), [@​kagawagao](https://togithub.com/kagawagao), [@​KompKK](https://togithub.com/KompKK), [@​SleeplessByte](https://togithub.com/SleeplessByte), [@​Chrisyee22](https://togithub.com/Chrisyee22) and [@​qlonik](https://togithub.com/qlonik) for helping us with this release. We couldn't have done this without you!
#### Get involved
We welcome new contributors. AVA is a friendly place to get started in open source. We have a [great article](https://medium.com/@​vadimdemedes/making-your-first-contribution-de6576ddb190#.umxr7id07) on getting started contributing and a comprehensive [contributing guide](https://togithub.com/avajs/ava/blob/master/contributing.md).
</details>
---
### Renovate configuration
:date: **Schedule**: At any time (no schedule defined).
:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.
:recycle: **Rebasing**: Whenever PR becomes conflicted, or if you modify the PR title to begin with "`rebase!`".
:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.
---
- [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box
---
This PR has been generated by [Renovate Bot](https://togithub.com/marketplace/renovate). View repository job log [here](https://renovatebot.com/dashboard#codetheweb/tuyapi).
* Update dependency p-retry to v4 (#172)
This PR contains the following updates:
| Package | Type | Update | Change | References |
|---|---|---|---|---|
| p-retry | dependencies | major | [`3.0.1` -> `4.0.0`](https://diff.intrinsic.com/p-retry/3.0.1/4.0.0) | [source](https://togithub.com/sindresorhus/p-retry) |
---
### Release Notes
<details>
<summary>sindresorhus/p-retry</summary>
### [`v4.0.0`](https://togithub.com/sindresorhus/p-retry/releases/v4.0.0)
[Compare Source](https://togithub.com/sindresorhus/p-retry/compare/v3.0.1...v4.0.0)
Breaking:
- Require Node.js 8 [`0ed8d5d`](https://togithub.com/sindresorhus/p-retry/commit/0ed8d5d) ([#​21](https://togithub.com/sindresorhus/p-retry/issues/21)) [`4b6ec19`](https://togithub.com/sindresorhus/p-retry/commit/4b6ec19)
Enhancements:
- Throw a useful error if a non-error is thrown [`a9d75a5`](https://togithub.com/sindresorhus/p-retry/commit/a9d75a5)
- Add TypeScript definition ([#​21](https://togithub.com/sindresorhus/p-retry/issues/21)) [`4b6ec19`](https://togithub.com/sindresorhus/p-retry/commit/4b6ec19)
</details>
---
### Renovate configuration
:date: **Schedule**: At any time (no schedule defined).
:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.
:recycle: **Rebasing**: Whenever PR becomes conflicted, or if you modify the PR title to begin with "`rebase!`".
:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.
---
- [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box
---
This PR has been generated by [Renovate Bot](https://togithub.com/marketplace/renovate). View repository job log [here](https://renovatebot.com/dashboard#codetheweb/tuyapi).
* Update dependency p-timeout to v3 (#173)
This PR contains the following updates:
| Package | Type | Update | Change | References |
|---|---|---|---|---|
| p-timeout | dependencies | major | [`2.0.1` -> `3.0.0`](https://diff.intrinsic.com/p-timeout/2.0.1/3.0.0) | [source](https://togithub.com/sindresorhus/p-timeout) |
---
### Release Notes
<details>
<summary>sindresorhus/p-timeout</summary>
### [`v3.0.0`](https://togithub.com/sindresorhus/p-timeout/releases/v3.0.0)
[Compare Source](https://togithub.com/sindresorhus/p-timeout/compare/v2.0.1...v3.0.0)
Breaking:
- Require Node.js 8 ([#​10](https://togithub.com/sindresorhus/p-timeout/issues/10)) [`9a429bc`](https://togithub.com/sindresorhus/p-timeout/commit/9a429bc)
Enhancements:
- Add TypeScript definition ([#​10](https://togithub.com/sindresorhus/p-timeout/issues/10)) [`9a429bc`](https://togithub.com/sindresorhus/p-timeout/commit/9a429bc)
</details>
---
### Renovate configuration
:date: **Schedule**: At any time (no schedule defined).
:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.
:recycle: **Rebasing**: Whenever PR becomes conflicted, or if you modify the PR title to begin with "`rebase!`".
:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.
---
- [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box
---
This PR has been generated by [Renovate Bot](https://togithub.com/marketplace/renovate). View repository job log [here](https://renovatebot.com/dashboard#codetheweb/tuyapi).
* Update dependency documentation to v9.3.1 (#174)
This PR contains the following updates:
| Package | Type | Update | Change | References |
|---|---|---|---|---|
| documentation | devDependencies | minor | [`9.2.0` -> `9.3.1`](https://diff.intrinsic.com/documentation/9.2.0/9.3.1) | [source](https://togithub.com/documentationjs/documentation) |
---
### Release Notes
<details>
<summary>documentationjs/documentation</summary>
### [`v9.3.1`](https://togithub.com/documentationjs/documentation/blob/master/CHANGELOG.md#​1000-alpha0httpsgithubcomdocumentationjsdocumentationcomparev931v1000-alpha0-2019-03-12)
[Compare Source](https://togithub.com/documentationjs/documentation/compare/v9.3.0...v9.3.1)
##### Features
- Support custom babel config ([#​1205](https://togithub.com/documentationjs/documentation/issues/1205)) ([746d0a9](https://togithub.com/documentationjs/documentation/commit/746d0a9))
##### BREAKING CHANGES
- this may change babel configuration loading, and is a
major change to the documentation.js approach to Babel.
#### [9.3.1](https://togithub.com/documentationjs/documentation/compare/v9.3.0...v9.3.1) (2019-03-12)
### [`v9.3.0`](https://togithub.com/documentationjs/documentation/blob/master/CHANGELOG.md#​930httpsgithubcomdocumentationjsdocumentationcomparev921v930-2019-02-27)
[Compare Source](https://togithub.com/documentationjs/documentation/compare/v9.2.1...v9.3.0)
##### Features
- Add inner section ([#​1212](https://togithub.com/documentationjs/documentation/issues/1212)) ([64c9ca6](https://togithub.com/documentationjs/documentation/commit/64c9ca6))
#### [9.2.1](https://togithub.com/documentationjs/documentation/compare/v9.2.0...v9.2.1) (2019-02-26)
### [`v9.2.1`](https://togithub.com/documentationjs/documentation/blob/master/CHANGELOG.md#​930httpsgithubcomdocumentationjsdocumentationcomparev921v930-2019-02-27)
[Compare Source](https://togithub.com/documentationjs/documentation/compare/v9.2.0...v9.2.1)
##### Features
- Add inner section ([#​1212](https://togithub.com/documentationjs/documentation/issues/1212)) ([64c9ca6](https://togithub.com/documentationjs/documentation/commit/64c9ca6))
#### [9.2.1](https://togithub.com/documentationjs/documentation/compare/v9.2.0...v9.2.1) (2019-02-26)
</details>
---
### Renovate configuration
:date: **Schedule**: At any time (no schedule defined).
:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.
:recycle: **Rebasing**: Whenever PR becomes conflicted, or if you modify the PR title to begin with "`rebase!`".
:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.
---
- [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box
---
This PR has been generated by [Renovate Bot](https://togithub.com/marketplace/renovate). View repository job log [here](https://renovatebot.com/dashboard#codetheweb/tuyapi).
* Update dependency ava to v1.4.0 (#177)
This PR contains the following updates:
| Package | Type | Update | Change | References |
|---|---|---|---|---|
| ava | devDependencies | minor | [`1.3.1` -> `1.4.0`](https://diff.intrinsic.com/ava/1.3.1/1.4.0) | [homepage](https://ava.li), [source](https://togithub.com/avajs/ava) |
---
### Release Notes
<details>
<summary>avajs/ava</summary>
### [`v1.4.0`](https://togithub.com/avajs/ava/releases/v1.4.0)
[Compare Source](https://togithub.com/avajs/ava/compare/v1.3.1...v1.4.0)
#### Focusing [`power-assert`](https://togithub.com/power-assert-js/power-assert)
AVA comes with [`power-assert`](https://togithub.com/power-assert-js/power-assert) built-in, giving you more descriptive assertion messages. However it's been confusing to understand _which_ assertions come with `power-assert`. To address this we've added the new `t.assert()` assertion. It's now the only assertion that is `power-assert` enabled. The assertion passes if called with a truthy value. Consider this example:
```js
test('enhanced assertions', t => {
const a = /foo/;
const b = 'bar';
const c = 'baz';
t.assert(a.test(b) || b === c);
});
```
<details>
<summary>AVA will output:</summary>
<pre><code>6: const c = 'baz';
7: t.assert(a.test(b) || b === c);
8: });
Value is not truthy:
false
a.test(b) || b === c
=> false
b === c
=> false
c
=> 'baz'
b
=> 'bar'
a.test(b)
=> false
b
=> 'bar'
a
=> /foo/</code></pre>
</details>
Our [ESLint plugin](https://togithub.com/avajs/eslint-plugin-ava) has been updated to support this new assertion. Many thanks to [@​eemed](https://togithub.com/eemed) for implementing this! [`9406470`](https://togithub.com/avajs/ava/commit/94064702837583f1cd3920142c5d0ce50e71e255)
#### Watch mode
Watch mode now prints the available commands. Thanks [@​KompKK](https://togithub.com/KompKK)! [`cd256ac`](https://togithub.com/avajs/ava/commit/cd256ac53c975d51ddabd3d80a9f909424f5d7e3)
#### Bug fixes
- Filtered tests (when using `--match`, `.skip()` or `.only()`) are no longer included in the list of pending tests when timeouts occur or when you interrupt a test run. Thanks [@​vancouverwill](https://togithub.com/vancouverwill)! [`23e302a`](https://togithub.com/avajs/ava/commit/23e302a8dc35d03ba82916bd6591822a28d499d1)
- We're now shimming all TTY methods in the worker processes, thanks to [@​okyantoro](https://togithub.com/okyantoro). [`c1f6fdf`](https://togithub.com/avajs/ava/commit/c1f6fdfed61c99c1144cff56b58d113810c630c8)
#### Documentation updates
- We've added a note to say that, by default, AVA does not have a default test timeout. Thanks [@​amokmen](https://togithub.com/amokmen)! [`99a10a1`](https://togithub.com/avajs/ava/commit/99a10a16a3e3037326c91fb23c2a052acd3abef9)
#### All changes
[`v1.3.1...v1.4.0`](https://togithub.com/avajs/ava/compare/v1.3.1...v1.4.0)
#### Thanks
Thank you [@​eemed](https://togithub.com/eemed), [@​KompKK](https://togithub.com/KompKK), [@​vancouverwill](https://togithub.com/vancouverwill), [@​okyantoro](https://togithub.com/okyantoro) and [@​amokmen](https://togithub.com/amokmen). We couldn't have done this without you!
#### Get involved
We welcome new contributors. AVA is a friendly place to get started in open source. We have a [great article](https://medium.com/@​vadimdemedes/making-your-first-contribution-de6576ddb190#.umxr7id07) on getting started contributing and a comprehensive [contributing guide](https://togithub.com/avajs/ava/blob/master/contributing.md).
</details>
---
### Renovate configuration
:date: **Schedule**: At any time (no schedule defined).
:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.
:recycle: **Rebasing**: Whenever PR becomes conflicted, or if you modify the PR title to begin with "`rebase!`".
:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.
---
- [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box
---
This PR has been generated by [Renovate Bot](https://togithub.com/marketplace/renovate). View repository job log [here](https://renovatebot.com/dashboard#codetheweb/tuyapi).
* Implement Tuya flavored CRC (#178)
* 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
* Replaced manual argument default checking with ES6 style default arguments and destructuring assignments
Improves code clarity through easy to see defaults and reduced boilerplate
Tiny tweaks for terse code; less code, less reading, less maintenance :)
* Fixed namespace collision with timeout accidentally introduced in last commit
* Travis doesn't like how terse my code is ;P
* 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 the first 3 bytes are zero, which they often (always?) are for return code
Moving forward, we should decide whether this parser should serve both client and device emulation
* Removed unused _parsed flag
* Added tests for message-parser, bringing coverage to 100
Test decoding a plaintext payload, as is the case when a device reports an error
Test for several types of corrupt messages; short, way too short, prefix and suffix mismatch
Test handling of two packets coming through at the same time
(for the time being, we just don't catch the second message; this should change)
* Removed unused crc package from dependencies
* Move clone from prod dependencies to dev dependencies
* Moved parse and encode from static wrapped Class methods into static functions, skipping the middle man
This change touched a lot of lines due to indentation and a few renames but code was otherwise unmodified
More cleanup to come once we move on to breaking changes
(ie its possible to receive multiple packets in one buffer, should therefore change parse to return an array of parsed packets)
(this will require touching index.js and so is left for another revision)
We can also return more information about the packet than we currently are
(ie sequence index, return code)
We can also generate and check CRCs (to be ported from MockTuyaCloud)
* Removed check for IP address in _send which will never be reached, since we're checking .isConnected() first
* Added implementation of Tuya's modified CRC32 algorithm
* Restore package-lock from upstream/development
* Fix lint warnings
* Integrate CRC check in message-parser
* Update dependency ava to v1.4.1 (#179)
This PR contains the following updates:
| Package | Type | Update | Change | References |
|---|---|---|---|---|
| ava | devDependencies | patch | [`1.4.0` -> `1.4.1`](https://diff.intrinsic.com/ava/1.4.0/1.4.1) | [homepage](https://ava.li), [source](https://togithub.com/avajs/ava) |
---
### Release Notes
<details>
<summary>avajs/ava</summary>
### [`v1.4.1`](https://togithub.com/avajs/ava/releases/v1.4.1)
[Compare Source](https://togithub.com/avajs/ava/compare/v1.4.0...v1.4.1)
#### Focusing [`power-assert`](https://togithub.com/power-assert-js/power-assert)
AVA comes with [`power-assert`](https://togithub.com/power-assert-js/power-assert) built-in, giving you more descriptive assertion messages. However it's been confusing to understand _which_ assertions come with `power-assert`. To address this we've added the new `t.assert()` assertion. It's now the only assertion that is `power-assert` enabled. The assertion passes if called with a truthy value. Consider this example:
```js
test('enhanced assertions', t => {
const a = /foo/;
const b = 'bar';
const c = 'baz';
t.assert(a.test(b) || b === c);
});
```
<details>
<summary>AVA will output:</summary>
<pre><code>6: const c = 'baz';
7: t.assert(a.test(b) || b === c);
8: });
Value is not truthy:
false
a.test(b) || b === c
=> false
b === c
=> false
c
=> 'baz'
b
=> 'bar'
a.test(b)
=> false
b
=> 'bar'
a
=> /foo/</code></pre>
</details>
Our [ESLint plugin](https://togithub.com/avajs/eslint-plugin-ava) has been updated to support this new assertion. Many thanks to [@​eemed](https://togithub.com/eemed) for implementing this! [`9406470`](https://togithub.com/avajs/ava/commit/94064702837583f1cd3920142c5d0ce50e71e255)
#### Watch mode
Watch mode now prints the available commands. Thanks [@​KompKK](https://togithub.com/KompKK)! [`cd256ac`](https://togithub.com/avajs/ava/commit/cd256ac53c975d51ddabd3d80a9f909424f5d7e3)
#### Bug fixes
- Filtered tests (when using `--match`, `.skip()` or `.only()`) are no longer included in the list of pending tests when timeouts occur or when you interrupt a test run. Thanks [@​vancouverwill](https://togithub.com/vancouverwill)! [`23e302a`](https://togithub.com/avajs/ava/commit/23e302a8dc35d03ba82916bd6591822a28d499d1)
- We're now shimming all TTY methods in the worker processes, thanks to [@​okyantoro](https://togithub.com/okyantoro). [`c1f6fdf`](https://togithub.com/avajs/ava/commit/c1f6fdfed61c99c1144cff56b58d113810c630c8)
#### Documentation updates
- We've added a note to say that, by default, AVA does not have a default test timeout. Thanks [@​amokmen](https://togithub.com/amokmen)! [`99a10a1`](https://togithub.com/avajs/ava/commit/99a10a16a3e3037326c91fb23c2a052acd3abef9)
#### All changes
[`v1.3.1...v1.4.1`](https://togithub.com/avajs/ava/compare/v1.3.1...v1.4.1)
#### Thanks
Thank you [@​eemed](https://togithub.com/eemed), [@​KompKK](https://togithub.com/KompKK), [@​vancouverwill](https://togithub.com/vancouverwill), [@​okyantoro](https://togithub.com/okyantoro) and [@​amokmen](https://togithub.com/amokmen). We couldn't have done this without you!
#### Get involved
We welcome new contributors. AVA is a friendly place to get started in open source. We have a [great article](https://medium.com/@​vadimdemedes/making-your-first-contribution-de6576ddb190#.umxr7id07) on getting started contributing and a comprehensive [contributing guide](https://togithub.com/avajs/ava/blob/master/contributing.md).
</details>
---
### Renovate configuration
:date: **Schedule**: At any time (no schedule defined).
:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.
:recycle: **Rebasing**: Whenever PR becomes conflicted, or if you modify the PR title to begin with "`rebase!`".
:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.
---
- [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box
---
This PR has been generated by [Renovate Bot](https://togithub.com/marketplace/renovate). View repository job log [here](https://renovatebot.com/dashboard#codetheweb/tuyapi).
* Fix CRC computation; wrong payload range (my bad! no coding before coffee) (#182)
* Update dependency p-retry to v4.1.0 (#181)1 parent fba0db6 commit 9ea40d7
File tree
8 files changed
+1049
-662
lines changed- lib
- test
8 files changed
+1049
-662
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
| 38 | + | |
44 | 39 | | |
45 | 40 | | |
46 | | - | |
47 | | - | |
| 41 | + | |
| 42 | + | |
48 | 43 | | |
49 | 44 | | |
50 | 45 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 46 | + | |
58 | 47 | | |
59 | 48 | | |
60 | 49 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
| 50 | + | |
| 51 | + | |
69 | 52 | | |
70 | 53 | | |
71 | 54 | | |
| |||
100 | 83 | | |
101 | 84 | | |
102 | 85 | | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
| 86 | + | |
107 | 87 | | |
108 | 88 | | |
109 | 89 | | |
| |||
195 | 175 | | |
196 | 176 | | |
197 | 177 | | |
198 | | - | |
199 | | - | |
| 178 | + | |
200 | 179 | | |
201 | 180 | | |
202 | 181 | | |
| |||
266 | 245 | | |
267 | 246 | | |
268 | 247 | | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | 248 | | |
275 | 249 | | |
276 | 250 | | |
| |||
492 | 466 | | |
493 | 467 | | |
494 | 468 | | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
| 469 | + | |
500 | 470 | | |
501 | 471 | | |
502 | 472 | | |
| |||
523 | 493 | | |
524 | 494 | | |
525 | 495 | | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
| 496 | + | |
535 | 497 | | |
536 | 498 | | |
537 | 499 | | |
| |||
546 | 508 | | |
547 | 509 | | |
548 | 510 | | |
549 | | - | |
| 511 | + | |
550 | 512 | | |
551 | 513 | | |
552 | 514 | | |
| |||
569 | 531 | | |
570 | 532 | | |
571 | 533 | | |
572 | | - | |
| 534 | + | |
573 | 535 | | |
574 | 536 | | |
575 | 537 | | |
576 | 538 | | |
577 | 539 | | |
578 | | - | |
| 540 | + | |
579 | 541 | | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
| 542 | + | |
585 | 543 | | |
586 | 544 | | |
587 | 545 | | |
| |||
599 | 557 | | |
600 | 558 | | |
601 | 559 | | |
602 | | - | |
| 560 | + | |
603 | 561 | | |
604 | 562 | | |
605 | 563 | | |
606 | 564 | | |
607 | 565 | | |
608 | | - | |
| 566 | + | |
609 | 567 | | |
610 | 568 | | |
611 | 569 | | |
| |||
620 | 578 | | |
621 | 579 | | |
622 | 580 | | |
623 | | - | |
624 | | - | |
| 581 | + | |
| 582 | + | |
625 | 583 | | |
626 | 584 | | |
627 | 585 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
| 15 | + | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
30 | | - | |
31 | | - | |
32 | | - | |
| 29 | + | |
33 | 30 | | |
34 | | - | |
35 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | | - | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
53 | 57 | | |
54 | | - | |
55 | | - | |
| 58 | + | |
| 59 | + | |
56 | 60 | | |
57 | 61 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
83 | | - | |
| 82 | + | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
0 commit comments