File tree 2 files changed +11
-9
lines changed
2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -112,17 +112,19 @@ class TuyaCipher {
112
112
}
113
113
114
114
/**
115
- * Decrypts data.
116
- * @param {String|Buffer } data to decrypt
117
- * @returns {Object|String }
118
- * returns object if data is JSON, else returns string
119
- */
120
- decrypt ( data ) {
121
- if ( this . version === '3.4' ) {
115
+ * Decrypts data.
116
+ * @param {String|Buffer } data to decrypt
117
+ * @param {String } [version] protocol version
118
+ * @returns {Object|String }
119
+ * returns object if data is JSON, else returns string
120
+ */
121
+ decrypt ( data , version ) {
122
+ version = version || this . version ;
123
+ if ( version === '3.4' ) {
122
124
return this . _decrypt34 ( data ) ;
123
125
}
124
126
125
- if ( this . version === '3.5' ) {
127
+ if ( version === '3.5' ) {
126
128
return this . _decrypt35 ( data ) ;
127
129
}
128
130
Original file line number Diff line number Diff line change @@ -250,7 +250,7 @@ class MessageParser {
250
250
throw new Error ( 'Missing key or version in constructor.' ) ;
251
251
}
252
252
253
- data = this . cipher . decrypt ( data ) ;
253
+ data = this . cipher . decrypt ( data , version ) ;
254
254
} catch ( _ ) {
255
255
data = data . toString ( 'utf8' ) ;
256
256
}
You can’t perform that action at this time.
0 commit comments