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/gpgmejs.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 'lang/js/src/gpgmejs.js')
-rw-r--r-- | lang/js/src/gpgmejs.js | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/lang/js/src/gpgmejs.js b/lang/js/src/gpgmejs.js index 720490d6..9154979d 100644 --- a/lang/js/src/gpgmejs.js +++ b/lang/js/src/gpgmejs.js @@ -102,7 +102,7 @@ export class GpgME { */ this.getKeyring = function(){ if (!_Keyring){ - _Keyring = new GPGME_Keyring; + _Keyring = Object.freeze(new GPGME_Keyring); } return _Keyring; }; @@ -241,7 +241,7 @@ export class GpgME { putData(msg, data); return new Promise(function(resolve,reject) { if (mode ==='detached'){ - msg.expect= 'base64'; + msg.setExpect('base64'); } msg.post().then( function(message) { if (mode === 'clearsign'){ @@ -319,10 +319,7 @@ export class GpgME { * Accesses the {@link GPGME_Keyring}. */ get Keyring(){ - if (!this._Keyring){ - this._Keyring = new GPGME_Keyring; - } - return this._Keyring; + return this.getKeyring(); } } |