File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -112,17 +112,19 @@ class TuyaCipher {
112112 }
113113
114114 /**
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' ) {
122124 return this . _decrypt34 ( data ) ;
123125 }
124126
125- if ( this . version === '3.5' ) {
127+ if ( version === '3.5' ) {
126128 return this . _decrypt35 ( data ) ;
127129 }
128130
Original file line number Diff line number Diff line change @@ -250,7 +250,7 @@ class MessageParser {
250250 throw new Error ( 'Missing key or version in constructor.' ) ;
251251 }
252252
253- data = this . cipher . decrypt ( data ) ;
253+ data = this . cipher . decrypt ( data , version ) ;
254254 } catch ( _ ) {
255255 data = data . toString ( 'utf8' ) ;
256256 }
You can’t perform that action at this time.
0 commit comments