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/Message.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/Message.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lang/js/src/Message.js b/lang/js/src/Message.js index c0b6ed57..e2c07344 100644 --- a/lang/js/src/Message.js +++ b/lang/js/src/Message.js @@ -36,7 +36,7 @@ export function createMessage(operation){ return gpgme_error('PARAM_WRONG'); } if (permittedOperations.hasOwnProperty(operation)){ - return new GPGME_Message(operation); + return Object.freeze(new GPGME_Message(operation)); } else { return gpgme_error('MSG_WRONG_OP'); } @@ -56,11 +56,21 @@ export class GPGME_Message { op: operation, chunksize: 1023* 1024 }; + let expected = null; this.getOperation = function(){ return _msg.op; }; + this.setExpect = function(value){ + if (value === 'base64'){ + expected = value; + } + }; + this.getExpect = function(){ + return expected; + }; + /** * The maximum size of responses from gpgme in bytes. As of July 2018, * most browsers will only accept answers up to 1 MB of size. @@ -204,7 +214,7 @@ export class GPGME_Message { return new Promise(function(resolve, reject) { if (me.isComplete() === true) { - let conn = new Connection; + let conn = Object.freeze(new Connection); conn.post(me).then(function(response) { resolve(response); }, function(reason) { |