diff options
author | Maximilian Krambach <[email protected]> | 2018-07-30 10:31:27 +0000 |
---|---|---|
committer | Maximilian Krambach <[email protected]> | 2018-07-30 10:31:27 +0000 |
commit | e16a87e83910ebb6bfdc4148369165f121f0997e (patch) | |
tree | 40727a6f9aec8110cc0bfaefc8aa36d14e302ecd /lang/js/src/Connection.js | |
parent | js: fix indentaion (diff) | |
download | gpgme-e16a87e83910ebb6bfdc4148369165f121f0997e.tar.gz gpgme-e16a87e83910ebb6bfdc4148369165f121f0997e.zip |
js: Making objects inmutable
--
* An Object.freeze should stop any malicious third party from changing
objects' methods once the objects are instantiated (see unittest for
an approach that would have worked before)
- An initialized gpgmejs- object doesn't have a '_Keyring' property
anymore (it still has its 'Keyring')
- The internal expect='base64' needed to be turned into a method.
Diffstat (limited to '')
-rw-r--r-- | lang/js/src/Connection.js | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lang/js/src/Connection.js b/lang/js/src/Connection.js index 561a5b70..b0105757 100644 --- a/lang/js/src/Connection.js +++ b/lang/js/src/Connection.js @@ -118,7 +118,7 @@ export class Connection{ } let chunksize = message.chunksize; return new Promise(function(resolve, reject){ - let answer = new Answer(message); + let answer = Object.freeze(new Answer(message)); let listener = function(msg) { if (!msg){ _connection.onMessage.removeListener(listener); @@ -188,14 +188,15 @@ class Answer{ */ constructor(message){ const operation = message.operation; - const expect = message.expect; + const expected = message.getExpect(); let response_b64 = null; this.getOperation = function(){ return operation; }; + this.getExpect = function(){ - return expect; + return expected; }; /** @@ -260,7 +261,7 @@ class Answer{ } if (_decodedResponse.base64 === true && poa.data[key] === 'string' - && this.getExpect() === undefined + && this.getExpect() !== 'base64' ){ _response[key] = decodeURIComponent( atob(_decodedResponse[key]).split('').map( |